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

Some tests failed when testing with debug version #46064

Open
1 of 4 tasks
inkydragon opened this issue Jul 16, 2022 · 4 comments
Open
1 of 4 tasks

Some tests failed when testing with debug version #46064

inkydragon opened this issue Jul 16, 2022 · 4 comments
Labels
test This change adds or pertains to unit tests

Comments

@inkydragon
Copy link
Sponsor Member

inkydragon commented Jul 16, 2022

Test Summary:                                     |     Pass  Fail  Error  Broken     Total      Time
  Overall                                         | 40426497    20      9  352662  40779188  53m36.7s
    compiler/codegen                              |      168    13      1               182     48.4s
    ccall                                         |     2885            1              2886   7m42.7s
    misc                                          |  1282187     2                  1282189   2m37.1s
    InteractiveUtils                              |      294            2               296   1m09.2s
    FAILURE

env

  • build debug version with master branch (6008cbc).
  • running tests in WSL2 (Ubuntu), cygwin, and macOS

TODO

  • compiler/codegen
  • ccall
  • misc: GC.enable_finalizers
  • InteractiveUtils: f_broken_code

Errors

Build:

make -j `nproc`  debug

compiler/codegen

run: make -C test/ compiler/codegen debug

LoadError: could not load library "libjulia-codegen"

long logs

errors:

Error During Test at /mnt/v/julia/test/testdefs.jl:21
  Got exception outside of a @test
  LoadError: could not load library "libjulia-codegen"
  libjulia-codegen.so: cannot open shared object file: No such file or directory
  Stacktrace:
    [1] dlopen(s::String, flags::UInt32; throw_error::Bool)
      @ Base.Libc.Libdl ./libdl.jl:117
    [2] dlopen (repeats 2 times)
      @ ./libdl.jl:116 [inlined]
    [3] dlpath(libname::String)
      @ Base.Libc.Libdl ./libdl.jl:240
    [4] (::Main.Test98Main_compiler_codegen.var"#36#38")(pfx::String)
      @ Main.Test98Main_compiler_codegen /mnt/v/julia/test/compiler/codegen.jl:681
    [5] mktempdir(fn::Main.Test98Main_compiler_codegen.var"#36#38", parent::String; prefix::String)
      @ Base.Filesystem ./file.jl:760
    [6] mktempdir(fn::Function, parent::String) (repeats 2 times)
      @ Base.Filesystem ./file.jl:756
    [7] top-level scope
      @ /mnt/v/julia/test/compiler/codegen.jl:679
    [8] include
      @ ./Base.jl:424 [inlined]
    [9] macro expansion
      @ /mnt/v/julia/test/testdefs.jl:24 [inlined]
   [10] macro expansion
      @ /mnt/v/julia/usr/share/julia/stdlib/v1.9/Test/src/Test.jl:1388 [inlined]
   [11] macro expansion
      @ /mnt/v/julia/test/testdefs.jl:23 [inlined]
   [12] macro expansion
      @ ./timing.jl:473 [inlined]
   [13] runtests(name::String, path::String, isolate::Bool; seed::UInt128)
      @ Main /mnt/v/julia/test/testdefs.jl:21
   [14] invokelatest(::Any, ::Any, ::Vararg{Any}; kwargs::Base.Pairs{Symbol, UInt128, Tuple{Symbol}, NamedTuple{(:seed,), Tuple{UInt128}}})
      @ Base ./essentials.jl:803
   [15] (::Distributed.var"#110#112"{Distributed.CallMsg{:call_fetch}})()
      @ Distributed /mnt/v/julia/usr/share/julia/stdlib/v1.9/Distributed/src/process_messages.jl:285
   [16] run_work_thunk(thunk::Distributed.var"#110#112"{Distributed.CallMsg{:call_fetch}}, print_error::Bool)
      @ Distributed /mnt/v/julia/usr/share/julia/stdlib/v1.9/Distributed/src/process_messages.jl:70
   [17] macro expansion
      @ /mnt/v/julia/usr/share/julia/stdlib/v1.9/Distributed/src/process_messages.jl:285 [inlined]
   [18] (::Distributed.var"#109#111"{Distributed.CallMsg{:call_fetch}, Distributed.MsgHeader, Sockets.TCPSocket})()
      @ Distributed ./task.jl:501
  in expression starting at /mnt/v/julia/test/compiler/codegen.jl:679

patch: add an if branch ccall(:jl_is_debugbuild, Cint, ()) != 0

ccall

run code with debug version:

# test/ccall.jl#L1097  (issue #15408)
begin
    ccall((:get_c_int, "libccalltest"), Cint, ())
    cglobal((:finalizer_cptr, "libccalltest"))
end

Expr not allowed in value position

long logs

errors:

Expr not allowed in value position
Internal error: encountered unexpected error in runtime:
ErrorException("")
error at ./error.jl:35
check_op at ./compiler/ssair/verify.jl:52
verify_ir at ./compiler/ssair/verify.jl:243
verify_ir at ./compiler/ssair/verify.jl:79 [inlined]
run_passes at ./compiler/optimize.jl:586
run_passes at ./compiler/optimize.jl:572 [inlined]
optimize at ./compiler/optimize.jl:521 [inlined]
_typeinf at ./compiler/typeinfer.jl:257
typeinf at ./compiler/typeinfer.jl:213
typeinf_ext_toplevel at ./compiler/typeinfer.jl:1080
typeinf_ext_toplevel at ./compiler/typeinfer.jl:1067
jfptr_typeinf_ext_toplevel_11762 at /home/a309/julia/usr/lib/julia/sys-debug.so (unknown line)
_jl_invoke at /home/a309/julia/src/gf.c:2374
ijl_apply_generic at /home/a309/julia/src/gf.c:2575
jl_apply at /home/a309/julia/src/julia.h:1848
jl_type_infer at /home/a309/julia/src/gf.c:317
jl_toplevel_eval_flex at /home/a309/julia/src/toplevel.c:901
jl_toplevel_eval_flex at /home/a309/julia/src/toplevel.c:856
ijl_toplevel_eval at /home/a309/julia/src/toplevel.c:921
ijl_toplevel_eval_in at /home/a309/julia/src/toplevel.c:971
eval at ./boot.jl:370 [inlined]
eval_user_input at /home/a309/julia/usr/share/julia/stdlib/v1.9/REPL/src/REPL.jl:152
repl_backend_loop at /home/a309/julia/usr/share/julia/stdlib/v1.9/REPL/src/REPL.jl:248
#start_repl_backend#46 at /home/a309/julia/usr/share/julia/stdlib/v1.9/REPL/src/REPL.jl:233
start_repl_backend##kw at /home/a309/julia/usr/share/julia/stdlib/v1.9/REPL/src/REPL.jl:230 [inlined]
#run_repl#59 at /home/a309/julia/usr/share/julia/stdlib/v1.9/REPL/src/REPL.jl:372
run_repl at /home/a309/julia/usr/share/julia/stdlib/v1.9/REPL/src/REPL.jl:357
jfptr_run_repl_56813 at /home/a309/julia/usr/lib/julia/sys-debug.so (unknown line)
_jl_invoke at /home/a309/julia/src/gf.c:2374
ijl_apply_generic at /home/a309/julia/src/gf.c:2575
#992 at ./client.jl:413
jfptr_YY.992_35853 at /home/a309/julia/usr/lib/julia/sys-debug.so (unknown line)
_jl_invoke at /home/a309/julia/src/gf.c:2374
ijl_apply_generic at /home/a309/julia/src/gf.c:2575
jl_apply at /home/a309/julia/src/julia.h:1848
jl_f__call_latest at /home/a309/julia/src/builtins.c:774
run_main_repl at ./client.jl:397
exec_options at ./client.jl:314
_start at ./client.jl:514
jfptr__start_24596 at /home/a309/julia/usr/lib/julia/sys-debug.so (unknown line)
_jl_invoke at /home/a309/julia/src/gf.c:2374
ijl_apply_generic at /home/a309/julia/src/gf.c:2575
jl_apply at /home/a309/julia/src/julia.h:1848
true_main at /home/a309/julia/src/jlapi.c:567
jl_repl_entrypoint at /home/a309/julia/src/jlapi.c:711
jl_load_repl at /home/a309/julia/cli/loader_lib.c:277
main at /home/a309/julia/cli/loader_exe.c:59
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
_start at ./julia (unknown line)
Ptr{Nothing} @0x00007f2b247af320

misc

using Test
GC.enable_finalizers(true)
GC.enable_finalizers(true)
GC.enable_finalizers(true)

# test/ccall.jl#L152
if ccall(:jl_is_debugbuild, Cint, ()) != 0
    # Note this warning only exists in debug builds
    @test_warn "WARNING: GC finalizers already enabled on this thread." GC.enable_finalizers(true)
end

Expected behavior: output warning

long logs

run: make -C test/ misc debug

errors:

Test Summary: |    Pass  Fail    Total   Time
  Overall     | 1282187     2  1282189  37.9s
    misc      | 1282187     2  1282189  36.8s
    FAILURE

The global RNG seed was 0xc9d0281197e2f261692aeb106a67b2b1.

Error in testset misc:
Test Failed at /home/a309/julia/usr/share/julia/stdlib/v1.9/Test/src/Test.jl:817
  Expression: contains_warn(read(fname, String), $(Expr(:escape, "WARNING: GC finalizers already enabled on this thread.")))
Error in testset misc:
Test Failed at /home/a309/julia/usr/share/julia/stdlib/v1.9/Test/src/Test.jl:817
  Expression: contains_warn(read(fname, String), $(Expr(:escape, "WARNING: GC finalizers already enabled on this thread.")))
ERROR: LoadError: Test run finished with errors
in expression starting at /home/a309/julia/test/runtests.jl:93
make: *** [Makefile:25: misc] Error 1
make: Leaving directory '/home/a309/julia/test'

julia/base/gcutils.jl

Lines 121 to 128 in 6008cbc

enable_finalizers(on::Bool) = on ? enable_finalizers() : disable_finalizers()
function enable_finalizers() @inline
ccall(:jl_gc_enable_finalizers_internal, Cvoid, ())
if Core.Intrinsics.atomic_pointerref(cglobal(:jl_gc_have_pending_finalizers, Cint), :monotonic) != 0
ccall(:jl_gc_run_pending_finalizers, Cvoid, (Ptr{Cvoid},), C_NULL)
end
end

julia/src/gc.c

Lines 445 to 467 in 6008cbc

JL_DLLEXPORT void jl_gc_enable_finalizers_internal(void)
{
jl_task_t *ct = jl_current_task;
#ifdef NDEBUG
ct->ptls->finalizers_inhibited--;
#else
jl_gc_enable_finalizers(ct, 1);
#endif
}
JL_DLLEXPORT void jl_gc_enable_finalizers(jl_task_t *ct, int on)
{
if (ct == NULL)
ct = jl_current_task;
jl_ptls_t ptls = ct->ptls;
int old_val = ptls->finalizers_inhibited;
int new_val = old_val + (on ? -1 : 1);
if (new_val < 0) {
JL_TRY {
jl_error(""); // get a backtrace
}
JL_CATCH {
jl_printf((JL_STREAM*)STDERR_FILENO, "WARNING: GC finalizers already enabled on this thread.\n");

InteractiveUtils

## InteractiveUtils/test/runtests.jl#L334
@eval @noinline @Base.constprop :none f_broken_code() = 0
let m = which(f_broken_code, ())
   let src = Base.uncompressed_ast(m)
       src.code = Any[
           Expr(:meta, :noinline)
           Core.ReturnNode(Expr(:invalid))
       ]
       m.source = src
   end
end
_true = true
# and show that we can still work around it
@noinline g_broken_code() = _true ? 0 : h_broken_code()
@noinline h_broken_code() = (g_broken_code(); f_broken_code())

# Expected to throw an Internal error 
f_broken_code()
julia> # will print some 
       f_broken_code()
WARNING: Encountered invalid lowered code for method f_broken_code(): Core.Compiler.InvalidCodeError(kind="invalid argument to return", meta=Expr(:invalid))
WARNING: Encountered invalid inferred code for method f_broken_code(): Core.Compiler.InvalidCodeError(kind="invalid argument to return", meta=Expr(:invalid))
Expr not allowed in value position
Internal error: encountered unexpected error in runtime:
ErrorException("")
error at ./error.jl:35
check_op at ./compiler/ssair/verify.jl:52
verify_ir at ./compiler/ssair/verify.jl:243
verify_ir at ./compiler/ssair/verify.jl:79 [inlined]
run_passes at ./compiler/optimize.jl:586
run_passes at ./compiler/optimize.jl:572 [inlined]
optimize at ./compiler/optimize.jl:521 [inlined]
_typeinf at ./compiler/typeinfer.jl:257
typeinf at ./compiler/typeinfer.jl:213

Expected behavior: throw an internal errors: "Internal error: encountered unexpected error during compilation of f_broken_code:"

I'm not quite sure if this is a bug
If it's not a bug, then just create a new branch for the test

looooooong logs

run: make -C test/ InteractiveUtils debug

errors:

Test Summary:      | Pass  Fail  Error  Total   Time
  Overall          |  297     1      2    300  40.1s
    InteractiveUtils |  297     1      2    300  38.6s
    FAILURE

The global RNG seed was 0x8defd7bf5bedea09d848aee3c885c3a1.

Error in testset InteractiveUtils:
Error During Test at /Users/woclass/Desktop/GitHub/julia/usr/share/julia/stdlib/v1.9/InteractiveUtils/test/runtests.jl:364
  Expression evaluated to non-Boolean
  Expression: startswith(errstr, "start\nend\nInternal error: encountered unexpected error during compilation of f_broken_code:\nErrorException(\"unsupported or misplaced expression \"invalid\" in function f_broken_code\")\n") || errstr
       Value: "start\nInternal error: encountered unexpected error in runtime:\nErrorException(\"\")\nerror at ./error.jl:35\ncheck_op at ./compiler/ssair/verify.jl:52\nverify_ir at ./compiler/ssair/verify.jl:243\nverify_ir at ./compiler/ssair/verify.jl:79 [inlined]\nrun_passes at ./compiler/optimize.jl:586\nrun_passes at ./compiler/optimize.jl:572 [inlined]\noptimize at ./compiler/optimize.jl:521 [inlined]\n_typeinf at ./compiler/typeinfer.jl:257\ntypeinf at ./compiler/typeinfer.jl:213\ntypeinf_edge at ./compiler/typeinfer.jl:914\nabstract_call_method at ./compiler/abstractinterpretation.jl:605\nabstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:166\nabstract_call_known at ./compiler/abstractinterpretation.jl:1769\nabstract_call at ./compiler/abstractinterpretation.jl:1838\nabstract_call at ./compiler/abstractinterpretation.jl:1817\nabstract_eval_statement at ./compiler/abstractinterpretation.jl:1959\nabstract_eval_basic_statement at ./compiler/abstractinterpretation.jl:2309\ntypeinf_local at ./compiler/abstractinterpretation.jl:2484\ntypeinf_nocycle at ./compiler/abstractinterpretation.jl:2582\n_typeinf at ./compiler/typeinfer.jl:230\ntypeinf at ./compiler/typeinfer.jl:213\ntypeinf_ext at ./compiler/typeinfer.jl:1038\ntypeinf_ext_toplevel at ./compiler/typeinfer.jl:1071\ntypeinf_ext_toplevel at ./compiler/typeinfer.jl:1067\njfptr_typeinf_ext_toplevel_11863 at /Users/woclass/Desktop/GitHub/julia/usr/lib/julia/sys-debug.dylib (unknown line)\n_jl_invoke at /Users/woclass/Desktop/GitHub/julia/src/gf.c:2374\nijl_apply_generic at /Users/woclass/Desktop/GitHub/julia/src/gf.c:2575\njl_apply at /Users/woclass/Desktop/GitHub/julia/src/./julia.h:1848\njl_type_infer at /Users/woclass/Desktop/GitHub/julia/src/gf.c:317\njl_get_llvmf_defn_impl at /Users/woclass/Desktop/GitHub/julia/src/aotcompile.cpp:1028\n_dump_function_linfo_native at /Users/woclass/Desktop/GitHub/julia/usr/share/julia/stdlib/v1.9/InteractiveUtils/src/codeview.jl:233\n_dump_function at /Users/woclass/Desktop/GitHub/julia/usr/share/julia/stdlib/v1.9/InteractiveUtils/src/codeview.jl:208\n_dump_function at /Users/woclass/Desktop/GitHub/julia/usr/share/julia/stdlib/v1.9/InteractiveUtils/src/codeview.jl:171 [inlined]\n#code_native#37 at /Users/woclass/Desktop/GitHub/julia/usr/share/julia/stdlib/v1.9/InteractiveUtils/src/codeview.jl:295 [inlined]\ncode_native at /Users/woclass/Desktop/GitHub/julia/usr/share/julia/stdlib/v1.9/InteractiveUtils/src/codeview.jl:293\njl_fptr_args at /Users/woclass/Desktop/GitHub/julia/src/gf.c:2154\n_jl_invoke at /Users/woclass/Desktop/GitHub/julia/src/gf.c:2374\nijl_apply_generic at /Users/woclass/Desktop/GitHub/julia/src/gf.c:2575\njl_apply at /Users/woclass/Desktop/GitHub/julia/src/./julia.h:1848\ndo_apply at /Users/woclass/Desktop/GitHub/julia/src/builtins.c:730\njl_f__apply_iterate at /Users/woclass/Desktop/GitHub/julia/src/builtins.c:738\n#sprint#470 at ./strings/io.jl:114\njl_fptr_args at /Users/woclass/Desktop/GitHub/julia/src/gf.c:2154\n_jl_invoke at /Users/woclass/Desktop/GitHub/julia/src/gf.c:2393\nijl_apply_generic at /Users/woclass/Desktop/GitHub/julia/src/gf.c:2575\njl_apply at /Users/woclass/Desktop/GitHub/julia/src/./julia.h:1848\ndo_apply at /Users/woclass/Desktop/GitHub/julia/src/builtins.c:730\njl_f__apply_iterate at /Users/woclass/Desktop/GitHub/julia/src/builtins.c:738\nsprint at ./strings/io.jl:107\njl_fptr_args at /Users/woclass/Desktop/GitHub/julia/src/gf.c:2154\n_jl_invoke at /Users/woclass/Desktop/GitHub/julia/src/gf.c:2393\nijl_apply_generic at /Users/woclass/Desktop/GitHub/julia/src/gf.c:2575\njl_apply at /Users/woclass/Desktop/GitHub/julia/src/./julia.h:1848\ndo_call at /Users/woclass/Desktop/GitHub/julia/src/interpreter.c:126\neval_value at /Users/woclass/Desktop/GitHub/julia/src/interpreter.c:215\neval_stmt_value at /Users/woclass/Desktop/GitHub/julia/src/interpreter.c:166\neval_body at /Users/woclass/Desktop/GitHub/julia/src/interpreter.c:594\neval_body at /Users/woclass/Desktop/GitHub/julia/src/interpreter.c:522\neval_body at /Users/woclass/Desktop/GitHub/julia/src/interpreter.c:522\njl_interpret_toplevel_thunk at /Users/woclass/Desktop/GitHub/julia/src/interpreter.c:750\nmacro expansion at /Users/woclass/Desktop/GitHub/julia/usr/share/julia/stdlib/v1.9/Test/src/Test.jl:466\njl_toplevel_eval_flex at /Users/woclass/Desktop/GitHub/julia/src/toplevel.c:912\njl_toplevel_eval_flex at /Users/woclass/Desktop/GitHub/julia/src/toplevel.c:856\nijl_toplevel_eval at /Users/woclass/Desktop/GitHub/julia/src/toplevel.c:921\nijl_toplevel_eval_in at /Users/woclass/Desktop/GitHub/julia/src/toplevel.c:971\neval at ./boot.jl:370 [inlined]\ninclude_string at ./loading.jl:1488\njl_fptr_args at /Users/woclass/Desktop/GitHub/julia/src/gf.c:2154\n_jl_invoke at /Users/woclass/Desktop/GitHub/julia/src/gf.c:2374\nijl_apply_generic at /Users/woclass/Desktop/GitHub/julia/src/gf.c:2575\n_include at ./loading.jl:1548\ninclude at ./Base.jl:424 [inlined]\nmacro expansion at /Users/woclass/Desktop/GitHub/julia/test/testdefs.jl:24 [inlined]\nmacro expansion at /Users/woclass/Desktop/GitHub/julia/usr/share/julia/stdlib/v1.9/Test/src/Test.jl:1388 [inlined]\nmacro expansion at /Users/woclass/Desktop/GitHub/julia/test/testdefs.jl:23 [inlined]\nmacro expansion at ./timing.jl:473 [inlined]\n#runtests#59 at /Users/woclass/Desktop/GitHub/julia/test/testdefs.jl:21\nruntests##kw at /Users/woclass/Desktop/GitHub/julia/test/testdefs.jl:5 [inlined]\nruntests##kw at /Users/woclass/Desktop/GitHub/julia/test/testdefs.jl:5\nunknown function (ip: 0x13fd6e69d)\n_jl_invoke at /Users/woclass/Desktop/GitHub/julia/src/gf.c:2393\nijl_apply_generic at /Users/woclass/Desktop/GitHub/julia/src/gf.c:2575\njl_apply at /Users/woclass/Desktop/GitHub/julia/src/./julia.h:1848\njl_f__call_latest at /Users/woclass/Desktop/GitHub/julia/src/builtins.c:774\n#invokelatest#2 at ./essentials.jl:803 [inlined]\ninvokelatest##kw at ./essentials.jl:798 [inlined]\n#153 at /Users/woclass/Desktop/GitHub/julia/usr/share/julia/stdlib/v1.9/Distributed/src/remotecall.jl:425 [inlined]\nrun_work_thunk at /Users/woclass/Desktop/GitHub/julia/usr/share/julia/stdlib/v1.9/Distributed/src/process_messages.jl:70\nunknown function (ip: 0x13fd68fa9)\n_jl_invoke at /Users/woclass/Desktop/GitHub/julia/src/gf.c:2393\nijl_apply_generic at /Users/woclass/Desktop/GitHub/julia/src/gf.c:2575\n#remotecall_fetch#158 at /Users/woclass/Desktop/GitHub/julia/usr/share/julia/stdlib/v1.9/Distributed/src/remotecall.jl:450\njl_fptr_args at /Users/woclass/Desktop/GitHub/julia/src/gf.c:2154\n_jl_invoke at /Users/woclass/Desktop/GitHub/julia/src/gf.c:2393\nijl_apply_generic at /Users/woclass/Desktop/GitHub/julia/src/gf.c:2575\njl_apply at /Users/woclass/Desktop/GitHub/julia/src/./julia.h:1848\ndo_apply at /Users/woclass/Desktop/GitHub/julia/src/builtins.c:730\njl_f__apply_iterate at /Users/woclass/Desktop/GitHub/julia/src/builtins.c:738\nremotecall_fetch##kw at /Users/woclass/Desktop/GitHub/julia/usr/share/julia/stdlib/v1.9/Distributed/src/remotecall.jl:449\njl_fptr_args at /Users/woclass/Desktop/GitHub/julia/src/gf.c:2154\n_jl_invoke at /Users/woclass/Desktop/GitHub/julia/src/gf.c:2393\nijl_apply_generic at /Users/woclass/Desktop/GitHub/julia/src/gf.c:2575\njl_apply at /Users/woclass/Desktop/GitHub/julia/src/./julia.h:1848\ndo_apply at /Users/woclass/Desktop/GitHub/julia/src/builtins.c:730\njl_f__apply_iterate at /Users/woclass/Desktop/GitHub/julia/src/builtins.c:738\n#remotecall_fetch#162 at /Users/woclass/Desktop/GitHub/julia/usr/share/julia/stdlib/v1.9/Distributed/src/remotecall.jl:492\njl_fptr_args at /Users/woclass/Desktop/GitHub/julia/src/gf.c:2154\n_jl_invoke at /Users/woclass/Desktop/GitHub/julia/src/gf.c:2393\nijl_apply_generic at /Users/woclass/Desktop/GitHub/julia/src/gf.c:2575\njl_apply at /Users/woclass/Desktop/GitHub/julia/src/./julia.h:1848\ndo_apply at /Users/woclass/Desktop/GitHub/julia/src/builtins.c:730\njl_f__apply_iterate at /Users/woclass/Desktop/GitHub/julia/src/builtins.c:738\nremotecall_fetch##kw at /Users/woclass/Desktop/GitHub/julia/usr/share/julia/stdlib/v1.9/Distributed/src/remotecall.jl:492\njl_fptr_args at /Users/woclass/Desktop/GitHub/julia/src/gf.c:2154\n_jl_invoke at /Users/woclass/Desktop/GitHub/julia/src/gf.c:2393\nijl_apply_generic at /Users/woclass/Desktop/GitHub/julia/src/gf.c:2575\nmacro expansion at /Users/woclass/Desktop/GitHub/julia/test/runtests.jl:260 [inlined]\n#45 at ./task.jl:501\nunknown function (ip: 0x13fd67f7f)\n_jl_invoke at /Users/woclass/Desktop/GitHub/julia/src/gf.c:2393\nijl_apply_generic at /Users/woclass/Desktop/GitHub/julia/src/gf.c:2575\njl_apply at /Users/woclass/Desktop/GitHub/julia/src/./julia.h:1848\nstart_task at /Users/woclass/Desktop/GitHub/julia/src/task.c:931\nWARNING: Encountered invalid lowered code for method f_broken_code(): Core.Compiler.InvalidCodeError(kind=\"invalid argument to return\", meta=Expr(:invalid))\nWARNING: Encountered invalid inferred code for method f_broken_code(): Core.Compiler.InvalidCodeError(kind=\"invalid argument to return\", meta=Expr(:invalid))\nExpr not allowed in value position\nend\n"
Error in testset InteractiveUtils:
Error During Test at /Users/woclass/Desktop/GitHub/julia/usr/share/julia/stdlib/v1.9/InteractiveUtils/test/runtests.jl:369
  Expression evaluated to non-Boolean
  Expression: !(endswith(errstr, "\nend\n")) || errstr

@test startswith(errstr, """start
end
Internal error: encountered unexpected error during compilation of f_broken_code:
ErrorException(\"unsupported or misplaced expression \"invalid\" in function f_broken_code\")
""") || errstr
@test !endswith(errstr, "\nend\n") || errstr

@inkydragon inkydragon added the test This change adds or pertains to unit tests label Jul 16, 2022
@inkydragon
Copy link
Sponsor Member Author

Another interesting question: Do we need to define an isdebugbuild function?

A search shows ccall(:jl_is_debugbuild, Cint, ()) ! = 0 was copied more than a dozen times
https://github.com/JuliaLang/julia/search?q=%3Ajl_is_debugbuild

@timholy
Copy link
Sponsor Member

timholy commented Jul 22, 2022

You can hit the InteractiveUtils bug (and same error in the ccall example) with MRIgeneralizedBloch (and maybe others, it would be nice to find a smaller dependency):

activate --temp
add MRIgeneralizedBloch
precompile   # you'll see the error once during precompile
using MRIgeneralizedBloch    # you'll see it here too

@timholy
Copy link
Sponsor Member

timholy commented Jul 23, 2022

Here's something that's a bit more M(medium)WE; @inkydragon's example above is even better, but this at least shows that the issue occurs outside of test suites:

pkg> dev LLVMExtra_jll
shell> cd ~/.julia/dev/LLVMExtra_jll/.pkg
julia> include("select_artifacts.jl")

@timholy
Copy link
Sponsor Member

timholy commented Jul 23, 2022

For the ccall case, the frame that triggers the error seems to be (see #46147 for the debug diff)

julia> Core.Compiler.junk[1]
Core.Compiler.InferenceState(Toplevel MethodInstance thunk from Main starting at REPL[1]:2, 0x00000000000077ce, Main, Any[], Any[], CodeInfo(
    @ REPL[1]:2 within `top-level scope`
1$(Expr(:foreigncall, :(Core.tuple(:get_c_int, "libccalltest")), Int32, svec(), 0, :(:ccall)))::Int32
│   @ REPL[1]:3 within `top-level scope`%2 = Main.cglobal(Core.tuple(:finalizer_cptr, "libccalltest"))::Ptr{Nothing}
└──      return %2
), 1	=>	
, -1, 3, Core.Compiler.BitSet(UInt64[0x0000000000000000], 0), [0, 0, 0], Core.Compiler.BitSet[Core.Compiler.BitSet(UInt64[], -1152921504606846976), Core.Compiler.BitSet(UInt64[0x0000000000000008], 0), Core.Compiler.BitSet(UInt64[], -1152921504606846976)], Union{Nothing, Vector{Core.Compiler.VarState}}[Core.Compiler.VarState[]], Any[Int32, Ptr{Nothing}, Any], Union{Nothing, Vector{Any}}[Any[], nothing, nothing], Any[nothing, false, nothing], Core.Compiler.IdSet{Core.Compiler.InferenceState}(Core.Compiler.IdDict{Core.Compiler.InferenceState, Nothing}(Any[#undef, #undef, #undef, #undef, #undef, #undef, #undef, #undef, #undef, #undef  …  #undef, #undef, #undef, #undef, #undef, #undef, #undef, #undef, #undef, #undef], 0, 0)), Core.Compiler.IdSet{Core.Compiler.InferenceState}(Core.Compiler.IdDict{Core.Compiler.InferenceState, Nothing}(Any[#undef, #undef, #undef, #undef, #undef, #undef, #undef, #undef, #undef, #undef  …  #undef, #undef, #undef, #undef, #undef, #undef, #undef, #undef, #undef, #undef], 0, 0)), Tuple{Core.Compiler.InferenceState, Int64}[], Core.Compiler.InferenceState[], true, nothing, true, Error showing value of type Core.Compiler.InferenceState:
ERROR: UndefVarError: name not defined
...

(yes, display of the frame failed).

For the InteractiveUtils version, it's

julia> Core.Compiler.junk[1]
Core.Compiler.InferenceState(MethodInstance for f_broken_code(), 0x00000000000077d1, Main, Any[], Any[Core.Const(f_broken_code)], CodeInfo(
1$(Expr(:meta, :noinline))
│   @ REPL[1]:1 within `f_broken_code`
└──     return $(Expr(:invalid))
), 1	=>	
, -1, 2, Core.Compiler.BitSet(UInt64[0x0000000000000000], 0), [0, 0], Core.Compiler.BitSet[Core.Compiler.BitSet(UInt64[], -1152921504606846976), Core.Compiler.BitSet(UInt64[], -1152921504606846976)], Union{Nothing, Vector{Core.Compiler.VarState}}[Core.Compiler.VarState[Core.Compiler.VarState(Core.Const(f_broken_code), false)]], Any[Nothing, Any], Union{Nothing, Vector{Any}}[Any[], nothing], Any[nothing, nothing], Core.Compiler.IdSet{Core.Compiler.InferenceState}(Core.Compiler.IdDict{Core.Compiler.InferenceState, Nothing}(Any[#undef, #undef, #undef, #undef, #undef, #undef, #undef, #undef, #undef, #undef  …  #undef, #undef, #undef, #undef, #undef, #undef, #undef, #undef, #undef, #undef], 0, 0)), Core.Compiler.IdSet{Core.Compiler.InferenceState}(Core.Compiler.IdDict{Core.Compiler.InferenceState, Nothing}(Any[#undef, #undef, #undef, #undef, #undef, #undef, #undef, #undef, #undef, #undef  …  #undef, #undef, #undef, #undef, #undef, #undef, #undef, #undef, #undef, #undef], 0, 0)), Tuple{Core.Compiler.InferenceState, Int64}[], Core.Compiler.InferenceState[], true, nothing, true, f_broken_code() => Any, Core.Compiler.WorldRange(0x0000000000000001, 0x00000000000077d1), Any, (+c,+e,+n,+t,+s), Core.Compiler.InferenceParams(true, false, true, 3, 4, 8, 3, 32), false, true, Core.Compiler.NativeInterpreter(...))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test This change adds or pertains to unit tests
Projects
None yet
Development

No branches or pull requests

2 participants