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

crash on iterator comparison #40834

Closed
stevengj opened this issue May 15, 2021 · 5 comments · Fixed by #41046
Closed

crash on iterator comparison #40834

stevengj opened this issue May 15, 2021 · 5 comments · Fixed by #41046
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior compiler:codegen Generation of LLVM IR and native code

Comments

@stevengj
Copy link
Member

stevengj commented May 15, 2021

The following code is crashing with an "illegal instruction" for me in both Julia 1.6.1 (macOS x86_64) and a recent master:

function foo(s1::AbstractString, s2::AbstractString)
    function bar(i, s)
        return 1, 1, iterate(s, i[2])
    end
    i1, i2 = iterate(s1), iterate(s2)
    while i1 !== nothing && i2 !== nothing
        _, _, i1 = bar(i1, s1)
        _, _, i2 = bar(i2, s2)
    end
    return i1 === i2 # strings ended together
end

foo("foo", "foo")

gives

signal (4): Illegal instruction: 4
in expression starting at REPL[3]:1
foo at ./REPL[2]:10
unknown function (ip: 0x10b5d1493)
jl_apply_generic at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
do_call at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
eval_body at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
jl_interpret_toplevel_thunk at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
jl_toplevel_eval_flex at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
jl_toplevel_eval_flex at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
jl_toplevel_eval_in at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
eval at ./boot.jl:360 [inlined]
eval_user_input at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:139
repl_backend_loop at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:200
start_repl_backend at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:185
#run_repl#42 at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:317
run_repl at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:305
jl_apply_generic at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
#874 at ./client.jl:387
jfptr_YY.874_25971.clone_1 at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line)
jl_apply_generic at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
jl_f__call_latest at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
#invokelatest#2 at ./essentials.jl:708 [inlined]
invokelatest at ./essentials.jl:706 [inlined]
run_main_repl at ./client.jl:372
exec_options at ./client.jl:302
_start at ./client.jl:485
jfptr__start_32022.clone_1 at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line)
jl_apply_generic at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
true_main at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
repl_entrypoint at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
Allocations: 2367832 (Pool: 2366839; Big: 993); GC: 3
zsh: illegal hardware instruction  julia

It is crashing on the last line — it succeeds if I replace i1 === i2 with i1 === nothing && i2 === nothing.

@stevengj stevengj added the bug Indicates an unexpected problem or unintended behavior label May 15, 2021
@Qfl3x
Copy link
Contributor

Qfl3x commented May 15, 2021

Can confirm same issue on Linux (Binary client).

@JeffBezanson JeffBezanson added the compiler:codegen Generation of LLVM IR and native code label May 17, 2021
@stevengj
Copy link
Member Author

git bisect says that the problem is due to 94e1766 (#36796).

@JeffBezanson
Copy link
Member

Huh, strange, thanks.

@JeffBezanson JeffBezanson self-assigned this May 18, 2021
@vtjnash
Copy link
Member

vtjnash commented May 19, 2021

Sounds a bit like #40612, which I was going to work on fixing soon

@JeffBezanson
Copy link
Member

Yep looks like the same issue; confirmed by instrumenting emit_bitsunion_compare.

vtjnash added a commit that referenced this issue Jun 1, 2021
vtjnash added a commit that referenced this issue Jun 2, 2021
KristofferC pushed a commit that referenced this issue Jun 4, 2021
shirodkara pushed a commit to shirodkara/julia that referenced this issue Jun 9, 2021
johanmon pushed a commit to johanmon/julia that referenced this issue Jul 5, 2021
staticfloat pushed a commit that referenced this issue Dec 23, 2022
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 compiler:codegen Generation of LLVM IR and native code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants