Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests fail, no method isxdigit(Int32) #5142

Closed
mschauer opened this issue Dec 14, 2013 · 11 comments
Closed

tests fail, no method isxdigit(Int32) #5142

mschauer opened this issue Dec 14, 2013 · 11 comments
Labels
bug Indicates an unexpected problem or unintended behavior priority This should be addressed urgently
Milestone

Comments

@mschauer
Copy link
Contributor

While testing a bugfix, I ran into this unrelated error, which lets the test suite fail in test string.jl, line 62

julia> escape_string(string('\u1ffd', 'x'))
"´x"
julia> escape_string(string('\u1ff0','x'))
ERROR: no method isxdigit(Int32)
 in need_full_hex at string.jl:837
 in print_escaped at string.jl:843
 in sprint at io.jl:462
 in escape_string at string.jl:856
@pao
Copy link
Member

pao commented Dec 14, 2013

This test appears to pass on Travis, and isxdigit is exported from Base. Maybe you need to rebuild your system image?

@ihnorton
Copy link
Member

please send:

  • versioninfo()
  • methods(isxdigit)

@mschauer
Copy link
Contributor Author

julia> methods(isxdigit)
# 2 methods for generic function "isxdigit":
isxdigit(c::Char) at string.jl:835
isxdigit(s::String) at string.jl:836

julia> versioninfo()
Julia Version 0.3.0-prerelease+490
Commit f8f3190 (2013-12-15 07:16 UTC)
Platform Info:
  System: Linux (i686-linux-gnu)
  WORD_SIZE: 32
  BLAS: libopenblas (DYNAMIC_ARCH NO_AFFINITY)
  LAPACK: libopenblas
  LIBM: libopenlibm

@mschauer
Copy link
Contributor Author

I rebuild everything after git clean -fdx and the problem persists. I also fail at
length(1:4:typemax(Int64))==2305843009213693952 in test-ranges.

Does travis cover 32 bit machines?

@mschauer
Copy link
Contributor Author

See also #4813

@staticfloat
Copy link
Sponsor Member

I can confirm that this is a 32-bit problem. It happens on 32-bit wine and 32-bit ubuntu builds.

@staticfloat
Copy link
Sponsor Member

This is where I admit that I don't know what's going on:

julia> z = unescape_string(string('\ufff','\x0'))
"Evaluation succeeded, but an error occurred while showing value of type UTF8String:
ERROR: no method display(UTF8String)
 in display at multimedia.jl:158

(Note that this "no method" error is really just the underlying error reported above being caught by an overzealous try/catch)

julia> Base.need_full_hex(z,1)
ERROR: no method isxdigit(Int32)
 in need_full_hex at string.jl:838

julia> Base.need_full_hex(z,4)
ERROR: no method isxdigit(Int32)
 in need_full_hex at string.jl:838

julia> Base.need_full_hex(z,5)
false

However, if we just plug in the definition of Base.need_full_hex, we get:

julia> !done(z,1) && isxdigit(next(z,1)[1])
false

julia> !done(z,4) && isxdigit(next(z,4)[1])
false

julia> !done(z,5) && isxdigit(next(z,5)[1])
false

If we wrap that definition in a function though, we get an error again (instead of the correct value which is indeed false):

julia> g(s,i) = !done(s,i) && isxdigit(next(s,i)[1])
g (generic function with 1 method)

julia> g(z,1)
ERROR: no method isxdigit(Int32)
 in g at none:1

julia> g(z,4)                                                                   
ERROR: no method isxdigit(Int32)
 in g at none:1

julia> g(z,5)                                                                   
false

@StefanKarpinski
Copy link
Sponsor Member

My very vague suspicion is that this might be due to @loladiro's recently merged tuple optimization branch.

@Keno
Copy link
Member

Keno commented Jan 2, 2014

I'll grab myself a 32bit system and see what's going on.

This was referenced Jan 5, 2014
@vtjnash
Copy link
Sponsor Member

vtjnash commented Jan 10, 2014

This seems to be a reappearance of #4066:

julia> g(s,i) = !done(s,i) && isxdigit(next(s,i)[1])
g (generic function with 1 method)

julia> z = unescape_string(string('\ufff','\x0'))
"Evaluation succeeded, but an error occurred while showing value of type UTF8String:
ERROR: no method display(UTF8String)
 in display at multimedia.jl:158

julia> code_lowered(g,typeof((z,1)))
1-element Array{Any,1}:
 :($(Expr(:lambda, {:s,:i}, {{},{{:s,:Any,0},{:i,:Any,0}},{}}, quote  # none, line 1:
        unless !(done(s,i)) goto 0
        return isxdigit(getindex(next(s,i),1))
        0: 
        return false
    end)))

julia> code_typed(g,typeof((z,1)))
1-element Array{Any,1}:
 :($(Expr(:lambda, {:s,:i}, {{},{{:s,UTF8String,0},{:i,Int32,0}},{}}, quote  # none, line 1:
        unless top(box)(Bool,top(not_int)(top(slt_int)(endof(s::UTF8String)::Int32,i::Int32)::Bool))::Bool goto 0
        return isxdigit(tupleref(top(tuple)(getindex(s::UTF8String,i::Int32)::Char,top(box)(Int,top(add_int)(top(box)(Int,top(add_int)(i::Int32,1))::Int32,arrayref(top(utf8_trailing),top(box)(Int,top(add_int)(top(box)($(Int32),top(zext_int)($(Int32),arrayref(top(getfield)(s::UTF8String,:data)::Array{Uint8,1},i::Int32)::Uint8))::Int32,1))::Int32)::Int32))::Int32)::(Char,Int32),1)::Union(Int32,Char))::Bool
        0: 
        return false
    end)))

(in code_llvm, the output of the tupleref gets boxed via jl_box_int32, then passed to jl_apply_generic)

If I turn off inlining, it fails while emitting a reference to the 2nd element of ((Base.DevNullStream, Base.DevNullStream, Base.DevNullStream), Bool, Bool) with the complaint that julia-debug-basic: /home/jameson/julia/usr/include/llvm/IR/Instructions.h:704: llvm::Type* llvm::checkGEPType(llvm::Type*): Assertion Ty && "Invalid GetElementPtrInst indices for type!"' failed.`

@vtjnash vtjnash mentioned this issue Jan 11, 2014
21 tasks
@vtjnash
Copy link
Sponsor Member

vtjnash commented Jan 11, 2014

64-bit test code:

julia> bitstype 64 Int5142

julia> f(x::Int64) = "bad"
f (generic function with 1 methods)

julia> f(x::Int5142) = "good"
f (generic function with 2 methods)

julia> function g(a)
       x=a?(int64(0),reinterpret(Int5142,int64(0))):(int64(1),reinterpret(Int5142,int64(1)))
       f(x[2]::Int5142)
       end
g (generic function with 1 method)

julia> g(true)
"bad"

julia> function h(a)
              x=a?(int64(0),reinterpret(Int5142,int64(0))):(int64(1),reinterpret(Int5142,int64(1)))
              x[2]::Int5142 
              end
h (generic function with 1 method)

julia> h(true)
ERROR: type: h: in typeassert, expected Int5142, got Int64
 in h at none:3

tknopp pushed a commit to tknopp/julia that referenced this issue Jan 13, 2014
This teaches jl_new_bits how to create heap-allocated tuples from flat, stack-allocated
bits-type tuples. It also ensures that allocate_box_dynamic always marks the
julia type of its return values.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior priority This should be addressed urgently
Projects
None yet
Development

No branches or pull requests

7 participants