JuliaLang / julia

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

Access violation in uv__udp_check_before_send #43525

Open Mrbigmatt opened 2 years ago

Mrbigmatt commented 2 years ago

While I don't think this is how I should be using the sockets, I don't think Julia should crash when the following code is put into a package and executed:

module TestSockets

using Sockets

sock = UDPSocket()

function crash()
    global sock

    send(sock::UDPSocket, ip"127.0.0.1", 12345, "test")
end

end # module

This is the output:

julia> using TestSockets

julia> TestSockets.crash()

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 0x1f4e5e6 -- uv__udp_check_before_send at /workspace/srcdir/libuv\src\uv-common.c:408
in expression starting at REPL[8]:1
uv__udp_check_before_send at /workspace/srcdir/libuv\src\uv-common.c:408
uv_udp_send at /workspace/srcdir/libuv\src\uv-common.c:444
jl_udp_send at /cygdrive/c/buildbot/worker/package_win64/build/src\jl_uv.c:739
_send_async at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Sockets\src\Sockets.jl:423
send at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Sockets\src\Sockets.jl:445
crash at C:\Projects\TestSockets\src\TestSockets.jl:10
unknown function (ip: 000000005fd6b6a3)
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1703 [inlined]
do_call at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:115
eval_value at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:204
eval_stmt_value at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:155 [inlined]
eval_body at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:576
jl_interpret_toplevel_thunk at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:670
jl_toplevel_eval_flex at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:877    
jl_toplevel_eval_flex at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:825    
jl_toplevel_eval at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:886 [inlined]
jl_toplevel_eval_in at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:929      
eval at .\boot.jl:360 [inlined]
eval_user_input at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\REPL\src\REPL.jl:139
repl_backend_loop at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\REPL\src\REPL.jl:200
start_repl_backend at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\REPL\src\REPL.jl:185
#run_repl#42 at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\REPL\src\REPL.jl:317
run_repl at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\REPL\src\REPL.jl:305
#874 at .\client.jl:387
jfptr_YY.874_32664.clone_1 at C:\Users\%username%\AppData\Local\Programs\Julia-1.6.2\lib\julia\sys.dll (unknown line)
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1703 [inlined]
jl_f__call_latest at /cygdrive/c/buildbot/worker/package_win64/build/src\builtins.c:714        
#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_39745.clone_1 at C:\Users\%username%\AppData\Local\Programs\Julia-1.6.2\lib\julia\sys.dll (unknown line)
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1703 [inlined]
true_main at /cygdrive/c/buildbot/worker/package_win64/build/src\jlapi.c:560
repl_entrypoint at /cygdrive/c/buildbot/worker/package_win64/build/src\jlapi.c:702
mainCRTStartup at /cygdrive/c/buildbot/worker/package_win64/build/cli\loader_exe.c:51
BaseThreadInitThunk at C:\windows\System32\KERNEL32.DLL (unknown line)
RtlUserThreadStart at C:\windows\SYSTEM32\ntdll.dll (unknown line)
Allocations: 1463346 (Pool: 1462705; Big: 641); GC: 2

This is the version info:

julia> versioninfo()
Julia Version 1.6.2
Commit 1b93d53fc4 (2021-07-14 15:36 UTC)        
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i5-10210U CPU @ 1.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, skylake)
Environment:
  JULIA_NUM_THREADS = 8

I've also seen this behavior with Julia 1.7.0 running on Ubuntu 18.04

Mrbigmatt commented 2 years ago

This might be a bigger issue with globals being initialized outside of functions within a module. I've run into other crashes happening with this situation but there's much less helpful information:

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 0x0 -- unknown function (ip: 0000000000000000) in expression starting at <code that tries to initialize a global outside of a function within a module>