JuliaLang / julia

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

Provide an error message if LD_PRELOAD is set during a Julia build or startup #55487

Open wsmoses opened 2 months ago

wsmoses commented 2 months ago

This was a build of release-1.10.

[119298] signal (6.-6): Aborted
in expression starting at /home/wmoses/julia/usr/share/julia/stdlib/v1.10/Downloads/src/Downloads.jl:469
gsignal at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
abort at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x7fed8bd1b26d)
unknown function (ip: 0x7fed8bd232fb)
unknown function (ip: 0x7fed8bd24f9f)
Curl_parsenetrc at /home/wmoses/julia/usr/bin/../lib/libcurl.so.4 (unknown line)
Curl_connect at /home/wmoses/julia/usr/bin/../lib/libcurl.so.4 (unknown line)
multi_runsingle at /home/wmoses/julia/usr/bin/../lib/libcurl.so.4 (unknown line)
multi_socket at /home/wmoses/julia/usr/bin/../lib/libcurl.so.4 (unknown line)
curl_multi_socket_action at /home/wmoses/julia/usr/bin/../lib/libcurl.so.4 (unknown line)
curl_multi_socket_action at /home/wmoses/julia/usr/share/julia/stdlib/v1.10/Downloads/src/Curl/Curl.jl:51 [inlined]
curl_multi_socket_action at /home/wmoses/julia/usr/share/julia/stdlib/v1.10/Downloads/src/Curl/Curl.jl:59 [inlined]
macro expansion at /home/wmoses/julia/usr/share/julia/stdlib/v1.10/Downloads/src/Curl/utils.jl:56 [inlined]
do_multi at /home/wmoses/julia/usr/share/julia/stdlib/v1.10/Downloads/src/Curl/Multi.jl:129
#48 at /home/wmoses/julia/usr/share/julia/stdlib/v1.10/Downloads/src/Curl/Multi.jl:147 [inlined]
lock at ./lock.jl:229
#47 at /home/wmoses/julia/usr/share/julia/stdlib/v1.10/Downloads/src/Curl/Multi.jl:144 [inlined]
#726 at ./asyncevent.jl:306
unknown function (ip: 0x7fed7181c392)
_jl_invoke at /home/wmoses/julia/src/gf.c:2895 [inlined]
ijl_apply_generic at /home/wmoses/julia/src/gf.c:3077
jl_apply at /home/wmoses/julia/src/julia.h:1982 [inlined]
start_task at /home/wmoses/julia/src/task.c:1238
Allocations: 77961049 (Pool: 77879838; Big: 81211); GC: 96
Aborted (core dumped)
*** This error might be fixed by running `make clean`. If the error persists, try `make cleanall`. ***
make[1]: *** [sysimage.mk:67: /home/wmoses/julia/usr/lib/julia/sys.ji] Error 1
make: *** [Makefile:101: julia-sysimg-ji] Error 2

The same error occurs on my system using juliaup binaries for 1.10, 1.9, and 1.11-rc2

giordano commented 2 months ago

Can you please provide more information about the system? CPU, operating system, etc... What are make options? Just default configuration?

The same error occurs on my system using juliaup binaries for 1.10, 1.9, and 1.11-rc2

Just to understand, how do you reproduce the same error when you're using prebuilt binaries?

ViralBShah commented 2 months ago

Is there an LD_LIBRARY_PATH or LD_PRELOAD by any chance that is loading something else?

wsmoses commented 2 months ago

yeah I think its an ld_preload setting the allocator to libtcmalloc

giordano commented 2 months ago

For future reference, this is probably related to #44242 and #48461 (which was also worked around by unsetting LD_PRELOAD)

ViralBShah commented 2 months ago

Please reopen if still an issue. We may want to check the existence of LD_PRELOAD and LD_LIBRARY_PATH in our build to warn users.

moble commented 1 month ago

@ViralBShah I think this is very much still an issue. One of my users ran into this problem (with jemalloc, on a cluster I couldn't access), and it took us forever to diagnose. Some sort of warning would have saved us a lot of time.

Unfortunately for this user, just unsetting LD_PRELOAD isn't an option, because he needs to call Julia from another program that does actually need jemalloc. But knowing that earlier would have been very helpful. I'm hoping that building Julia from scratch lets him avoid the problem. 🤞

ViralBShah commented 1 month ago

I am not sure how far you'll get with jemalloc even with a source build: https://github.com/JuliaLang/julia/issues/46298

But reopening this issue to have a warning if LD_PRELOAD is set at build or run time.

giordano commented 1 month ago

Note that LD_PRELOAD can also be used "safely", for example for profiling, and MPI.jl explicitly supports that: https://github.com/JuliaParallel/MPI.jl/pull/451. So I'm a bit wary of adding a warning.

ViralBShah commented 1 month ago

I was thinking that the message would say something along the lines of: "LD_PRELOAD has been set to $val. If you experience problems with your build or at runtime, please review".

maleadt commented 1 month ago

Also note that LD_PRELOAD is already shown by the Environment: section in versioninfo(), so there's some visibility already: https://github.com/JuliaLang/julia/blob/c6c449ccdb75fbd72700704ae669e1f98e512206/stdlib/InteractiveUtils/src/InteractiveUtils.jl#L171-L173

ufechner7 commented 1 month ago

But that does not help if Julia doesn't start at all.

giordano commented 1 month ago

If Julia doesn't start at all it probably doesn't have any chance to print anything because it dies too early.

oscardssmith commented 1 month ago

Can we not intercept the signal handler to print a brief something on the C level?

IanButterworth commented 1 month ago

If there isn't a good option in julia perhaps juliaup could warn?

moble commented 1 month ago

But that does not help if Julia doesn't start at all.

Fair enough, but evidently for several cases, Julia does start just fine. In the example I ran into, the error only occurred after Pkg had been loaded and started trying to curl something.