Seg fault when using julia (pakcage installation, profiling)

Hello,

I’m new to Julia so I don’t know if seg faults are a classic thing but anyway, I have one and I don’t know why.

I installed Julia using Juliaup

I’m on linux, so I just ran the command

curl -fsSL https://install.julialang.org | sh

While trying to understand somethings, I wanted to run the following code, which is a simple profiling code :

using Profile

function myfunc()
    A = rand(200, 200, 400)
    max_val = maximum(A)
    return max_val
end

println("function def ok") 

# First run to compile first 
myfunc()

println("first run ok") 

Profile.clear()

println("Profile clear ok") 

@profile for i in 1:5
    myfunc()
end

println("profiling ok") 

Profile.print()

When I tried to execute the code, by doing “julia code.jl” I got a seg fault.

Here’s the exact output :

function def ok
first run ok
Profile clear ok
Segmentation fault (core dumped)

As you can see, the execution reached the point where the profiling starts.

So I wanted to try another method for profiling and found a package called BenchmarkTools. When installing the package I also got a seg fault :

julia> import Pkg; Pkg.add("BenchmarkTools")
  Installing known registries into `~/.julia`
Segmentation fault (core dumped)

Even simple commands such as “pkg> st --manifest” give a seg fault :

(@v1.12) pkg> st --manifest
  Installing known registries into `~/.julia`
Segmentation fault (core dumped)

I’m using Julia version 1.12.1 (2025-10-17), installed using Juliaup
I’m on Ubuntu 24.04.2 LTS

Please tell me if you need more info, and thanks in advance for any help.

Your code can be run without any error on my linux machine. And I also installed julia via juliaup (the recommended way of installing).

Segfaults are not usual for me when writing daily code.

There is nothing normal about this.

It seems to me like a common factor for your segmentation faults are attempts to write files, possibly to /tmp. Can you successfully perform

julia> write("/tmp/test.txt", "test")

and

julia> write(expanduser("~/.julia/test.txt"), "test")

?

Hi,

Thanks for the replay.

When I executed the commands that you gave me, I got ‘4’ for each, which means the commands that you gave me worked 'since write function returns the number of bytes that have been written :

julia> write("/tmp/test.txt", "test")
4

julia> write(expanduser("~/.julia/test.txt"), "test")
4

Like you said, there’s nothing normal about this.

A colleague of mine suggested that it might be related to the C libraries that I have in my machine and the possibility that they are not compatible with what julia uses but everything else that I use that uses the C libs works fine so I don’t know.

Yes, that disproves my hypothesis. I also rather doubt that C libs should have anything to do with it. Ubuntu 24.04 is a very common platform to run Julia on.

You could try to run Julia in a debugger or with strace and see if that provides any hints.

Perhaps that is a hardware issue, either with your RAM or with your HD drive?

I’m not sure how to debug that, though. Are you overclocking your PC?

Can you run versioninfo(true) in Julia and send the result

No, l’m not overclocking the cpu.

It should be noted that the seg fault doesn’t happen with everything, so far it happened when trying to install any package and when running code that profiles a function, not always though.

Ok, thanks for the advice.

I’ll use a debugger and keep you updated.

So I ran the exact code that you gave but got an error saying that the method versioninfo doesn’t take any arguments. So I ran the method without ‘true’, here are the outputs (for the method with and without true) :

julia> versioninfo(true)
ERROR: MethodError: no method matching versioninfo(::Bool)
The function `versioninfo` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  versioninfo(; ...)
   @ InteractiveUtils ~/.julia/juliaup/julia-1.12.1+0.x64.linux.gnu/share/julia/stdlib/v1.12/InteractiveUtils/src/InteractiveUtils.jl:103
  versioninfo(::IO; verbose)
   @ InteractiveUtils ~/.julia/juliaup/julia-1.12.1+0.x64.linux.gnu/share/julia/stdlib/v1.12/InteractiveUtils/src/InteractiveUtils.jl:103

Stacktrace:
 [1] top-level scope
   @ REPL[1]:1

julia> versioninfo()
Julia Version 1.12.1
Commit ba1e628ee49 (2025-10-17 13:02 UTC)
Build Info:
  Official https://julialang.org release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 20 × Intel(R) Core(TM) i5-14500
  WORD_SIZE: 64
  LLVM: libLLVM-18.1.7 (ORCJIT, alderlake)
  GC: Built with stock GC
Threads: 1 default, 1 interactive, 1 GC (on 20 virtual cores)
Environment:
  LD_LIBRARY_PATH = /usr/lib/x86_64-linux-gnu/:/usr/lib/i386-linux-gnu/:/usr/lib/:/usr/local/lib/

I just had the same problem: trying to install a new package yields a segmentation fault. In my case, it is because julia was installed in /opt folder, for which you need sudo permissions to write. Installing the package after doing sudo julia was successful. Maybe this has nothing to do with your problem, but just in case…

There is your problem. Get rid of that environment variable.

1 Like

That works for me.

However, what can we do instead if we need to set LD_LIBRARY_PATH in order to call external libraries?

Wow, that worked.

Thank you very much.

Although, I would like to understand why that environment variable caused the seg faults ?

Also, I want to add I did some tests before solving the issue and found that Julia works when used with the flag --compile=no or --compile=min, but it becomes so slow obviously.

1 Like

In my case, I need the LD_LIBRARY_PATH for an application called Libero SoC.

The variable LD_LIBRARY_PATH used to be in bashrc but I removed it so I can run julia.
Now every time I need to run Libero, I just do an export of LD_LIBRARY_PATH with the value that I need, this works and it doesn’t affect julia.

1 Like

Because the wrong versions of some libraries that Julia needs are loaded. Same library name, but from a different directory.

Could be any of these libraries, that are shipped with Julia:

ufechner@framework:~/.julia/juliaup/julia-1.12.1+0.x64.linux.gnu/lib/julia$ ls
libamd.so                    libcurl.so                   libldl.so.3               libssh2.so
libamd.so.3                  libcurl.so.4                 libldl.so.3.3.2           libssh2.so.1
libamd.so.3.3.3              libcurl.so.4.8.0             libLLVM-18jl.so           libssh2.so.1.0.1
libatomic.so                 libdSFMT.so                  libllvmcalltest.so        libssl.so
libatomic.so.1               libgcc_s.so.1                libLLVM.so                libssl.so.3
libatomic.so.1.2.0           libgfortran.so               libLLVM.so.18.1jl         libssp.so
libblastrampoline.so         libgfortran.so.5             libmpfr.so                libssp.so.0
libblastrampoline.so.5       libgfortran.so.5.0.0         libmpfr.so.6              libssp.so.0.0.0
libblastrampoline.so.5.15.0  libgit2.so                   libmpfr.so.6.2.2          libstdc++.so
libbtf.so                    libgit2.so.1.9               libnghttp2.so             libstdc++.so.6
libbtf.so.2                  libgit2.so.1.9.0             libnghttp2.so.14          libstdc++.so.6.0.33
libbtf.so.2.3.2              libgmp.so                    libnghttp2.so.14.28.3     libsuitesparseconfig.so
libcamd.so                   libgmp.so.10                 libopenblas64_.0.3.29.so  libsuitesparseconfig.so.7
libcamd.so.3                 libgmp.so.10.5.0             libopenblas64_.so         libsuitesparseconfig.so.7.8.3
libcamd.so.3.3.3             libgmpxx.so                  libopenblas64_.so.0       libumfpack.so
libccalllazybar.so           libgmpxx.so.4                libopenlibm.so            libumfpack.so.6
libccalllazyfoo.so           libgmpxx.so.4.7.0            libopenlibm.so.4          libumfpack.so.6.3.5
libccalltest.so              libgomp.so                   libopenlibm.so.4.0        libunwind.so
libccalltest.so.debug        libgomp.so.1                 libpcre2-8.so             libunwind.so.8
libccolamd.so                libgomp.so.1.0.0             libpcre2-8.so.0           libunwind.so.8.1.0
libccolamd.so.3              libjulia-codegen.so          libpcre2-8.so.0.13.0      libuv.so
libccolamd.so.3.3.4          libjulia-codegen.so.1.12     libquadmath.so            libuv.so.2
libcholmod.so                libjulia-codegen.so.1.12.1   libquadmath.so.0          libuv.so.2.0.0
libcholmod.so.5              libjulia-internal.so         libquadmath.so.0.0.0      libz.so
libcholmod.so.5.3.0          libjulia-internal.so.1.12    librbio.so                libz.so.1
libcolamd.so                 libjulia-internal.so.1.12.1  librbio.so.4              libz.so.1.3.1
libcolamd.so.3               libklu.so                    librbio.so.4.3.4          sys.so
libcolamd.so.3.3.4           libklu.so.2                  libspqr.so
libcrypto.so                 libklu.so.2.3.5              libspqr.so.4
libcrypto.so.3               libldl.so                    libspqr.so.4.3.4
2 Likes