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

Segmentation fault trying to brute_build_julia() on: using Blink; w = Window() and several others #3

Closed
KestutisMa opened this issue Jul 18, 2019 · 36 comments

Comments

@KestutisMa
Copy link

KestutisMa commented Jul 18, 2019

PackageCompiler compiles Blink#master, but Fezzik throws:

   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.1.1 (2019-05-16)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using Blink;

julia> w = Window()
Window(1, Electron(Process(`/home/kest/.julia/packages/Blink/1mBxc/deps/atom/electron /home/kest/.julia/packages/Blink/1mBxc/src/AtomShell/main.js port 8140`, ProcessRunning), Sockets.TCPSocket(RawFD(0x00000015) active, 0 bytes waiting), Dict{String,Any}("callback"=>##1#2())), Page(1, WebSocket(server, CONNECTED), Dict{String,Any}("callback"=>##1#2()), Distributed.Future(1, 1, 1, Some(true))))

julia> Fezzik.brute_build_julia()
[ Info: generating precompile
[Mux] already loaded
[WebSockets] already loaded
[Mustache] already loaded
[Lazy] already loaded
[Distributed] already loaded
[Pidfile] already loaded
[MacroTools] already loaded
[REPL] already loaded
[AssetRegistry] already loaded
[HTTP] already loaded
[JSON] already loaded
[Sockets] already loaded
[Base64] already loaded
[Blink] already loaded
[AbstractPlotting] already loaded
[Logging] already loaded
[Base] already loaded
[DocStringExtensions] already loaded
[JSExpr] already loaded
[Fezzik] already loaded
[Core] already loaded
[ Info: activating new environment at ~/.julia/packages/PackageCompiler/CJQcs/packages/Project.toml.
failed_packages = Symbol[]
[ Info: used 391 precompile statements
out_file = "/home/kest/.julia/packages/Fezzik/qjuGL/precomp.jl"



 Compiling...
using Mux
 Resolving package versions...
  Updating `~/.julia/environments/v1.1/Project.toml`
  [a975b10e] + Mux v0.7.0
  Updating `~/.julia/environments/v1.1/Manifest.toml`
 [no changes]
[WebSockets] already loaded
using Mustache
 Resolving package versions...
  Updating `~/.julia/environments/v1.1/Project.toml`
  [ffc61752] + Mustache v0.5.12
  Updating `~/.julia/environments/v1.1/Manifest.toml`
 [no changes]
[Lazy] already loaded
[Distributed] already loaded
[Pidfile] already loaded
[MacroTools] already loaded
[REPL] already loaded
[AssetRegistry] already loaded
[HTTP] already loaded
[JSON] already loaded
[Sockets] already loaded
[Base64] already loaded
using Blink
[AbstractPlotting] already loaded
[Logging] already loaded
[Base] already loaded
[DocStringExtensions] already loaded
[JSExpr] already loaded
[Fezzik] already loaded
[Core] already loaded

signal (11): Segmentation fault
in expression starting at no file:0
jl_compile_linfo at /buildworker/worker/package_linux64/build/src/codegen.cpp:1176
emit_invoke at /buildworker/worker/package_linux64/build/src/codegen.cpp:3145
emit_expr at /buildworker/worker/package_linux64/build/src/codegen.cpp:3948
emit_ssaval_assign at /buildworker/worker/package_linux64/build/src/codegen.cpp:3662
emit_function at /buildworker/worker/package_linux64/build/src/codegen.cpp:3854
jl_compile_linfo at /buildworker/worker/package_linux64/build/src/codegen.cpp:1144
emit_invoke at /buildworker/worker/package_linux64/build/src/codegen.cpp:3145
emit_expr at /buildworker/worker/package_linux64/build/src/codegen.cpp:3948
emit_ssaval_assign at /buildworker/worker/package_linux64/build/src/codegen.cpp:3662
emit_function at /buildworker/worker/package_linux64/build/src/codegen.cpp:3854
jl_compile_linfo at /buildworker/worker/package_linux64/build/src/codegen.cpp:1144
jl_compile_hint at /buildworker/worker/package_linux64/build/src/gf.c:1949
jl_compile_specializations at /buildworker/worker/package_linux64/build/src/precompile.c:378 [inlined]
jl_precompile at /buildworker/worker/package_linux64/build/src/precompile.c:387 [inlined]
jl_write_compiler_output at /buildworker/worker/package_linux64/build/src/precompile.c:34
jl_atexit_hook at /buildworker/worker/package_linux64/build/src/init.c:222
main at /buildworker/worker/package_linux64/build/ui/repl.c:218
__libc_start_main at /usr/lib/libc.so.6 (unknown line)
_start at /home/kest/Downloads/julia-1.1.1/bin/julia (unknown line)
Allocations: 88711673 (Pool: 88682253; Big: 29420); GC: 205
ERROR: failed process: Process(`/home/kest/Downloads/julia-1.1.1/bin/julia --optimize=3 --output-o=/home/kest/.julia/packages/PackageCompiler/CJQcs/sysimg/sys.a -g1 --track-allocation=none --startup-file=no --code-coverage=none --history-file=yes --inline=yes --math-mode=ieee --handle-signals=yes --warn-overwrite=no --compile=yes --depwarn=yes --cpu-target=native --track-allocation=none --sysimage-native-code=yes --sysimage=/home/kest/.julia/packages/PackageCompiler/CJQcs/sysimg/sys.so -g1 --compiled-modules=yes --optimize=2 /home/kest/.julia/packages/PackageCompiler/CJQcs/sysimg/run_julia_code.jl`, ProcessSignaled(11)) [0]
Stacktrace:
 [1] error(::String, ::Base.Process, ::String, ::Int64, ::String) at ./error.jl:42
 [2] pipeline_error at ./process.jl:785 [inlined]
 [3] #run#515(::Bool, ::Function, ::Cmd) at ./process.jl:726
 [4] run at ./process.jl:724 [inlined]
 [5] #run_julia#1 at /home/kest/.julia/packages/PackageCompiler/CJQcs/src/compiler_flags.jl:225 [inlined]
 [6] #run_julia at ./none:0 [inlined]
 [7] #compile_incremental#62(::Bool, ::Bool, ::Bool, ::Nothing, ::Function, ::Nothing, ::String) at /home/kest/.julia/packages/PackageCompiler/CJQcs/src/incremental.jl:137
 [8] #compile_incremental at ./none:0 [inlined]
 [9] #brute_build_julia#5(::Bool, ::Function) at /home/kest/.julia/packages/Fezzik/qjuGL/src/bootstrap.jl:184
 [10] brute_build_julia() at /home/kest/.julia/packages/Fezzik/qjuGL/src/bootstrap.jl:78
 [11] top-level scope at none:0

Also, I made post about this issue here https://discourse.julialang.org/t/segmentation-fault-trying-to-fezzik-brute-build-julia-on-using-blink-w-window/26491

@KestutisMa KestutisMa changed the title Segmentation fault trying to brute_build_julia() Blink w = Window() Segmentation fault trying to brute_build_julia() on: using Blink; w = Window() Jul 18, 2019
@TsurHerman
Copy link
Owner

Fezzik uses PackageCompiler so there is probably not much I can do for you.

But it worked for me using the following steps.
Fezzik.revert()
restart julia
using Blink
let it precompile ... then restart julia

Fezzik.auto_trace(false) #removes also previous traces dir
Fezzik.auto_trace(true) #reinstating trace

restart julia

using Blink
w = Window();

restart julia
brute_build_julia()

On my machine (osx) when a window is created using blink and the user closes it(presses the x) it crashes julia
as well, so if you are on osx , then the segmentation fault might have come from the fact that something tried to close the window that you just opened prior to invoking brute_build_julia

@KestutisMa
Copy link
Author

I just deleted ~/.julia folder, started again and it worked! I don't know what caused such issue before, maybe my previous compilations using PackageCompiler.

On my machine (osx) when a window is created using blink and the user closes it(presses the x) it crashes julia

I didn't observe this on my machine (Arch Linux). Closing window do not throw error or crash julia.

But thanks for reply

@KestutisMa
Copy link
Author

After fresh julia v1.1.1 download I did Fezzik.auto_trace(true), then restarted Julia and ran brute_build_julia(), sys.so was generated successfully. But after I restarted Julia and again did brute_build_julia() it resulted in segmentation fault.
Such behavior is quite often when I try to brute_build_julia() second time to add more precompiles to sys image.
Is it normal? Is it possible to run brute_build_julia() only one time, so is it not possible add more precompile statements into existing image?

@TsurHerman
Copy link
Owner

It depends on what you are trying to add to the sysimg, for my use cases it works doing several times with no problem. However if there are some packages that causes the seg fault on the second build...
You can try and pinpoint the exact module that causes this behaviour, it might shed some light.

@KestutisMa
Copy link
Author

It is strange, let me give an example: using Blink; w = Window(); Fezzik.brute_build_julia() works when compiling on original sys.so, but fails on second run! (in this case first run was script that contained using AbstractPlotting; import Makie and some plotting).
What explanation could be of such behavior?

[kest@archlinux ~]$  /home/kest/Downloads/julia-1.1.1/bin/julia 
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.1.1 (2019-05-16)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using Blink; w = Window();

julia> Fezzik.brute_build_julia()
[ Info: generating precompile
[Mux] already loaded
[WebSockets] already loaded
[Mustache] already loaded
[Lazy] already loaded
[Requires] already loaded
[Distributed] already loaded
[Pidfile] already loaded
[AssetRegistry] already loaded
[REPL] already loaded
[MacroTools] already loaded
[HTTP] already loaded
[JSON] already loaded
[Sockets] already loaded
[WebIO] already loaded
[Base64] already loaded
[Blink] already loaded
[AbstractPlotting] already loaded
[JSExpr] already loaded
[Base] already loaded
[Core] already loaded
failed_packages = Symbol[]
[ Info: used 279 precompile statements
out_file = "/home/kest/.julia/packages/Fezzik/qjuGL/precomp.jl"



 Compiling...
using Mux
[WebSockets] already loaded
using Mustache
[Lazy] already loaded
[Requires] already loaded
[Distributed] already loaded
[Pidfile] already loaded
[AssetRegistry] already loaded
[REPL] already loaded
[MacroTools] already loaded
[HTTP] already loaded
[JSON] already loaded
[Sockets] already loaded
using WebIO
[Base64] already loaded
using Blink
[AbstractPlotting] already loaded
[JSExpr] already loaded
[Base] already loaded
[Core] already loaded
┌ Info: UndefVarError(:WebIOServer)
│   LINE = 75
└ @ Main.##anon_module#367 /home/kest/.julia/packages/Fezzik/qjuGL/precomp.jl:75
┌ Info: UndefVarError(Symbol("##91#92"))
│   LINE = 263
└ @ Main.##anon_module#367 /home/kest/.julia/packages/Fezzik/qjuGL/precomp.jl:263

signal (11): Segmentation fault
in expression starting at no file:0
jl_compile_linfo at /buildworker/worker/package_linux64/build/src/codegen.cpp:1176
emit_invoke at /buildworker/worker/package_linux64/build/src/codegen.cpp:3145
emit_expr at /buildworker/worker/package_linux64/build/src/codegen.cpp:3948
emit_ssaval_assign at /buildworker/worker/package_linux64/build/src/codegen.cpp:3662
emit_function at /buildworker/worker/package_linux64/build/src/codegen.cpp:3854
jl_compile_linfo at /buildworker/worker/package_linux64/build/src/codegen.cpp:1144
emit_invoke at /buildworker/worker/package_linux64/build/src/codegen.cpp:3145
emit_expr at /buildworker/worker/package_linux64/build/src/codegen.cpp:3948
emit_ssaval_assign at /buildworker/worker/package_linux64/build/src/codegen.cpp:3662
emit_function at /buildworker/worker/package_linux64/build/src/codegen.cpp:3854
jl_compile_linfo at /buildworker/worker/package_linux64/build/src/codegen.cpp:1144
jl_compile_hint at /buildworker/worker/package_linux64/build/src/gf.c:1949
jl_compile_specializations at /buildworker/worker/package_linux64/build/src/precompile.c:378 [inlined]
jl_precompile at /buildworker/worker/package_linux64/build/src/precompile.c:387 [inlined]
jl_write_compiler_output at /buildworker/worker/package_linux64/build/src/precompile.c:34
jl_atexit_hook at /buildworker/worker/package_linux64/build/src/init.c:222
main at /buildworker/worker/package_linux64/build/ui/repl.c:218
__libc_start_main at /usr/lib/libc.so.6 (unknown line)
_start at /home/kest/Downloads/julia-1.1.1/bin/julia (unknown line)
Allocations: 45023802 (Pool: 45006386; Big: 17416); GC: 98
ERROR: failed process: Process(`/home/kest/Downloads/julia-1.1.1/bin/julia --optimize=3 --output-o=/home/kest/.julia/packages/PackageCompiler/CJQcs/sysimg/sys.a -g1 --track-allocation=none --startup-file=no --code-coverage=none --history-file=yes --inline=yes --math-mode=ieee --handle-signals=yes --warn-overwrite=no --compile=yes --depwarn=yes --cpu-target=native --track-allocation=none --sysimage-native-code=yes --sysimage=/home/kest/Downloads/julia-1.1.1/lib/julia/sys.so -g1 --compiled-modules=yes --optimize=2 /home/kest/.julia/packages/PackageCompiler/CJQcs/sysimg/run_julia_code.jl`, ProcessSignaled(11)) [0]
Stacktrace:
 [1] error(::String, ::Base.Process, ::String, ::Int64, ::String) at ./error.jl:42
 [2] pipeline_error at ./process.jl:785 [inlined]
 [3] #run#515(::Bool, ::Function, ::Cmd) at ./process.jl:726
 [4] run at ./process.jl:724 [inlined]
 [5] #run_julia#1 at /home/kest/.julia/packages/PackageCompiler/CJQcs/src/compiler_flags.jl:225 [inlined]
 [6] #run_julia at ./none:0 [inlined]
 [7] #compile_incremental#62(::Bool, ::Bool, ::Bool, ::Nothing, ::Function, ::Nothing, ::String) at /home/kest/.julia/packages/PackageCompiler/CJQcs/src/incremental.jl:137
 [8] #compile_incremental at ./none:0 [inlined]
 [9] #brute_build_julia#5(::Bool, ::Function) at /home/kest/.julia/packages/Fezzik/qjuGL/src/bootstrap.jl:184
 [10] brute_build_julia() at /home/kest/.julia/packages/Fezzik/qjuGL/src/bootstrap.jl:78
 [11] top-level scope at none:0

julia>

@KestutisMa
Copy link
Author

Ok, I just realized that when I compile first time using Blink; ... or using AbstractPlotting; ... it works. But if I try to compile onto same sysimage second file it fails :) so maybe there is conflicting statements in both scripts.

@KestutisMa
Copy link
Author

Two MWE:
No matters which of them I run first, second brute_build run fails to compile.
If I run each after revert() - both are working.

import AbstractPlotting, Makie; const ap = AbstractPlotting; ap.__init__(); s = ap.lines(rand(10))
Fezzik.brute_build_julia()
import Blink; w = Blink.Window();
Fezzik.brute_build_julia()

One of given example compile error:

julia> import Blink; w = Blink.Window();

julia> Fezzik.brute_build_julia()
[ Info: generating precompile
[Mux] already loaded
[WebSockets] already loaded
[Mustache] already loaded
[Lazy] already loaded
[MacroTools] already loaded
[REPL] already loaded
[Sockets] already loaded
[Blink] already loaded
[Base] already loaded
[Distributed] already loaded
[HTTP] already loaded
[JSON] already loaded
[WebIO] already loaded
[Base64] already loaded
[AbstractPlotting] already loaded
[JSExpr] already loaded
failed_packages = Symbol[]
[ Info: used 225 precompile statements
out_file = "/home/kest/.julia/packages/Fezzik/qjuGL/precomp.jl"



 Compiling...
[Mux] already loaded
[WebSockets] already loaded
[Mustache] already loaded
[Lazy] already loaded
[MacroTools] already loaded
[REPL] already loaded
[Sockets] already loaded
[Blink] already loaded
[Base] already loaded
[Distributed] already loaded
[HTTP] already loaded
[JSON] already loaded
[WebIO] already loaded
[Base64] already loaded
[AbstractPlotting] already loaded
[JSExpr] already loaded

signal (11): Segmentation fault
in expression starting at no file:0
jl_compile_linfo at /buildworker/worker/package_linux64/build/src/codegen.cpp:1176
emit_invoke at /buildworker/worker/package_linux64/build/src/codegen.cpp:3145
emit_expr at /buildworker/worker/package_linux64/build/src/codegen.cpp:3948
emit_ssaval_assign at /buildworker/worker/package_linux64/build/src/codegen.cpp:3662
emit_function at /buildworker/worker/package_linux64/build/src/codegen.cpp:3854
jl_compile_linfo at /buildworker/worker/package_linux64/build/src/codegen.cpp:1144
emit_invoke at /buildworker/worker/package_linux64/build/src/codegen.cpp:3145
emit_expr at /buildworker/worker/package_linux64/build/src/codegen.cpp:3948
emit_ssaval_assign at /buildworker/worker/package_linux64/build/src/codegen.cpp:3662
emit_function at /buildworker/worker/package_linux64/build/src/codegen.cpp:3854
jl_compile_linfo at /buildworker/worker/package_linux64/build/src/codegen.cpp:1144
jl_compile_hint at /buildworker/worker/package_linux64/build/src/gf.c:1949
jl_compile_specializations at /buildworker/worker/package_linux64/build/src/precompile.c:378 [inlined]
jl_precompile at /buildworker/worker/package_linux64/build/src/precompile.c:387 [inlined]
jl_write_compiler_output at /buildworker/worker/package_linux64/build/src/precompile.c:34
jl_atexit_hook at /buildworker/worker/package_linux64/build/src/init.c:222
main at /buildworker/worker/package_linux64/build/ui/repl.c:218
__libc_start_main at /usr/lib/libc.so.6 (unknown line)
_start at /home/kest/Downloads/julia-1.1.1/bin/julia (unknown line)
Allocations: 29266051 (Pool: 29260059; Big: 5992); GC: 63
ERROR: failed process: Process(`/home/kest/Downloads/julia-1.1.1/bin/julia --optimize=3 --output-o=/home/kest/.julia/packages/PackageCompiler/CJQcs/sysimg/sys.a -g1 --track-allocation=none --startup-file=no --code-coverage=none --history-file=yes --inline=yes --math-mode=ieee --handle-signals=yes --warn-overwrite=no --compile=yes --depwarn=yes --cpu-target=native --track-allocation=none --sysimage-native-code=yes --sysimage=/home/kest/Downloads/julia-1.1.1/lib/julia/sys.so -g1 --compiled-modules=yes --optimize=2 /home/kest/.julia/packages/PackageCompiler/CJQcs/sysimg/run_julia_code.jl`, ProcessSignaled(11)) [0]
Stacktrace:
 [1] error(::String, ::Base.Process, ::String, ::Int64, ::String) at ./error.jl:42
 [2] pipeline_error at ./process.jl:785 [inlined]
 [3] #run#515(::Bool, ::Function, ::Cmd) at ./process.jl:726
 [4] run at ./process.jl:724 [inlined]
 [5] #run_julia#1 at /home/kest/.julia/packages/PackageCompiler/CJQcs/src/compiler_flags.jl:225 [inlined]
 [6] #run_julia at ./none:0 [inlined]
 [7] #compile_incremental#62(::Bool, ::Bool, ::Bool, ::Nothing, ::Function, ::Nothing, ::String) at /home/kest/.julia/packages/PackageCompiler/CJQcs/src/incremental.jl:137
 [8] #compile_incremental at ./none:0 [inlined]
 [9] #brute_build_julia#5(::Bool, ::Function) at /home/kest/.julia/packages/Fezzik/qjuGL/src/bootstrap.jl:184
 [10] brute_build_julia() at /home/kest/.julia/packages/Fezzik/qjuGL/src/bootstrap.jl:78
 [11] top-level scope at none:0

julia> 

@TsurHerman
Copy link
Owner

It is beyond my level to debug this...

@TsurHerman
Copy link
Owner

@SimonDanisch maybe you could help?

@TsurHerman TsurHerman reopened this Jul 29, 2019
@SimonDanisch
Copy link

Is this using compile_incremental with a previously compiled sysimage? That's supposed to work, but does segfault in certain cases

@KestutisMa
Copy link
Author

@SimonDanisch

Is this using compile_incremental with a previously compiled sysimage? That's supposed to work, but does segfault in certain cases

Yes, sysimage was compiled by Fezzik, which is using compile_incremental. Also it is interesting that compilation of both examples at once (one compile_incemental call with original sysimage) was successful. But if I compile one after another (no maters which is first) compilation segfaults.
I also made post about this https://discourse.julialang.org/t/packagecompiler-errors-on-compile-incremental-second-run/26932

@TsurHerman
Copy link
Owner

Yes, but can you run a debug version of Julia and say which precompile statement caused the segfault?

It is hapenning in the C side of julia

@KestutisMa
Copy link
Author

KestutisMa commented Jul 30, 2019

Actually segfault happens even if I do

julia> using Example
julia> Example.hello("aa")
"Hello, aa"
julia> Fezzik.brute_build_julia()

after

import AbstractPlotting, Makie; const ap = AbstractPlotting; ap.__init__(); s = ap.lines(rand(10))
Fezzik.brute_build_julia()

or

import Blink; w = Blink.Window();
Fezzik.brute_build_julia()

@TsurHerman
Copy link
Owner

Maybe you can open an issue with Julia and see if you can get someone to check out where is the segmentation fault coming from...

@KestutisMa
Copy link
Author

Thanks for adding debug information in last Fezzik commit ;-)
It is interesting, I tried to delete .julia folder and start form beginning.
Then
using Blink; w = Window; Fezzik.brute_build_julia()
and
using Makie; lines(rand(3)); Fezzik.brute_build_julia()
was successful, but afterwards
using Interact; ui = Interact.button(); Fezzik.brute_build_julia()
gave error:

...
/home/kest/.julia/packages/Fezzik/Uvmuj/precomp.jl:631

done.
.
.
Creating sysimg

signal (11): Segmentation fault
in expression starting at no file:0
jl_compile_linfo at /buildworker/worker/package_linux64/build/src/codegen.cpp:1176
emit_invoke at /buildworker/worker/package_linux64/build/src/codegen.cpp:3145
emit_expr at /buildworker/worker/package_linux64/build/src/codegen.cpp:3948
emit_ssaval_assign at /buildworker/worker/package_linux64/build/src/codegen.cpp:3662
emit_function at /buildworker/worker/package_linux64/build/src/codegen.cpp:3854
jl_compile_linfo at /buildworker/worker/package_linux64/build/src/codegen.cpp:1144
emit_invoke at /buildworker/worker/package_linux64/build/src/codegen.cpp:3145
emit_expr at /buildworker/worker/package_linux64/build/src/codegen.cpp:3948
emit_ssaval_assign at /buildworker/worker/package_linux64/build/src/codegen.cpp:3662
emit_function at /buildworker/worker/package_linux64/build/src/codegen.cpp:3854
jl_compile_linfo at /buildworker/worker/package_linux64/build/src/codegen.cpp:1144
jl_compile_hint at /buildworker/worker/package_linux64/build/src/gf.c:1949
jl_compile_specializations at /buildworker/worker/package_linux64/build/src/precompile.c:378 [inlined]
jl_precompile at /buildworker/worker/package_linux64/build/src/precompile.c:387 [inlined]
jl_write_compiler_output at /buildworker/worker/package_linux64/build/src/precompile.c:34
jl_atexit_hook at /buildworker/worker/package_linux64/build/src/init.c:222
main at /buildworker/worker/package_linux64/build/ui/repl.c:218
__libc_start_main at /usr/lib/libc.so.6 (unknown line)
_start at /home/kest/Downloads/julia-1.1.1/bin/julia (unknown line)
Allocations: 13846602 (Pool: 13843985; Big: 2617); GC: 30
ERROR: failed process: Process(`/home/kest/Downloads/julia-1.1.1/bin/julia --optimize=3 --output-o=/home/kest/.julia/packages/PackageCompiler/CJQcs/sysimg/sys.a -g1 --track-allocation=none --startup-file=no --code-coverage=none --history-file=yes --inline=yes --math-mode=ieee --handle-signals=yes --warn-overwrite=no --compile=yes --depwarn=yes --cpu-target=native --track-allocation=none --sysimage-native-code=yes --sysimage=/home/kest/Downloads/julia-1.1.1/lib/julia/sys.so -g1 --compiled-modules=yes --optimize=2 /home/kest/.julia/packages/PackageCompiler/CJQcs/sysimg/run_julia_code.jl`, ProcessSignaled(11)) [0]
Stacktrace:
 [1] error(::String, ::Base.Process, ::String, ::Int64, ::String) at ./error.jl:42
 [2] pipeline_error at ./process.jl:785 [inlined]
 [3] #run#515(::Bool, ::Function, ::Cmd) at ./process.jl:726
 [4] run at ./process.jl:724 [inlined]
 [5] #run_julia#1 at /home/kest/.julia/packages/PackageCompiler/CJQcs/src/compiler_flags.jl:225 [inlined]
 [6] #run_julia at ./none:0 [inlined]
 [7] #compile_incremental#62(::Bool, ::Bool, ::Bool, ::Nothing, ::Function, ::Nothing, ::String) at /home/kest/.julia/packages/PackageCompiler/CJQcs/src/incremental.jl:137
 [8] #compile_incremental at ./none:0 [inlined]
 [9] #brute_build_julia#5(::Bool, ::Bool, ::Function) at /home/kest/.julia/packages/Fezzik/Uvmuj/src/bootstrap.jl:209
 [10] (::getfield(Fezzik, Symbol("#kw##brute_build_julia")))(::NamedTuple{(:debug,),Tuple{Bool}}, ::typeof(brute_build_julia)) at ./none:0
 [11] top-level scope at none:0

@TsurHerman
Copy link
Owner

When the script has printed the ”creating sysimg” msg it finished compiling and is now dumping the memory modules into one big sysimg... And here in this phase it crashes.

@SimonDanisch
Copy link

SimonDanisch commented Jul 31, 2019

So is brute_build_julia building uppon the previous system image that got compiled via brute_build_julia?
If it does, that's exactly the behaviour I'd expect, as pointed out previously.

@KestutisMa
Copy link
Author

Yes, today I compiled two times in a row successfully (earlier, same error was thrown on second run, but after I deleted .julia folder now it errors on third run):
Original sys.so -> (Interact) brute_build_julia -> (Blink) brute_build_julia -> (Makie) brute_build_julia = segfault.
Also it doesn't matters which package I brute_build_julia first and second, but third run segfaults.
I also tried to run julia-debug but it errors even at using Makie (but non-debug version woks fine).
Isn't strange that same package sometimes compiles sometimes not?

@SimonDanisch
Copy link

If brute_build_julia builds incrementally uppon other incrementally build system images - no it's not strange...
It will yield undefined behaviour, so anything can happen, including it working sometimes.

@TsurHerman
Copy link
Owner

I suspect the error stems from the type annotation on the function in structarrays.jl line 80 in StructArrays module, at least this is where the debug information leads to...

@KestutisMa
Copy link
Author

KestutisMa commented Jul 31, 2019

Thanks for explanation, so compile_incremental can be ran only one time for explicit behavior? But sometimes it works, so if we could know why that happens it may be useful to prevent that?

@TsurHerman
Copy link
Owner

A possible solution

@KestutisMa
Copy link
Author

KestutisMa commented Aug 1, 2019

Using your's modification to gf.c. Tried brute_build_julia() this file after I compiled Interact, Blink, Makie:

function kernel1!(V_,
	I,
	n_,
	m_,
	h_,
	dt_sim,
	cellCountY,
    cellCountX, i)

   	for y = 1:cellCountY
       	for x = 1:cellCountX
            V = V_[y,x];
            n = n_[y,x];
            m = m_[y,x];
            h = h_[y,x];
            g_Na_max = 4.0; g_K_add = 0.002; g_L = 0.0; E_Na = 40.0; E_L = -60.0; Area = 7.6e-3;
            alpha_n = 0.0; beta_n = 0.0; alpha_m = 0.0; beta_m = 0.0; alpha_h = 0.0; beta_h = 0.0; g_Na = 0.0; g_K1 = 0.0; g_K2 = 0.0; i_Na = 0.0; i_K = 0.0; i_Leak = 0.0; i_ion = 0.0;
           	i_Leak = g_L * (V - E_L);
            #  //------------potassium
            alpha_n = .0003 * (-V - 50.) / (exp((-V - 50.) / 10.) - 1.);
            beta_n = .002 * exp((-V - 90.) / 80.);
            n = n + (alpha_n * (1 - n) - beta_n * n) * dt_sim;
            g_K1 = .012 * exp((-V - 90.) / 50.) + .00015 * exp((V + 90.) / 60.);
            g_K2 = .012 * n * n * n * n;
            i_K = (g_K1 + g_K2 + g_K_add) * (V + 100.);
            #  //------------ - sodium
            alpha_h = .166 * exp((-V - 90.) / 20.);
            beta_h = 1. / (1. + exp((-V - 42.) / 10.));
            h = h + (alpha_h * (1. - h) - beta_h * h) * dt_sim;
            alpha_m = .1 * (-V - 48.) / (exp((-V - 48.) / 15.) - 1.);
            beta_m = .12 * (V + 8.) / (exp((V + 8.) / 5.) - 1.);
            m = m + (alpha_m * (1. - m) - beta_m * m) * dt_sim;
            g_Na = m * m * m * h * g_Na_max;
           	i_Na = (g_Na + .0014) * (V - E_Na);

            i_ion = (i_Na + i_K + i_Leak);

            n_[y,x] = n;
            m_[y,x] = m;
            h_[y,x] = h;

            if (x > 1 && x < cellCountX && y > 1 && y < cellCountY ) # // TODO: separete if x ... if y ..., will get extra line simulated
                dx1 = V_[y,x - 1] - V; #// each thread compares two cells: right(x+1) and up (y+1) with current cell (x,y)
                dx2 = V_[y,x + 1] - V;
                dy1 = V_[y - 1,x] - V;
                dy2 = V_[y + 1, x] - V;
                gjX = 125e-9;
                gjY = 125e-9 / 4;
                I[y,x] = -Area * i_ion + 1000 * ( gjX * dx1 + gjX * dx2 + gjY * dy1 + gjY * dy2 );
            end
        end
    end
end

function kernel2!(I, V_, V_reg, cellCountY, cellCountX, dt_sim, dt_reg, i)
    Cm = .12; Area = 7.6e-3;
   	for y = 1:cellCountY
      		for x = 1:cellCountX

            if (i * dt_sim) % dt_reg == 0
                i_reg = Int(i * dt_sim / dt_reg);
                V_reg[i_reg,y,x] = V_[y,x];
            end
            # V_reg[i,y,x] = V_[y,x];

            V = V_[y,x];

            up = 100 + 60;
            # I_ext = (i > 100 && i < 100 + 2) ? 0.2 : 0
            I_ext = ( (i > 100 && i < 100 + 2)
                ||  (i > up && i < up + 2) ) &&
                    (y > 16 - 2 && y < 16 + 2 && x > 16 - 2 && x < 16 + 2) ? 0.2 : 0;
            # display(I[y,x])
            # error("")
            V_[y,x] = V + dt_sim * (I_ext + I[y,x]) / (Cm * Area);
        end
    end
end

# using AbstractPlotting
import Makie
const mk = Makie

function run()
    Makie.AbstractPlotting.__init__()
#pagal NobleCppLinux 2019-07-16

    dt_sim = .1; #.01simuliacijos dT ms
    sim_t = 400; #simulacijos trukme ms
    dt_reg = .1; #.01isvedimo dT ms
    N_reg = Int(sim_t / dt_reg);# koks isvedimo matricu dydis
    N_sim = Int(sim_t / dt_sim); # simulacijos trukme, iteracijomis
    cellCountY = 32;
    cellCountX = 32;

    n = zeros(cellCountY, cellCountX)
    m = zeros(cellCountY, cellCountX)
    h = zeros(cellCountY, cellCountX)
    I = zeros(cellCountY, cellCountX)
    V = zeros(cellCountY, cellCountX); V .= -85.0;
    V_reg = zeros(N_reg, cellCountY, cellCountX)
    vv = []#zeros(N_reg)

    s1 = mk.heatmap(V)    
    s2 = mk.lines(zeros(2))
    s = mk.vbox(mk.title(s1, "V map";  textsize = 15),
             mk.title(s2, "V[16,16]"; textsize = 15))
    display(s)

    i_reg = 0
    for i = 1:N_sim
        if i / N_sim * 100 % 10 == 0
            print(i / N_sim * 100, "% ")
        end
        kernel1!(V, I, n, m, h, dt_sim, cellCountY, cellCountX, i)
        kernel2!(I, V, V_reg, cellCountY, cellCountX, dt_sim, dt_reg, i)
        if i % 100 == 0
            push!(vv, V[16, 16])
            s1[end][1] = V.+1
            s2[end][1] = vv
            mk.update_limits!(s2)
            mk.update!(s2)
            sleep(1 / 24)
        end
    end
s = mk.lines(reshape(V_reg, N_reg, cellCountY, cellCountX)[:,32,32])
    s2[end][1] = vv

end

run()

And that showed:

...
emit_function at /home/kest/Projects/julia/src/codegen.cpp:6277
jl_compile_linfo at /home/kest/Projects/julia/src/codegen.cpp:1144
emit_invoke at /home/kest/Projects/julia/src/codegen.cpp:3145
emit_expr at /home/kest/Projects/julia/src/codegen.cpp:3948
emit_ssaval_assign at /home/kest/Projects/julia/src/codegen.cpp:3662
emit_stmtpos at /home/kest/Projects/julia/src/codegen.cpp:3854 [inlined]
emit_function at /home/kest/Projects/julia/src/codegen.cpp:6277
jl_compile_linfo at /home/kest/Projects/julia/src/codegen.cpp:1144
jl_compile_hint at /home/kest/Projects/julia/src/gf.c:1950
jl_compile_specializations at /home/kest/Projects/julia/src/precompile.c:378
jl_precompile at /home/kest/Projects/julia/src/precompile.c:387 [inlined]
jl_write_compiler_output at /home/kest/Projects/julia/src/precompile.c:34
jl_atexit_hook at /home/kest/Projects/julia/src/init.c:222
main at /home/kest/Projects/julia/ui/repl.c:218
__libc_start_main at /usr/lib/libc.so.6 (unknown line)
_start at /home/kest/Projects/julia/usr/bin/julia (unknown line)
ERROR: failed process: Process(`/home/kest/Projects/julia/usr/bin/julia --optimize=3 --output-o=/home/kest/.julia/packages/PackageCompiler/CJQcs/sysimg/sys.a -g1 --track-allocation=none --startup-file=no --code-coverage=none --history-file=yes --inline=yes --math-mode=ieee --handle-signals=yes --warn-overwrite=no --compile=yes --depwarn=yes --cpu-target=native --track-allocation=none --sysimage-native-code=yes --sysimage=/home/kest/Projects/julia/usr/lib/julia/sys.so -g1 --compiled-modules=yes --optimize=2 /home/kest/.julia/packages/PackageCompiler/CJQcs/sysimg/run_julia_code.jl`, ProcessExited(1)) [1]
Stacktrace:
 [1] error(::String, ::Base.Process, ::String, ::Int64, ::String) at ./error.jl:42
 [2] pipeline_error at ./process.jl:785 [inlined]
 [3] #run#515(::Bool, ::Function, ::Cmd) at ./process.jl:726
 [4] run at ./process.jl:724 [inlined]
 [5] #run_julia#1 at /home/kest/.julia/packages/PackageCompiler/CJQcs/src/compiler_flags.jl:225 [inlined]
 [6] #run_julia at ./none:0 [inlined]
 [7] #compile_incremental#62(::Bool, ::Bool, ::Bool, ::Nothing, ::Function, ::Nothing, ::String) at /home/kest/.julia/packages/PackageCompiler/CJQcs/src/incremental.jl:137
 [8] #compile_incremental at ./none:0 [inlined]
 [9] #brute_build_julia#5(::Bool, ::Bool, ::Function) at /home/kest/.julia/packages/Fezzik/Uvmuj/src/bootstrap.jl:209
 [10] brute_build_julia() at /home/kest/.julia/packages/Fezzik/Uvmuj/src/bootstrap.jl:82
 [11] top-level scope at none:0

@KestutisMa
Copy link
Author

KestutisMa commented Aug 1, 2019

Tried same in julia-debug (on fresh sys-debug.so), showed more about that error:

julia> using Fezzik; Fezzik.trace(); include(raw"/home/kest/Projects/gjJulia/noble2D.jl"); Fezzik.brute_build_julia();
...
Creating sysimg
julia-debug: /home/kest/Projects/julia/src/codegen.cpp:1094: jl_llvm_functions_t jl_compile_linfo(jl_method_instance_t**, jl_code_info_t*, size_t, const jl_cgparams_t*): Assertion `li->min_world <= world && li->max_world >= world' failed.

signal (6): Aborted
in expression starting at no file:0
gsignal at /usr/lib/libc.so.6 (unknown line)
abort at /usr/lib/libc.so.6 (unknown line)
__assert_fail_base.cold at /usr/lib/libc.so.6 (unknown line)
__assert_fail at /usr/lib/libc.so.6 (unknown line)
jl_compile_linfo at /home/kest/Projects/julia/src/codegen.cpp:1094
emit_invoke at /home/kest/Projects/julia/src/codegen.cpp:3145
emit_expr at /home/kest/Projects/julia/src/codegen.cpp:3948
emit_ssaval_assign at /home/kest/Projects/julia/src/codegen.cpp:3662
emit_stmtpos at /home/kest/Projects/julia/src/codegen.cpp:3854
emit_function at /home/kest/Projects/julia/src/codegen.cpp:6277
jl_compile_linfo at /home/kest/Projects/julia/src/codegen.cpp:1144
emit_invoke at /home/kest/Projects/julia/src/codegen.cpp:3145
emit_expr at /home/kest/Projects/julia/src/codegen.cpp:3948
emit_ssaval_assign at /home/kest/Projects/julia/src/codegen.cpp:3662
emit_stmtpos at /home/kest/Projects/julia/src/codegen.cpp:3854
emit_function at /home/kest/Projects/julia/src/codegen.cpp:6277
jl_compile_linfo at /home/kest/Projects/julia/src/codegen.cpp:1144
jl_compile_hint at /home/kest/Projects/julia/src/gf.c:1950
jl_compile_specializations at /home/kest/Projects/julia/src/precompile.c:378
jl_precompile at /home/kest/Projects/julia/src/precompile.c:387
jl_write_compiler_output at /home/kest/Projects/julia/src/precompile.c:34
jl_atexit_hook at /home/kest/Projects/julia/src/init.c:222
main at /home/kest/Projects/julia/ui/repl.c:218
__libc_start_main at /usr/lib/libc.so.6 (unknown line)
_start at /home/kest/Projects/julia/usr/bin/julia-debug (unknown line)
Allocations: 242939867 (Pool: 242901221; Big: 38646); GC: 548
ERROR: failed process: Process(`/home/kest/Projects/julia/usr/bin/julia-debug --optimize=3 --output-o=/home/kest/.julia/packages/PackageCompiler/CJQcs/sysimg/sys.a -g1 --track-allocation=none --startup-file=no --code-coverage=none --history-file=yes --inline=yes --math-mode=ieee --handle-signals=yes --warn-overwrite=no --compile=yes --depwarn=yes --cpu-target=native --track-allocation=none --sysimage-native-code=yes --sysimage=/home/kest/Projects/julia/usr/lib/julia/sys-debug.so -g2 --compiled-modules=yes --optimize=2 /home/kest/.julia/packages/PackageCompiler/CJQcs/sysimg/run_julia_code.jl`, ProcessSignaled(6)) [0]
Stacktrace:
 [1] error(::String, ::Base.Process, ::String, ::Int64, ::String) at ./error.jl:42
 [2] pipeline_error at ./process.jl:785 [inlined]
 [3] #run#515(::Bool, ::Function, ::Cmd) at ./process.jl:726
 [4] run at ./process.jl:724 [inlined]
 [5] #run_julia#1 at /home/kest/.julia/packages/PackageCompiler/CJQcs/src/compiler_flags.jl:225 [inlined]
 [6] #run_julia at ./none:0 [inlined]
 [7] #compile_incremental#62(::Bool, ::Bool, ::Bool, ::Nothing, ::Function, ::Nothing, ::String) at /home/kest/.julia/packages/PackageCompiler/CJQcs/src/incremental.jl:137
 [8] #compile_incremental at ./none:0 [inlined]
 [9] #brute_build_julia#5(::Bool, ::Bool, ::Function) at /home/kest/.julia/packages/Fezzik/Uvmuj/src/bootstrap.jl:209
 [10] brute_build_julia() at /home/kest/.julia/packages/Fezzik/Uvmuj/src/bootstrap.jl:82
 [11] top-level scope at none:0

@TsurHerman
Copy link
Owner

try to blacklist("AbstractPlotiing")

@KestutisMa
Copy link
Author

KestutisMa commented Aug 2, 2019

Tried, now sysimage was created successfully, but "time to first" is long.

@TsurHerman
Copy link
Owner

You are hitting ”world age” problems... The main problem is that it uses asserts in the C code which causes segfaults.

@KestutisMa
Copy link
Author

How to fix it? :-)

@KestutisMa
Copy link
Author

KestutisMa commented Aug 2, 2019

Actually commenting out line 1755 in subtype.c: //assert(obvious_subtype == 3 || obvious_subtype == subtype || jl_has_free_typevars(x) || jl_has_free_typevars(y)); solves that ;-)
Maybe somebody could advice better solution?
what means these functions?
why such assert is needed and why it caused an error?

@KestutisMa
Copy link
Author

Previous post was using Julia master branch, but trying to Fezzik.brute_build_julia(); another file (using Interact) gave error even at compiling. So I switched to v1.1.1 branch. Then segfault appeared, julia-debug showed it's location and error disappeared after I commented out line 1094 at codegen.c // assert(li->min_world <= world && li->max_world >= world);.
Next I decided to Fezzik.brute_build_julia(); another file:

import Interact, Blink
const i = Interact
const b = Blink
function run()
    w = b.Window();
    runModelButton = i.button("Run Model")
    stopModelButton = i.button("Stop")
    loadParButton = i.button("Load Parameters")
    loadProtocolButton = i.button("Load Protocol")
    saveParButton = i.button("Save Parameters")
    saveProtocolButton = i.button("SaveProtocol")
    ui = i.vbox(runModelButton, stopModelButton, loadParButton, loadProtocolButton,
            saveParButton, saveProtocolButton)
    wait(w.content)
    b.body!(w, ui);
end
run();

Compilation was successful, but sysimg generation resulted in error (using julia-debug v1.1.1):

compiling line 2806
done.
.
.
Creating sysimg

signal (11): Segmentation fault
in expression starting at no file:0
__strcmp_avx2 at /usr/lib/libc.so.6 (unknown line)
jl_compile_linfo at /home/kest/Projects/julia/src/codegen.cpp:1176
emit_invoke at /home/kest/Projects/julia/src/codegen.cpp:3145
emit_expr at /home/kest/Projects/julia/src/codegen.cpp:3948
emit_ssaval_assign at /home/kest/Projects/julia/src/codegen.cpp:3662
emit_stmtpos at /home/kest/Projects/julia/src/codegen.cpp:3854
emit_function at /home/kest/Projects/julia/src/codegen.cpp:6277
jl_compile_linfo at /home/kest/Projects/julia/src/codegen.cpp:1144
emit_invoke at /home/kest/Projects/julia/src/codegen.cpp:3145
emit_expr at /home/kest/Projects/julia/src/codegen.cpp:3948
emit_ssaval_assign at /home/kest/Projects/julia/src/codegen.cpp:3662
emit_stmtpos at /home/kest/Projects/julia/src/codegen.cpp:3854
emit_function at /home/kest/Projects/julia/src/codegen.cpp:6277
jl_compile_linfo at /home/kest/Projects/julia/src/codegen.cpp:1144
jl_compile_hint at /home/kest/Projects/julia/src/gf.c:1950
jl_compile_specializations at /home/kest/Projects/julia/src/precompile.c:378
jl_precompile at /home/kest/Projects/julia/src/precompile.c:387
jl_write_compiler_output at /home/kest/Projects/julia/src/precompile.c:34
jl_atexit_hook at /home/kest/Projects/julia/src/init.c:222
main at /home/kest/Projects/julia/ui/repl.c:218
__libc_start_main at /usr/lib/libc.so.6 (unknown line)
_start at /home/kest/Projects/julia/usr/bin/julia-debug (unknown line)
Allocations: 86146476 (Pool: 86119272; Big: 27204); GC: 196
ERROR: failed process: Process(`/home/kest/Projects/julia/usr/bin/julia-debug --optimize=3 --output-o=/home/kest/.julia/packages/PackageCompiler/CJQcs/sysimg/sys.a -g1 --track-allocation=none --startup-file=no --code-coverage=none --history-file=yes --inline=yes --math-mode=ieee --handle-signals=yes --warn-overwrite=no --compile=yes --depwarn=yes --cpu-target=native --track-allocation=none --sysimage-native-code=yes --sysimage=/home/kest/Projects/julia/usr/lib/julia/sys-debug.so -g2 --compiled-modules=yes --optimize=2 /home/kest/.julia/packages/PackageCompiler/CJQcs/sysimg/run_julia_code.jl`, ProcessSignaled(11)) [0]
Stacktrace:
 [1] error(::String, ::Base.Process, ::String, ::Int64, ::String) at ./error.jl:42
 [2] pipeline_error at ./process.jl:785 [inlined]
 [3] #run#515(::Bool, ::Function, ::Cmd) at ./process.jl:726
 [4] run at ./process.jl:724 [inlined]
 [5] #run_julia#1 at /home/kest/.julia/packages/PackageCompiler/CJQcs/src/compiler_flags.jl:225 [inlined]
 [6] #run_julia at ./none:0 [inlined]
 [7] #compile_incremental#62(::Bool, ::Bool, ::Bool, ::Nothing, ::Function, ::Nothing, ::String) at /home/kest/.julia/packages/PackageCompiler/CJQcs/src/incremental.jl:137
 [8] #compile_incremental at ./none:0 [inlined]
 [9] #brute_build_julia#5(::Bool, ::Bool, ::Function) at /home/kest/.julia/packages/Fezzik/Uvmuj/src/bootstrap.jl:209
 [10] brute_build_julia() at /home/kest/.julia/packages/Fezzik/Uvmuj/src/bootstrap.jl:82
 [11] top-level scope at none:0

Any comments?

@KestutisMa
Copy link
Author

KestutisMa commented Aug 3, 2019

I ran gdb on coredump file generated by the segfault. Here is backtrace:

Reading symbols from /home/kest/Projects/julia/usr/bin/julia-debug...
[New LWP 1191]
[New LWP 1192]
[New LWP 1202]
[New LWP 1203]
[New LWP 1204]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
Core was generated by `/home/kest/Projects/julia/usr/bin/julia-debug --optimize=3 --output-o=/home/kes'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007ffff778015e in __strcmp_avx2 () from /usr/lib/libc.so.6
[Current thread is 1 (Thread 0x7ffff46cc0c0 (LWP 1191))]
(gdb) bt
#0  0x00007ffff778015e in __strcmp_avx2 () from /usr/lib/libc.so.6
#1  0x00007ffff796c2eb in jl_compile_linfo (pli=0x7fffffffa030, src=0x7fffd7d1cb50, world=25663, 
    params=0x7ffff7c98ce0 <jl_default_cgparams>) at /home/kest/Projects/julia/src/codegen.cpp:1176
#2  0x00007ffff7992793 in emit_invoke (ctx=..., ex=0x7fffd7c7fcb0, rt=0x7fffe215df90)
    at /home/kest/Projects/julia/src/codegen.cpp:3145
#3  0x00007ffff7998276 in emit_expr (ctx=..., expr=0x7fffd7c7fcb0, ssaval=36)
    at /home/kest/Projects/julia/src/codegen.cpp:3948
#4  0x00007ffff799654b in emit_ssaval_assign (ctx=..., idx=36, r=0x7fffd7c7fcb0)
    at /home/kest/Projects/julia/src/codegen.cpp:3662
#5  0x00007ffff79979ed in emit_stmtpos (ctx=..., expr=0x7fffd7c7fcb0, ssaval_result=36)
    at /home/kest/Projects/julia/src/codegen.cpp:3854
#6  0x00007ffff79a88cd in emit_function (lam=0x7fffe808b8e0 <jl_system_image_data+13424096>, src=0x7fffd7d1ca60, 
    world=25663, declarations=0x7fffe808b940 <jl_system_image_data+13424192>, 
    params=0x7ffff7c98ce0 <jl_default_cgparams>) at /home/kest/Projects/julia/src/codegen.cpp:6277
#7  0x00007ffff796c066 in jl_compile_linfo (pli=0x7fffffffc020, src=0x7fffd7d1ca60, world=25663, 
    params=0x7ffff7c98ce0 <jl_default_cgparams>) at /home/kest/Projects/julia/src/codegen.cpp:1144
#8  0x00007ffff7992793 in emit_invoke (ctx=..., ex=0x7fffd7c7f870, 
    rt=0x7fffe7ae8c20 <jl_system_image_data+7514400>) at /home/kest/Projects/julia/src/codegen.cpp:3145
#9  0x00007ffff7998276 in emit_expr (ctx=..., expr=0x7fffd7c7f870, ssaval=18)
    at /home/kest/Projects/julia/src/codegen.cpp:3948
#10 0x00007ffff799654b in emit_ssaval_assign (ctx=..., idx=18, r=0x7fffd7c7f870)
    at /home/kest/Projects/julia/src/codegen.cpp:3662
#11 0x00007ffff79979ed in emit_stmtpos (ctx=..., expr=0x7fffd7c7f870, ssaval_result=18)
    at /home/kest/Projects/julia/src/codegen.cpp:3854
#12 0x00007ffff79a88cd in emit_function (lam=0x7fffe8087420 <jl_system_image_data+13406496>, src=0x7fffd7d1c9c0, world=25663, declarations=0x7fffe8087480 <jl_system_image_data+13406592>, params=0x7ffff7c98ce0 <jl_default_cgparams>) at /home/kest/Projects/julia/src/codegen.cpp:6277
#13 0x00007ffff796c066 in jl_compile_linfo (pli=0x7fffffffde28, src=0x7fffd7d1c9c0, world=25663, params=0x7ffff7c98ce0 <jl_default_cgparams>) at /home/kest/Projects/julia/src/codegen.cpp:1144
#14 0x00007ffff78a6e25 in jl_compile_hint (types=0x7fffe8087390 <jl_system_image_data+13406352>) at /home/kest/Projects/julia/src/gf.c:1950
#15 0x00007ffff79085db in jl_compile_specializations () at /home/kest/Projects/julia/src/precompile.c:378
#16 0x00007ffff7908644 in jl_precompile (all=0) at /home/kest/Projects/julia/src/precompile.c:387
#17 0x00007ffff7906ea9 in jl_write_compiler_output () at /home/kest/Projects/julia/src/precompile.c:34
#18 0x00007ffff78c2a89 in jl_atexit_hook (exitcode=0) at /home/kest/Projects/julia/src/init.c:222
#19 0x0000555555556d14 in main (argc=1, argv=0x7fffffffe4c0) at /home/kest/Projects/julia/ui/repl.c:218

@KestutisMa
Copy link
Author

I commented statement at line 1176 in codegen.cpp (julia v1.1.1) and that segfault are gone. Now Blink, Makie, Interact, JuMP and several other packages are compiling to sysimage without segfaults.

                // if (strcmp(f, "jl_fptr_args") && strcmp(f, "jl_fptr_sparam"))
                //     jl_add_linfo_in_flight(f, li, DL);

Error was because some pointers were not valid.
From context I think that line was for debug purposes. Maybe somebody could advice better solution?

@TsurHerman
Copy link
Owner

Thanks for the update, post it also on Julia main repo it will get more attention.

I will try you fix on my local build

@SimonDanisch
Copy link

There also seems to be a PR that should fix this: JuliaLang/julia#32776

@vtjnash
Copy link

vtjnash commented Aug 13, 2019

It'd be good to hear back too if that seems to work (I'm not sure all of the issues mentioned here are the same).

@KestutisMa
Copy link
Author

KestutisMa commented Aug 14, 2019

@vtjnash
using Blink; w = Window; Fezzik.brute_build_julia() is working, but I ran Julia second time, and:

   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.3.0-alpha.53 (2019-08-03)
 _/ |\__'_|_|_|\__'_|  |  jn/typemap-unsorting/e866576d12 (fork: 6 commits, 11 days)
|__/                   |

julia> using Interact

julia> ui = button()
fatal: error thrown and no exception handler available.
BoundsError(a=Array{Any, (0,)}[], i=(1,))
rec_backtrace at /home/kest/Projects/julia2/julia/src/stackwalk.c:94
jl_throw at /home/kest/Projects/julia2/julia/src/task.c:224
jl_bounds_error_ints at /home/kest/Projects/julia2/julia/src/rtutils.c:183
getindex at ./array.jl:742 [inlined]
_reformat_bt at ./error.jl:67
catch_backtrace at ./error.jl:91
task_done_hook at ./task.jl:318
jl_apply at /home/kest/Projects/julia2/julia/src/julia.h:1632 [inlined]
jl_finish_task at /home/kest/Projects/julia2/julia/src/task.c:181
start_task at /home/kest/Projects/julia2/julia/src/task.c:661

p.s. In my working version (Julia v1.1.1) I also removed all assertions (using bash command awk '/assert/ {$0="//"$0}1' ./codegen.cpp > codegen.cpp and some manual editing where it spreads over one line), since I also got BoundsError before. Now I don't get any error and Makie, Blink, Interact, JuMP seems working good. Compiling to sysimages is also working without error, I tried run Fezzik.brute_build_julia() several times on existing image.
I am using Interact#master.

@KestutisMa KestutisMa changed the title Segmentation fault trying to brute_build_julia() on: using Blink; w = Window() Segmentation fault trying to brute_build_julia() on: using Blink; w = Window() and several others Aug 14, 2019
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