JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.88k stars 5.49k forks source link

Crash in Base.iolock_end() #43556

Open goerch opened 2 years ago

goerch commented 2 years ago
C:\Users\Win10\AppData\Local\Programs\Julia-1.8.0-DEV\bin\julia.exe -t5
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.8.0-DEV.1176 (2021-12-24)
 _/ |\__'_|_|_|\__'_|  |  Commit 00646634c6 (2 days old master)
|__/                   |

julia> Base.iolock_end()

yields

Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
Exception: EXCEPTION_ACCESS_VIOLATION at 0x65404ddb -- ijl_eh_restore_state at /cygdrive/c/buildbot/worker/package_win64/build/src\rtutils.c:272
in expression starting at REPL[1]:1
ijl_eh_restore_state at /cygdrive/c/buildbot/worker/package_win64/build/src\rtutils.c:272
ijl_toplevel_eval_in at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:946
eval at .\boot.jl:368 [inlined]
eval_user_input at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.8\REPL\src\REPL.jl:151
repl_backend_loop at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.8\REPL\src\REPL.jl:245
start_repl_backend at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.8\REPL\src\REPL.jl:230
#run_repl#47 at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.8\REPL\src\REPL.jl:367
run_repl at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.8\REPL\src\REPL.jl:354
jfptr_run_repl_56925.clone_1 at C:\Users\Win10\AppData\Local\Programs\Julia-1.8.0-DEV\lib\julia\sys.dll (unknown line)
#934 at .\client.jl:403
jfptr_YY.934_47942.clone_1 at C:\Users\Win10\AppData\Local\Programs\Julia-1.8.0-DEV\lib\julia\sys.dll (unknown line)
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1789 [inlined]
jl_f__call_latest at /cygdrive/c/buildbot/worker/package_win64/build/src\builtins.c:757
#invokelatest#2 at .\essentials.jl:731 [inlined]
invokelatest at .\essentials.jl:729 [inlined]
run_main_repl at .\client.jl:388
exec_options at .\client.jl:318
_start at .\client.jl:506
jfptr__start_37216.clone_1 at C:\Users\Win10\AppData\Local\Programs\Julia-1.8.0-DEV\lib\julia\sys.dll (unknown line)
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1789 [inlined]
true_main at /cygdrive/c/buildbot/worker/package_win64/build/src\jlapi.c:562
jl_repl_entrypoint at /cygdrive/c/buildbot/worker/package_win64/build/src\jlapi.c:706
mainCRTStartup at /cygdrive/c/buildbot/worker/package_win64/build/cli\loader_exe.c:59
BaseThreadInitThunk at C:\Windows\System32\KERNEL32.DLL (unknown line)
RtlUserThreadStart at C:\Windows\SYSTEM32\ntdll.dll (unknown line)
Allocations: 2746 (Pool: 2736; Big: 10); GC: 0

Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
Exception: EXCEPTION_ACCESS_VIOLATION at 0x7ffd651445c3 -- memcpy at C:\Windows\System32\msvcrt.dll (unknown line)
in expression starting at REPL[1]:1
memcpy at C:\Windows\System32\msvcrt.dll (unknown line)
small_arraylist_grow at /cygdrive/c/buildbot/worker/package_win64/build/src/support\arraylist.c:115
jl_lock_frame_push at /cygdrive/c/buildbot/worker/package_win64/build/src\julia_locks.h:57 [inlined]
jl_mutex_lock at /cygdrive/c/buildbot/worker/package_win64/build/src\julia_locks.h:86 [inlined]
jl_get_binding_ at /cygdrive/c/buildbot/worker/package_win64/build/src\module.c:346
ijl_get_binding at /cygdrive/c/buildbot/worker/package_win64/build/src\module.c:381 [inlined]
ijl_get_global at /cygdrive/c/buildbot/worker/package_win64/build/src\module.c:648
ijl_atexit_hook at /cygdrive/c/buildbot/worker/package_win64/build/src\init.c:214
ijl_exit at /cygdrive/c/buildbot/worker/package_win64/build/src\jl_uv.c:636
jl_exception_handler at /cygdrive/c/buildbot/worker/package_win64/build/src\signals-win.c:322
__julia_personality at /cygdrive/c/buildbot/worker/package_win64/build/src\win32_ucontext.c:28
_chkstk at C:\Windows\SYSTEM32\ntdll.dll (unknown line)
RtlRaiseException at C:\Windows\SYSTEM32\ntdll.dll (unknown line)
KiUserExceptionDispatcher at C:\Windows\SYSTEM32\ntdll.dll (unknown line)
ijl_eh_restore_state at /cygdrive/c/buildbot/worker/package_win64/build/src\rtutils.c:272
ijl_toplevel_eval_in at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:946
eval at .\boot.jl:368 [inlined]
eval_user_input at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.8\REPL\src\REPL.jl:151
repl_backend_loop at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.8\REPL\src\REPL.jl:245
start_repl_backend at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.8\REPL\src\REPL.jl:230
#run_repl#47 at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.8\REPL\src\REPL.jl:367
run_repl at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.8\REPL\src\REPL.jl:354
jfptr_run_repl_56925.clone_1 at C:\Users\Win10\AppData\Local\Programs\Julia-1.8.0-DEV\lib\julia\sys.dll (unknown line)
#934 at .\client.jl:403
jfptr_YY.934_47942.clone_1 at C:\Users\Win10\AppData\Local\Programs\Julia-1.8.0-DEV\lib\julia\sys.dll (unknown line)
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1789 [inlined]
jl_f__call_latest at /cygdrive/c/buildbot/worker/package_win64/build/src\builtins.c:757
#invokelatest#2 at .\essentials.jl:731 [inlined]
invokelatest at .\essentials.jl:729 [inlined]
run_main_repl at .\client.jl:388
exec_options at .\client.jl:318
_start at .\client.jl:506
jfptr__start_37216.clone_1 at C:\Users\Win10\AppData\Local\Programs\Julia-1.8.0-DEV\lib\julia\sys.dll (unknown line)
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1789 [inlined]
true_main at /cygdrive/c/buildbot/worker/package_win64/build/src\jlapi.c:562
jl_repl_entrypoint at /cygdrive/c/buildbot/worker/package_win64/build/src\jlapi.c:706
mainCRTStartup at /cygdrive/c/buildbot/worker/package_win64/build/cli\loader_exe.c:59
BaseThreadInitThunk at C:\Windows\System32\KERNEL32.DLL (unknown line)
RtlUserThreadStart at C:\Windows\SYSTEM32\ntdll.dll (unknown line)
Allocations: 2746 (Pool: 2736; Big: 10); GC: 0
jakobnissen commented 2 years ago

Generally, calling un-exported, un-documented Base functions is not guaranteed to be safe, so I don't think this is an issue.

goerch commented 2 years ago

Point taken, but if you are writing an IR interpreter there is no obvious way around it.

JeffBezanson commented 2 years ago

It looks like iolock_end is somehow getting called in a different task than iolock_begin? How is that happening? We can't make that "just work". You will need to make sure the interpreter doesn't introduce new task boundaries in order to run on our task runtime.

vtjnash commented 2 years ago

We also generally prohibit switching tasks while holding an internal lock (i.e. iolock), since it breaks the assumption that the lock calls are properly nested, and that it won't accidentally try to interleave with, e.g., running the scheduler itself.