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

Segfault calling rand on master #34183

Closed
baggepinnen opened this issue Dec 23, 2019 · 5 comments
Closed

Segfault calling rand on master #34183

baggepinnen opened this issue Dec 23, 2019 · 5 comments

Comments

@baggepinnen
Copy link
Contributor

baggepinnen commented Dec 23, 2019

I just compiled latest master and got the following segmentation fault. When I got the segfault, I started Julia with a custom build sysimage. If I start julia without this image, the call to rand works fine. The sysimage compiled without any errors.

fredrikb@billman:~/.julia$ julia -J"/home/fredrikb/sys.so"
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.4.0-DEV.657 (2019-12-23)
 _/ |\__'_|_|_|\__'_|  |  Commit 6f76d16a9c (0 days old master)
|__/                   |

julia> rand(3)

signal (11): Segmentation fault
in expression starting at REPL[1]:1
unknown function (ip: 0x7f4244c00b3e)
memcpy at /usr/include/x86_64-linux-gnu/bits/string_fortified.h:34 [inlined]
_ios_read at /home/fredrikb/julia/src/support/ios.c:276 [inlined]
ios_readall at /home/fredrikb/julia/src/support/ios.c:337
macro expansion at ./lock.jl:194 [inlined]
unsafe_read at ./iostream.jl:374 [inlined]
unsafe_read at ./io.jl:669 [inlined]
macro expansion at ./gcutils.jl:105 [inlined]
read! at ./io.jl:687
rand! at /home/fredrikb/julia/usr/share/julia/stdlib/v1.4/Random/src/RNGs.jl:51 [inlined]
rand! at /home/fredrikb/julia/usr/share/julia/stdlib/v1.4/Random/src/Random.jl:267 [inlined]
rand at /home/fredrikb/julia/usr/share/julia/stdlib/v1.4/Random/src/Random.jl:288 [inlined]
rand at /home/fredrikb/julia/usr/share/julia/stdlib/v1.4/Random/src/Random.jl:291 [inlined]
make_seed at /home/fredrikb/julia/usr/share/julia/stdlib/v1.4/Random/src/RNGs.jl:249
seed! at /home/fredrikb/julia/usr/share/julia/stdlib/v1.4/Random/src/RNGs.jl:288 [inlined]
seed! at /home/fredrikb/julia/usr/share/julia/stdlib/v1.4/Random/src/Random.jl:426 [inlined]
MersenneTwister at /home/fredrikb/julia/usr/share/julia/stdlib/v1.4/Random/src/RNGs.jl:137
MersenneTwister at /home/fredrikb/julia/usr/share/julia/stdlib/v1.4/Random/src/RNGs.jl:137 [inlined]
default_rng at /home/fredrikb/julia/usr/share/julia/stdlib/v1.4/Random/src/RNGs.jl:302
default_rng at /home/fredrikb/julia/usr/share/julia/stdlib/v1.4/Random/src/RNGs.jl:296 [inlined]
rand at /home/fredrikb/julia/usr/share/julia/stdlib/v1.4/Random/src/Random.jl:289
rand at /home/fredrikb/julia/usr/share/julia/stdlib/v1.4/Random/src/Random.jl:277
unknown function (ip: 0x7f42280773a2)
_jl_invoke at /home/fredrikb/julia/src/gf.c:2158 [inlined]
jl_apply_generic at /home/fredrikb/julia/src/gf.c:2322
jl_apply at /home/fredrikb/julia/src/julia.h:1692 [inlined]
do_call at /home/fredrikb/julia/src/interpreter.c:369
eval_value at /home/fredrikb/julia/src/interpreter.c:458
eval_stmt_value at /home/fredrikb/julia/src/interpreter.c:409 [inlined]
eval_body at /home/fredrikb/julia/src/interpreter.c:819
jl_interpret_toplevel_thunk at /home/fredrikb/julia/src/interpreter.c:913
jl_toplevel_eval_flex at /home/fredrikb/julia/src/toplevel.c:814
jl_toplevel_eval_flex at /home/fredrikb/julia/src/toplevel.c:764
jl_toplevel_eval_in at /home/fredrikb/julia/src/toplevel.c:843
eval at ./boot.jl:331
_jl_invoke at /home/fredrikb/julia/src/gf.c:2144 [inlined]
jl_apply_generic at /home/fredrikb/julia/src/gf.c:2322
eval_user_input at /home/fredrikb/julia/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:86
macro expansion at /home/fredrikb/julia/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:118 [inlined]
#26 at ./task.jl:358
_jl_invoke at /home/fredrikb/julia/src/gf.c:2144 [inlined]
jl_apply_generic at /home/fredrikb/julia/src/gf.c:2322
jl_apply at /home/fredrikb/julia/src/julia.h:1692 [inlined]
start_task at /home/fredrikb/julia/src/task.c:687
unknown function (ip: (nil))
Allocations: 1689974 (Pool: 1689479; Big: 495); GC: 1
Segmentation fault (core dumped)



julia> versioninfo()
Julia Version 1.4.0-DEV.657
Commit 6f76d16a9c (2019-12-23 01:48 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-8.0.1 (ORCJIT, skylake)
Environment:
  JULIA_NUM_THREADS = 6

It's repeatable on my machine with my custom sysimage.

@baggepinnen baggepinnen changed the title Segafult on Pkg.add("") on master Segafult calling rand on master Dec 23, 2019
@jpsamaroo
Copy link
Member

Can you share how you compiled the custom sysimage? And have you tried recompiling it after you compiled julia?

@rfourquet
Copy link
Member

The following line from the stack trace has been changed recently in #27936, but I can't see what would be the problem:

rand! at /home/fredrikb/julia/usr/share/julia/stdlib/v1.4/Random/src/RNGs.jl:51 [inlined]

@rfourquet rfourquet changed the title Segafult calling rand on master Segfault calling rand on master Dec 23, 2019
@baggepinnen
Copy link
Contributor Author

The following is the script I used to compile the sysimage. The last two lines are what I execute in the terminal. The sysimage was recompiled after compiling julia

Base.init_depot_path()
Base.init_load_path()
Base.reinit_stdio()
using Random, LinearAlgebra, Statistics
Random.__init__()
import GR
GR.__init__()
LinearAlgebra.__init__() # for inv required by Colors required by Plots
using Plots
plot(randn(3))
plot(randn(3),randn(3))
heatmap(randn(5,5))
empty!(LOAD_PATH)
empty!(DEPOT_PATH)

# julia --output-o sys.o -J"/home/fredrikb/julia/usr/lib/julia/sys.so" custom_sysimage.jl
# gcc -shared -o sys.so -Wl,--whole-archive sys.o -Wl,--no-whole-archive -L"/home/fredrikb/julia/usr/lib" -ljulia

@KristofferC
Copy link
Member

KristofferC commented Dec 24, 2019

Try the method described here https://kristofferc.github.io/PackageCompilerX.jl/dev/devdocs/sysimages_part_1/#Recording-precompile-statements-1.

One of the __init __ functions might not worth properly through serialization. In general I would say it is best to do all precompilation generation in a separate normal process.

@baggepinnen
Copy link
Contributor Author

I haven't seen this issue arise since, so I think it's okay to close

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants