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

Core.Compiler calls into sort with undefined view #45522

Closed
jakobnissen opened this issue May 30, 2022 · 3 comments · Fixed by #45699
Closed

Core.Compiler calls into sort with undefined view #45522

jakobnissen opened this issue May 30, 2022 · 3 comments · Fixed by #45699
Labels
bug Indicates an unexpected problem or unintended behavior sorting Put things in order
Milestone

Comments

@jakobnissen
Copy link
Contributor

jakobnissen commented May 30, 2022

The following code produces a runtime error on master (commit b2bce47 from today):

using FASTX # v1.3.0
println(first(FASTQ.Reader(IOBuffer("@A\nA\n+\nA"))))

The error is:

Internal error: encountered unexpected error in runtime:
UndefVarError(var=:view)
ijl_undefined_var_error at /home/jakni/code/julia/src/rtutils.c:132
ijl_get_binding_or_error at /home/jakni/code/julia/src/module.c:407
sort! at ./sort.jl:775
sort! at ./sort.jl:864 [inlined]
#sort!#8 at ./sort.jl:913 [inlined]
sort! at ./sort.jl:907 [inlined]
#sort#9 at ./sort.jl:961 [inlined]
sort at ./sort.jl:961 [inlined]
domsort_ssa! at ./compiler/ssair/slot2ssa.jl:399
construct_ssa! at ./compiler/ssair/slot2ssa.jl:906
slot2reg at ./compiler/optimize.jl:691 [inlined]
run_passes at ./compiler/optimize.jl:546
run_passes at ./compiler/optimize.jl:561 [inlined]
optimize at ./compiler/optimize.jl:510 [inlined]
_typeinf at ./compiler/typeinfer.jl:257
typeinf at ./compiler/typeinfer.jl:213
typeinf_edge at ./compiler/typeinfer.jl:907
abstract_call_method at ./compiler/abstractinterpretation.jl:601
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:161
abstract_call_known at ./compiler/abstractinterpretation.jl:1696
abstract_call at ./compiler/abstractinterpretation.jl:1768
abstract_call at ./compiler/abstractinterpretation.jl:1733
abstract_eval_statement at ./compiler/abstractinterpretation.jl:1889
abstract_eval_basic_statement at ./compiler/abstractinterpretation.jl:2243
typeinf_local at ./compiler/abstractinterpretation.jl:2420
typeinf_nocycle at ./compiler/abstractinterpretation.jl:2518
_typeinf at ./compiler/typeinfer.jl:230
typeinf at ./compiler/typeinfer.jl:213
typeinf_edge at ./compiler/typeinfer.jl:907
abstract_call_method at ./compiler/abstractinterpretation.jl:601
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:161
abstract_call_known at ./compiler/abstractinterpretation.jl:1696
abstract_call at ./compiler/abstractinterpretation.jl:1768
abstract_call at ./compiler/abstractinterpretation.jl:1733
abstract_eval_statement at ./compiler/abstractinterpretation.jl:1889
abstract_eval_basic_statement at ./compiler/abstractinterpretation.jl:2243
typeinf_local at ./compiler/abstractinterpretation.jl:2420
typeinf_nocycle at ./compiler/abstractinterpretation.jl:2518
_typeinf at ./compiler/typeinfer.jl:230
typeinf at ./compiler/typeinfer.jl:213
typeinf_edge at ./compiler/typeinfer.jl:907
abstract_call_method at ./compiler/abstractinterpretation.jl:601
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:161
abstract_call_known at ./compiler/abstractinterpretation.jl:1696
abstract_call at ./compiler/abstractinterpretation.jl:1768
abstract_call at ./compiler/abstractinterpretation.jl:1733
abstract_eval_statement at ./compiler/abstractinterpretation.jl:1889
abstract_eval_basic_statement at ./compiler/abstractinterpretation.jl:2243
typeinf_local at ./compiler/abstractinterpretation.jl:2420
typeinf_nocycle at ./compiler/abstractinterpretation.jl:2518
_typeinf at ./compiler/typeinfer.jl:230
typeinf at ./compiler/typeinfer.jl:213
typeinf_edge at ./compiler/typeinfer.jl:907
abstract_call_method at ./compiler/abstractinterpretation.jl:601
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:161
abstract_call_known at ./compiler/abstractinterpretation.jl:1696
abstract_call at ./compiler/abstractinterpretation.jl:1768
abstract_call at ./compiler/abstractinterpretation.jl:1733
abstract_eval_statement at ./compiler/abstractinterpretation.jl:1889
abstract_eval_basic_statement at ./compiler/abstractinterpretation.jl:2243
typeinf_local at ./compiler/abstractinterpretation.jl:2420
typeinf_nocycle at ./compiler/abstractinterpretation.jl:2518
_typeinf at ./compiler/typeinfer.jl:230
typeinf at ./compiler/typeinfer.jl:213
typeinf_edge at ./compiler/typeinfer.jl:907
abstract_call_method at ./compiler/abstractinterpretation.jl:601
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:161
abstract_call_known at ./compiler/abstractinterpretation.jl:1696
abstract_call at ./compiler/abstractinterpretation.jl:1768
abstract_call at ./compiler/abstractinterpretation.jl:1733
abstract_eval_statement at ./compiler/abstractinterpretation.jl:1889
abstract_eval_basic_statement at ./compiler/abstractinterpretation.jl:2219
typeinf_local at ./compiler/abstractinterpretation.jl:2420
typeinf_nocycle at ./compiler/abstractinterpretation.jl:2518
_typeinf at ./compiler/typeinfer.jl:230
typeinf at ./compiler/typeinfer.jl:213
typeinf_ext at ./compiler/typeinfer.jl:1031
typeinf_ext_toplevel at ./compiler/typeinfer.jl:1064
typeinf_ext_toplevel at ./compiler/typeinfer.jl:1060
jfptr_typeinf_ext_toplevel_15861 at /home/jakni/code/julia/usr/lib/julia/sys.so (unknown line)
jl_apply at /home/jakni/code/julia/src/julia.h:1841 [inlined]
jl_type_infer at /home/jakni/code/julia/src/gf.c:317
jl_generate_fptr_impl at /home/jakni/code/julia/src/jitlayers.cpp:344
jl_compile_method_internal at /home/jakni/code/julia/src/gf.c:2106 [inlined]
jl_compile_method_internal at /home/jakni/code/julia/src/gf.c:2047
_jl_invoke at /home/jakni/code/julia/src/gf.c:2384 [inlined]
ijl_apply_generic at /home/jakni/code/julia/src/gf.c:2574
jl_apply at /home/jakni/code/julia/src/julia.h:1841 [inlined]
do_call at /home/jakni/code/julia/src/interpreter.c:126
eval_value at /home/jakni/code/julia/src/interpreter.c:215
eval_stmt_value at /home/jakni/code/julia/src/interpreter.c:166 [inlined]
eval_body at /home/jakni/code/julia/src/interpreter.c:594
jl_interpret_toplevel_thunk at /home/jakni/code/julia/src/interpreter.c:750
top-level scope at /home/jakni/Downloads/biofast/code/julia/bar.jl:2
jl_toplevel_eval_flex at /home/jakni/code/julia/src/toplevel.c:912
jl_toplevel_eval_flex at /home/jakni/code/julia/src/toplevel.c:856
ijl_toplevel_eval_in at /home/jakni/code/julia/src/toplevel.c:971
eval at ./boot.jl:370 [inlined]
include_string at ./loading.jl:1349
_include at ./loading.jl:1409
include at ./Base.jl:428
jfptr_include_29022 at /home/jakni/code/julia/usr/lib/julia/sys.so (unknown line)
exec_options at ./client.jl:299
_start at ./client.jl:516
jfptr__start_23386 at /home/jakni/code/julia/usr/lib/julia/sys.so (unknown line)
jl_apply at /home/jakni/code/julia/src/julia.h:1841 [inlined]
true_main at /home/jakni/code/julia/src/jlapi.c:567
jl_repl_entrypoint at /home/jakni/code/julia/src/jlapi.c:711
main at /home/jakni/code/julia/cli/loader_exe.c:59
unknown function (ip: 0x7fbb88baf28f)
__libc_start_main at /usr/lib/libc.so.6 (unknown line)
unknown function (ip: 0x560faa377084)
@vchuravy vchuravy changed the title Error in runtime on master Core.Compiler calls into sort with undefined view May 30, 2022
@KristofferC KristofferC added this to the 1.9 milestone May 30, 2022
@LilithHafner
Copy link
Member

Thanks! I think I introduced this bug here as a part of #44230. #45584 should eliminate the issue, or we can switch from issorted(view(x, lo:hi)) to a manual loop any time if #45584 doesn't land in time.

@LilithHafner
Copy link
Member

I would not be surprised if other bugs like this are lurking in Sort.jl. I'll try to look for them when I get a chance.

@LilithHafner
Copy link
Member

On second thought, it seems like @jakobnissen ran into this issue in a real world use case, it should be very easy to fix, and #45584 is unlikely to merge any time soon. Imma just fix this now.

@LilithHafner LilithHafner added the bug Indicates an unexpected problem or unintended behavior label Jun 15, 2022
@LilithHafner LilithHafner added the sorting Put things in order label Jul 19, 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 sorting Put things in order
Projects
None yet
3 participants