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

LoopVectorization PackageCompiler'd into sysimage crashing #364

Closed
jaakkor2 opened this issue Nov 16, 2021 · 21 comments
Closed

LoopVectorization PackageCompiler'd into sysimage crashing #364

jaakkor2 opened this issue Nov 16, 2021 · 21 comments

Comments

@jaakkor2
Copy link
Contributor

jaakkor2 commented Nov 16, 2021

LoopVectorization compiled into sysimage like this

import PackageCompiler
@time PackageCompiler.create_sysimage(["LoopVectorization"], replace_default = true)

causes a crash when Octavian is loaded

julia> using Octavian

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 0x26adff3 -- jl_subtype_env at /cygdrive/c/buildbot/worker/package_win64/build/src\subtype.c:1851
in expression starting at C:\Users\jaakkor2\.julia\packages\Octavian\Rlmrt\src\forward_diff.jl:5
jl_subtype_env at /cygdrive/c/buildbot/worker/package_win64/build/src\subtype.c:1851
mulexpr at C:\Users\jaakkor2\.julia\packages\LoopVectorization\x4G96\src\vectorizationbase_compat\contract_pass.jl:16
jfptr_mulexpr_52733 at C:\Users\jaakkor2\AppData\Local\Programs\Julia-1.7.0-rc3\lib\julia\sys.dll (unknown line)
tojlinvoke64148 at C:\Users\jaakkor2\AppData\Local\Programs\Julia-1.7.0-rc3\lib\julia\sys.dll (unknown line)
j_mulexpr_52120 at C:\Users\jaakkor2\AppData\Local\Programs\Julia-1.7.0-rc3\lib\julia\sys.dll (unknown line)
recursive_muladd_search! at C:\Users\jaakkor2\.julia\packages\LoopVectorization\x4G96\src\vectorizationbase_compat\contract_pass.jl:107
recursive_muladd_search! at C:\Users\jaakkor2\.julia\packages\LoopVectorization\x4G96\src\vectorizationbase_compat\contract_pass.jl:79 [inlined]
capture_a_muladd at C:\Users\jaakkor2\.julia\packages\LoopVectorization\x4G96\src\vectorizationbase_compat\contract_pass.jl:162
capture_muladd at C:\Users\jaakkor2\.julia\packages\LoopVectorization\x4G96\src\vectorizationbase_compat\contract_pass.jl:207
tojlinvoke64273 at C:\Users\jaakkor2\AppData\Local\Programs\Julia-1.7.0-rc3\lib\julia\sys.dll (unknown line)
contract! at C:\Users\jaakkor2\.julia\packages\LoopVectorization\x4G96\src\vectorizationbase_compat\contract_pass.jl:245
contract_pass! at C:\Users\jaakkor2\.julia\packages\LoopVectorization\x4G96\src\vectorizationbase_compat\contract_pass.jl:258 [inlined]
contract! at C:\Users\jaakkor2\.julia\packages\LoopVectorization\x4G96\src\vectorizationbase_compat\contract_pass.jl:248
contract_pass! at C:\Users\jaakkor2\.julia\packages\LoopVectorization\x4G96\src\vectorizationbase_compat\contract_pass.jl:258 [inlined]
contract! at C:\Users\jaakkor2\.julia\packages\LoopVectorization\x4G96\src\vectorizationbase_compat\contract_pass.jl:248
contract_pass! at C:\Users\jaakkor2\.julia\packages\LoopVectorization\x4G96\src\vectorizationbase_compat\contract_pass.jl:258 [inlined]
contract! at C:\Users\jaakkor2\.julia\packages\LoopVectorization\x4G96\src\vectorizationbase_compat\contract_pass.jl:248
contract_pass! at C:\Users\jaakkor2\.julia\packages\LoopVectorization\x4G96\src\vectorizationbase_compat\contract_pass.jl:258 [inlined]
contract_pass! at C:\Users\jaakkor2\.julia\packages\LoopVectorization\x4G96\src\vectorizationbase_compat\contract_pass.jl:252 [inlined]
LoopSet at C:\Users\jaakkor2\.julia\packages\LoopVectorization\x4G96\src\constructors.jl:64
unknown function (ip: 000000005d02bd59)
Allocations: 2281108 (Pool: 2280105; Big: 1003); GC: 2

[process exited with code 1]

If I compile the sysimage with

import PackageCompiler
@time PackageCompiler.create_sysimage(["LoopVectorization", "Octavian"], replace_default = true)

Julia does not start at all.

Versions

  • Windows 10
  • Julia-1.7.0-rc3 (and Julia-1.7.0-rc2), but works ok with Julia-1.6.3
  • LoopVectorization v0.12.98
  • Octavian v0.3.8
  • PackageCompiler v1.7.7

I think this is a regression in LoopVectorization, this combination works

  • LoopVectorization v0.12.88
  • Octavian v0.3.5

Edit:

  • LoopVectorization v0.12.98, Octavian v0.3.5 works ok

Edit2:

  • LoopVectorization v0.12.98, Octavian v0.3.6 not ok
    Regression between Octavian v0.3.5 and v0.3.6.

cc: @KristofferC JuliaLang/PackageCompiler.jl#453

@chriselrod
Copy link
Member

I don't see anything particularly problematic in the diff between Octavian 0.3.5 and 0.3.6 compared to what's already there.

@jaakkor2
Copy link
Contributor Author

PackageCompiler option include_transitive_dependencies=false solves this for both PackageCompiler v1.7.7 and v2.0.2.

Tested with Julia v1.7.0-rc3, LoopVectorization v0.12.98, Octavian v0.3.8.

@jaakkor2
Copy link
Contributor Author

Reopening, this still fails

PackageCompiler.create_sysimage(["LoopVectorization","Octavian","OrdinaryDiffEq"], sysimage_path="sysimage_LV.so", include_transitive_dependencies=false)

with Julia v1.7.0-rc3, LoopVectorization v0.12.98, Octavian v0.3.8, both PackageCompiler v1.7.7 and v2.0.2.

PS C:\temp> C:\Users\jaakkor2\AppData\Local\Programs\Julia-1.7.0-rc3\bin\julia.exe --sysimage .\sysimage_LV.so

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 0x280dff3 -- jl_subtype_env at /cygdrive/c/buildbot/worker/package_win64/build/src\subtype.c:1851
in expression starting at C:\temp\depo\packages\Octavian\Rlmrt\src\forward_diff.jl:5
jl_subtype_env at /cygdrive/c/buildbot/worker/package_win64/build/src\subtype.c:1851
mulexpr at C:\temp\depo\packages\LoopVectorization\x4G96\src\vectorizationbase_compat\contract_pass.jl:16
jfptr_mulexpr_53233 at C:\temp\sysimage_LV.so (unknown line)
tojlinvoke66635 at C:\temp\sysimage_LV.so (unknown line)
j_mulexpr_52533 at C:\temp\sysimage_LV.so (unknown line)
recursive_muladd_search! at C:\temp\depo\packages\LoopVectorization\x4G96\src\vectorizationbase_compat\contract_pass.jl:107
recursive_muladd_search! at C:\temp\depo\packages\LoopVectorization\x4G96\src\vectorizationbase_compat\contract_pass.jl:79 [inlined]
capture_a_muladd at C:\temp\depo\packages\LoopVectorization\x4G96\src\vectorizationbase_compat\contract_pass.jl:162
capture_muladd at C:\temp\depo\packages\LoopVectorization\x4G96\src\vectorizationbase_compat\contract_pass.jl:207
tojlinvoke66827 at C:\temp\sysimage_LV.so (unknown line)
contract! at C:\temp\depo\packages\LoopVectorization\x4G96\src\vectorizationbase_compat\contract_pass.jl:245
contract_pass! at C:\temp\depo\packages\LoopVectorization\x4G96\src\vectorizationbase_compat\contract_pass.jl:258 [inlined]
contract! at C:\temp\depo\packages\LoopVectorization\x4G96\src\vectorizationbase_compat\contract_pass.jl:248
contract_pass! at C:\temp\depo\packages\LoopVectorization\x4G96\src\vectorizationbase_compat\contract_pass.jl:258 [inlined]
contract! at C:\temp\depo\packages\LoopVectorization\x4G96\src\vectorizationbase_compat\contract_pass.jl:248
contract_pass! at C:\temp\depo\packages\LoopVectorization\x4G96\src\vectorizationbase_compat\contract_pass.jl:258 [inlined]
contract! at C:\temp\depo\packages\LoopVectorization\x4G96\src\vectorizationbase_compat\contract_pass.jl:248
contract_pass! at C:\temp\depo\packages\LoopVectorization\x4G96\src\vectorizationbase_compat\contract_pass.jl:258 [inlined]
contract_pass! at C:\temp\depo\packages\LoopVectorization\x4G96\src\vectorizationbase_compat\contract_pass.jl:252 [inlined]
LoopSet at C:\temp\depo\packages\LoopVectorization\x4G96\src\constructors.jl:64
LoopSet at C:\temp\depo\packages\LoopVectorization\x4G96\src\constructors.jl:70
turbo_macro at C:\temp\depo\packages\LoopVectorization\x4G96\src\constructors.jl:121
jfptr_turbo_macro_53389 at C:\temp\sysimage_LV.so (unknown line)
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1788 [inlined]
do_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\builtins.c:713
@tturbo at C:\temp\depo\packages\LoopVectorization\x4G96\src\constructors.jl:234
jl_invoke_julia_macro at /cygdrive/c/buildbot/worker/package_win64/build/src\ast.c:1088
jl_expand_macros at /cygdrive/c/buildbot/worker/package_win64/build/src\ast.c:1144
jl_expand_macros at /cygdrive/c/buildbot/worker/package_win64/build/src\ast.c:1187
jl_expand_macros at /cygdrive/c/buildbot/worker/package_win64/build/src\ast.c:1187
jl_expand_macros at /cygdrive/c/buildbot/worker/package_win64/build/src\ast.c:1154
jl_expand_with_loc_warn at /cygdrive/c/buildbot/worker/package_win64/build/src\ast.c:1249
jl_toplevel_eval_flex at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:667
jl_toplevel_eval_flex at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:830
jl_toplevel_eval at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:894 [inlined]
jl_toplevel_eval_in at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:944
eval at .\boot.jl:373 [inlined]
include_string at .\loading.jl:1196
_include at .\loading.jl:1253
include at .\Base.jl:418
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1788 [inlined]
jl_f__call_latest at /cygdrive/c/buildbot/worker/package_win64/build/src\builtins.c:757
include at C:\temp\depo\packages\Octavian\Rlmrt\src\Octavian.jl:1
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1788 [inlined]
do_call at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:126
eval_value at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:215
eval_stmt_value at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:166 [inlined]
eval_body at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:583
jl_interpret_toplevel_thunk at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:731
jl_toplevel_eval_flex at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:885
jl_toplevel_eval at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:894 [inlined]
jl_toplevel_eval_in at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:944
eval at .\boot.jl:373 [inlined]
eval at C:\temp\depo\packages\Octavian\Rlmrt\src\Octavian.jl:1 [inlined]
#12 at C:\temp\depo\packages\Requires\7Ncym\src\require.jl:99
unknown function (ip: 000000005f202ed3)
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1788 [inlined]
do_call at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:126
eval_value at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:215
eval_stmt_value at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:166 [inlined]
eval_body at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:587
eval_body at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:516
jl_fptr_interpret_call at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:675
#11 at C:\temp\depo\packages\Requires\7Ncym\src\require.jl:98
unknown function (ip: 000000005f202e23)
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1788 [inlined]
do_call at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:126
eval_value at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:215
eval_body at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:461
eval_body at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:516
jl_fptr_interpret_call at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:675
#10 at C:\temp\depo\packages\Requires\7Ncym\src\require.jl:97
unknown function (ip: 000000005f202d93)
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1788 [inlined]
do_call at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:126
eval_value at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:215
eval_stmt_value at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:166 [inlined]
eval_body at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:587
jl_fptr_interpret_call at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:675
macro expansion at C:\temp\depo\packages\Requires\7Ncym\src\require.jl:95 [inlined]
__init__ at C:\temp\depo\packages\Octavian\Rlmrt\src\init.jl:2
jfptr___init___50899 at C:\temp\sysimage_LV.so (unknown line)
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1788 [inlined]
jl_module_run_initializer at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:73
_finish_julia_init at /cygdrive/c/buildbot/worker/package_win64/build/src\init.c:796
jl_repl_entrypoint at /cygdrive/c/buildbot/worker/package_win64/build/src\jlapi.c:695
mainCRTStartup at /cygdrive/c/buildbot/worker/package_win64/build/cli\loader_exe.c:42
BaseThreadInitThunk at C:\WINDOWS\System32\KERNEL32.DLL (unknown line)
RtlUserThreadStart at C:\WINDOWS\SYSTEM32\ntdll.dll (unknown line)
Allocations: 5112 (Pool: 5088; Big: 24); GC: 0

@jaakkor2 jaakkor2 reopened this Nov 17, 2021
@KristofferC
Copy link
Contributor

jl_subtype_env at /cygdrive/c/buildbot/worker/package_win64/build/src\subtype.c:1851

Could be a subtyping bug. Printing out the types in https://github.com/JuliaLang/julia/blob/0c2117396336fe471403f7ff9b4612a448e633a3/src/subtype.c#L1847 might help reduce this.

@jaakkor2
Copy link
Contributor Author

With LoopVectorization v0.12.98, OrdinaryDiffEq v5.67.0, Octavian v0.3.8, PackageCompiler v2.0.2.

PackageCompiler.create_sysimage(["LoopVectorization","Octavian","OrdinaryDiffEq"], sysimage_path="sysimage_LV.so", include_transitive_dependencies=false)

Some Julia versions crash during startup, some are fine

Julia version Verdict
1.6.3 ok
1.7.0-rc2 crash
1.7.0-rc3 crash
1.8.0-DEV.778 (2021-10-20) JuliaLang/julia@792c026 crash
1.8.0-DEV.779 (2021-10-20) JuliaLang/julia@6d0b192 ok

The issue seems more like a Julia issue, maybe it should be opened at https://github.com/JuliaLang/julia/issues ?

@jaakkor2
Copy link
Contributor Author

Version 1.7.0-rc3.9 (2021-11-16) refs/pull/43047/merge/36c5e22f07 (fork: 401 commits, 162 days) from PR JuliaLang/julia#43047 works as well.

@jaakkor2
Copy link
Contributor Author

With Julia v1.7.0 official binaries from https://julialang.org/downloads/ I can reproduce the crash with building the sysimage with

      Status `~/.julia/environments/v1.7/Project.toml`
  [6fd5a793] Octavian v0.3.10
  [9b87118b] PackageCompiler v2.0.3
PackageCompiler.create_sysimage(["Octavian"], sysimage_path="sysimg.so")

both on

Julia Version 1.7.0
Commit 3bf9d17731 (2021-11-30 12:12 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, skylake)

and same Windows machine running under WSL2

Julia Version 1.7.0
Commit 3bf9d17731 (2021-11-30 12:12 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, skylake)

but not on

Julia Version 1.7.0
Commit 3bf9d17731 (2021-11-30 12:12 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: AMD EPYC 7371 16-Core Processor
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, znver1)

If I remove the @inline-statement from line https://github.com/JuliaLinearAlgebra/Octavian.jl/blob/v0.3.10/src/forward_diff.jl#L5 , the sysimage works ok.

Some combination of packages compiled 10 days ago worked fine, but same packages with updated versions compiled today results in a crashing sysimage.

Under WSL2, compiling Julia https://github.com/JuliaLang/julia/tree/v1.7.0 and then compiling Octavian into sysimage does not crash.

Under WSL2, compiling Julia with export JULIA_CPU_TARGET="generic;sandybridge,-xsaveopt,clone_all;haswell,-rdrnd,base(1)"
can cause the sysimage with Octavian crash. Reading from https://docs.julialang.org/en/v1/devdocs/sysimg/#Specifying-multiple-system-image-targets, this should be how distributed binaries are built.

However, make debug build does not crash. So, I cannot use gdb?

Under WSL2, looks like hardware performance counters are not available, so I cannot use rr?

Could be a subtyping bug. Printing out the types in https://github.com/JuliaLang/julia/blob/0c2117396336fe471403f7ff9b4612a448e633a3/src/subtype.c#L1847 might help reduce this.

@KristofferC how would one do this in practice?

@chriselrod
Copy link
Member

chriselrod commented Dec 12, 2021

export JULIA_CPU_TARGET="generic;sandybridge,-xsaveopt,clone_all;haswell,-rdrnd,base(1)"

Out of curiosity, what is your host running?
On certain systems, it's possible for LoopVectorization to produce code that is invalid/will crash when you try to run it on others.
LoopVectorization just uses host information, not target information, when compiling. Therefore it is invalid when compiling for a target other than the host.
Are you planning on redistributing the system image, or will you only use it locally?

However, the fact that it apparently works in a debug build suggests this may not be the problem.

I'm (very) slowly working on being able to replace everything about how LV works.
I'm no longer maintaining any of the JuliaSIMD code, so things that don't work now won't be fixed until then.

I'd be happy to accept PRs that work around (or fix) the problem, if things like removing an @inline are able to get things into working state.

@jaakkor2
Copy link
Contributor Author

Goal is to be able to debug a Julia build that crashes when loading with a problematic sysimage. This crash happens with the official Julia binaries. I think ruling out a Julia bug is worth this effort, otherwise a workaround would be fine.

I could not make the build of Julia locally with make nor make debug to crash without defining the JULIA_CPU_TARGET-variable.

gcc -march=native -Q --help=target|grep march says skylake. LLVM: libLLVM-12.0.1 (ORCJIT, skylake) says skylake as well.

chriselrod pushed a commit to JuliaLinearAlgebra/Octavian.jl that referenced this issue Dec 28, 2021
…recompiled image (#127)

* Remove inline from forward_diff.jl to workaround startup crash with precompiled image

Workaround JuliaSIMD/LoopVectorization.jl#364

* Bump version
@jaakkor2
Copy link
Contributor Author

Fix in JuliaLinearAlgebra/Octavian.jl#127 is not effective anymore.

With PackageCompiler v2.0.4, OrdinaryDiffEq v6.4.1, Octavian v0.3.11,

import PackageCompiler
PackageCompiler.create_sysimage([:OrdinaryDiffEq], sysimage_path="sysimageODE.dll")

and then using Octavian as shown below crashes. Help to debug further would be appreciated.

> julia --startup-file=no -J .\sysimageODE.dll
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.7.1 (2021-12-22)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> versioninfo()
Julia Version 1.7.1
Commit ac5cc99908 (2021-12-22 19:35 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, skylake)

julia> using Octavian

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 0x270d2f3 -- jl_subtype_env at /cygdrive/c/buildbot/worker/package_win64/build/src\subtype.c:1851
in expression starting at C:\Users\jaakkor2\.julia\packages\Octavian\yJ7wF\src\forward_diff.jl:5
jl_subtype_env at /cygdrive/c/buildbot/worker/package_win64/build/src\subtype.c:1851
mulexpr at C:\Users\jaakkor2\.julia\packages\LoopVectorization\ndGJi\src\vectorizationbase_compat\contract_pass.jl:16
jfptr_mulexpr_53200 at C:\Users\jaakkor2\sysimageODE.dll (unknown line)
tojlinvoke66272 at C:\Users\jaakkor2\sysimageODE.dll (unknown line)
j_mulexpr_52212 at C:\Users\jaakkor2\sysimageODE.dll (unknown line)
recursive_muladd_search! at C:\Users\jaakkor2\.julia\packages\LoopVectorization\ndGJi\src\vectorizationbase_compat\contract_pass.jl:107
recursive_muladd_search! at C:\Users\jaakkor2\.julia\packages\LoopVectorization\ndGJi\src\vectorizationbase_compat\contract_pass.jl:79 [inlined]
capture_a_muladd at C:\Users\jaakkor2\.julia\packages\LoopVectorization\ndGJi\src\vectorizationbase_compat\contract_pass.jl:162
capture_muladd at C:\Users\jaakkor2\.julia\packages\LoopVectorization\ndGJi\src\vectorizationbase_compat\contract_pass.jl:207
tojlinvoke65752 at C:\Users\jaakkor2\sysimageODE.dll (unknown line)
contract! at C:\Users\jaakkor2\.julia\packages\LoopVectorization\ndGJi\src\vectorizationbase_compat\contract_pass.jl:245
contract_pass! at C:\Users\jaakkor2\.julia\packages\LoopVectorization\ndGJi\src\vectorizationbase_compat\contract_pass.jl:258 [inlined]
contract! at C:\Users\jaakkor2\.julia\packages\LoopVectorization\ndGJi\src\vectorizationbase_compat\contract_pass.jl:248
contract_pass! at C:\Users\jaakkor2\.julia\packages\LoopVectorization\ndGJi\src\vectorizationbase_compat\contract_pass.jl:258 [inlined]
contract! at C:\Users\jaakkor2\.julia\packages\LoopVectorization\ndGJi\src\vectorizationbase_compat\contract_pass.jl:248
contract_pass! at C:\Users\jaakkor2\.julia\packages\LoopVectorization\ndGJi\src\vectorizationbase_compat\contract_pass.jl:258 [inlined]
contract! at C:\Users\jaakkor2\.julia\packages\LoopVectorization\ndGJi\src\vectorizationbase_compat\contract_pass.jl:248
contract_pass! at C:\Users\jaakkor2\.julia\packages\LoopVectorization\ndGJi\src\vectorizationbase_compat\contract_pass.jl:258 [inlined]
contract_pass! at C:\Users\jaakkor2\.julia\packages\LoopVectorization\ndGJi\src\vectorizationbase_compat\contract_pass.jl:252 [inlined]
LoopSet at C:\Users\jaakkor2\.julia\packages\LoopVectorization\ndGJi\src\constructors.jl:64
LoopSet at C:\Users\jaakkor2\.julia\packages\LoopVectorization\ndGJi\src\constructors.jl:70
turbo_macro at C:\Users\jaakkor2\.julia\packages\LoopVectorization\ndGJi\src\constructors.jl:121
jfptr_turbo_macro_53164 at C:\Users\jaakkor2\sysimageODE.dll (unknown line)
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1788 [inlined]
do_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\builtins.c:713
@tturbo at C:\Users\jaakkor2\.julia\packages\LoopVectorization\ndGJi\src\constructors.jl:234
jl_invoke_julia_macro at /cygdrive/c/buildbot/worker/package_win64/build/src\ast.c:1088
jl_expand_macros at /cygdrive/c/buildbot/worker/package_win64/build/src\ast.c:1144
jl_expand_macros at /cygdrive/c/buildbot/worker/package_win64/build/src\ast.c:1187
jl_expand_macros at /cygdrive/c/buildbot/worker/package_win64/build/src\ast.c:1187
jl_expand_with_loc_warn at /cygdrive/c/buildbot/worker/package_win64/build/src\ast.c:1249
jl_toplevel_eval_flex at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:667
jl_toplevel_eval_flex at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:830
jl_toplevel_eval at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:894 [inlined]
jl_toplevel_eval_in at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:944
eval at .\boot.jl:373 [inlined]
include_string at .\loading.jl:1196
_include at .\loading.jl:1253
include at .\Base.jl:418
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1788 [inlined]
jl_f__call_latest at /cygdrive/c/buildbot/worker/package_win64/build/src\builtins.c:757
include at C:\Users\jaakkor2\.julia\packages\Octavian\yJ7wF\src\Octavian.jl:1
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1788 [inlined]
do_call at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:126
eval_value at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:215
eval_stmt_value at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:166 [inlined]
eval_body at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:583
jl_interpret_toplevel_thunk at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:731
jl_toplevel_eval_flex at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:885
jl_toplevel_eval at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:894 [inlined]
jl_toplevel_eval_in at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:944
eval at .\boot.jl:373 [inlined]
eval at C:\Users\jaakkor2\.julia\packages\Octavian\yJ7wF\src\Octavian.jl:1 [inlined]
#12 at C:\Users\jaakkor2\.julia\packages\Requires\Z8rfN\src\require.jl:101
unknown function (ip: 000000005f299923)
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1788 [inlined]
do_call at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:126
eval_value at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:215
eval_body at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:461
eval_body at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:516
jl_fptr_interpret_call at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:675
#11 at C:\Users\jaakkor2\.julia\packages\Requires\Z8rfN\src\require.jl:100
unknown function (ip: 000000005f299873)
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1788 [inlined]
do_call at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:126
eval_value at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:215
eval_body at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:461
eval_body at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:516
jl_fptr_interpret_call at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:675
#10 at C:\Users\jaakkor2\.julia\packages\Requires\Z8rfN\src\require.jl:99
unknown function (ip: 000000005f2997e3)
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1788 [inlined]
do_call at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:126
eval_value at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:215
eval_stmt_value at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:166 [inlined]
eval_body at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:587
jl_fptr_interpret_call at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:675
macro expansion at C:\Users\jaakkor2\.julia\packages\Requires\Z8rfN\src\require.jl:98 [inlined]
__init__ at C:\Users\jaakkor2\.julia\packages\Octavian\yJ7wF\src\init.jl:2
unknown function (ip: 000000005f2996d3)
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1788 [inlined]
jl_module_run_initializer at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:73
jl_init_restored_modules at /cygdrive/c/buildbot/worker/package_win64/build/src\dump.c:2215
_include_from_serialized at .\loading.jl:768
_require_search_from_serialized at .\loading.jl:854
_require at .\loading.jl:1097
require at .\loading.jl:1013
require at .\loading.jl:997
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1788 [inlined]
call_require at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:426 [inlined]
eval_import_path at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:463
jl_toplevel_eval_flex at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:689
jl_toplevel_eval_flex at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:830
jl_toplevel_eval at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:894 [inlined]
jl_toplevel_eval_in at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:944
eval at .\boot.jl:373 [inlined]
eval_user_input at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.7\REPL\src\REPL.jl:150
repl_backend_loop at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.7\REPL\src\REPL.jl:244
start_repl_backend at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.7\REPL\src\REPL.jl:229
#run_repl#47 at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.7\REPL\src\REPL.jl:362
run_repl at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.7\REPL\src\REPL.jl:349
#930 at .\client.jl:394
jfptr_YY.930_26863 at C:\Users\jaakkor2\sysimageODE.dll (unknown line)
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1788 [inlined]
jl_f__call_latest at /cygdrive/c/buildbot/worker/package_win64/build/src\builtins.c:757
#invokelatest#2 at .\essentials.jl:716 [inlined]
invokelatest at .\essentials.jl:714 [inlined]
run_main_repl at .\client.jl:379
exec_options at .\client.jl:309
_start at .\client.jl:495
jfptr__start_38877 at C:\Users\jaakkor2\sysimageODE.dll (unknown line)
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1788 [inlined]
true_main at /cygdrive/c/buildbot/worker/package_win64/build/src\jlapi.c:559
jl_repl_entrypoint at /cygdrive/c/buildbot/worker/package_win64/build/src\jlapi.c:701
mainCRTStartup at /cygdrive/c/buildbot/worker/package_win64/build/cli\loader_exe.c:42
BaseThreadInitThunk at C:\WINDOWS\System32\KERNEL32.DLL (unknown line)
RtlUserThreadStart at C:\WINDOWS\SYSTEM32\ntdll.dll (unknown line)
Allocations: 4839254 (Pool: 4837397; Big: 1857); GC: 5

@jaakkor2
Copy link
Contributor Author

Smaller example that drops Octavian and OrdinaryDiffEq out of the problem.

With PackageCompiler v2.0.4, LoopVectorization v0.12.101

import PackageCompiler
PackageCompiler.create_sysimage([:LoopVectorization], sysimage_path="sysimageLV.dll")

Taking function from Octavian https://github.com/JuliaLinearAlgebra/Octavian.jl/blob/v0.3.11/src/macrokernels.jl#L83-L92

> julia --startup-file=no -J .\sysimageLV.dll
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.7.1 (2021-12-22)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> versioninfo()
Julia Version 1.7.1
Commit ac5cc99908 (2021-12-22 19:35 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, skylake)

julia> using LoopVectorization: @turbo, CloseOpen

julia> @inline function loopmul!(C, A, B, α, β, M, K, N)
           @turbo for n ∈ CloseOpen(N), m ∈ CloseOpen(M)
               Cₘₙ = zero(eltype(C))
                       for k ∈ CloseOpen(K)
                   Cₘₙ += A[m,k] * B[k,n]
               end
               C[m,n] = α * Cₘₙ + β * C[m,n]
           end
           nothing
       end

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 0x270d2f3 -- jl_subtype_env at /cygdrive/c/buildbot/worker/package_win64/build/src\subtype.c:1851
in expression starting at REPL[3]:1
jl_subtype_env at /cygdrive/c/buildbot/worker/package_win64/build/src\subtype.c:1851
mulexpr at C:\Users\jaakkor2\.julia\packages\LoopVectorization\ndGJi\src\vectorizationbase_compat\contract_pass.jl:16
jfptr_mulexpr_52161 at C:\Users\jaakkor2\sysimageLV.dll (unknown line)
tojlinvoke64319 at C:\Users\jaakkor2\sysimageLV.dll (unknown line)
j_mulexpr_51716 at C:\Users\jaakkor2\sysimageLV.dll (unknown line)
recursive_muladd_search! at C:\Users\jaakkor2\.julia\packages\LoopVectorization\ndGJi\src\vectorizationbase_compat\contract_pass.jl:107
recursive_muladd_search! at C:\Users\jaakkor2\.julia\packages\LoopVectorization\ndGJi\src\vectorizationbase_compat\contract_pass.jl:79 [inlined]
capture_a_muladd at C:\Users\jaakkor2\.julia\packages\LoopVectorization\ndGJi\src\vectorizationbase_compat\contract_pass.jl:162
capture_muladd at C:\Users\jaakkor2\.julia\packages\LoopVectorization\ndGJi\src\vectorizationbase_compat\contract_pass.jl:207
tojlinvoke64169 at C:\Users\jaakkor2\sysimageLV.dll (unknown line)
contract! at C:\Users\jaakkor2\.julia\packages\LoopVectorization\ndGJi\src\vectorizationbase_compat\contract_pass.jl:245
contract_pass! at C:\Users\jaakkor2\.julia\packages\LoopVectorization\ndGJi\src\vectorizationbase_compat\contract_pass.jl:258 [inlined]
contract! at C:\Users\jaakkor2\.julia\packages\LoopVectorization\ndGJi\src\vectorizationbase_compat\contract_pass.jl:248
contract_pass! at C:\Users\jaakkor2\.julia\packages\LoopVectorization\ndGJi\src\vectorizationbase_compat\contract_pass.jl:258 [inlined]
contract! at C:\Users\jaakkor2\.julia\packages\LoopVectorization\ndGJi\src\vectorizationbase_compat\contract_pass.jl:248
contract_pass! at C:\Users\jaakkor2\.julia\packages\LoopVectorization\ndGJi\src\vectorizationbase_compat\contract_pass.jl:258 [inlined]
contract! at C:\Users\jaakkor2\.julia\packages\LoopVectorization\ndGJi\src\vectorizationbase_compat\contract_pass.jl:248
contract_pass! at C:\Users\jaakkor2\.julia\packages\LoopVectorization\ndGJi\src\vectorizationbase_compat\contract_pass.jl:258 [inlined]
contract_pass! at C:\Users\jaakkor2\.julia\packages\LoopVectorization\ndGJi\src\vectorizationbase_compat\contract_pass.jl:252 [inlined]
LoopSet at C:\Users\jaakkor2\.julia\packages\LoopVectorization\ndGJi\src\constructors.jl:64
LoopSet at C:\Users\jaakkor2\.julia\packages\LoopVectorization\ndGJi\src\constructors.jl:70
turbo_macro at C:\Users\jaakkor2\.julia\packages\LoopVectorization\ndGJi\src\constructors.jl:121
jfptr_turbo_macro_51513 at C:\Users\jaakkor2\sysimageLV.dll (unknown line)
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1788 [inlined]
do_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\builtins.c:713
@turbo at C:\Users\jaakkor2\.julia\packages\LoopVectorization\ndGJi\src\constructors.jl:223
jl_invoke_julia_macro at /cygdrive/c/buildbot/worker/package_win64/build/src\ast.c:1088
jl_expand_macros at /cygdrive/c/buildbot/worker/package_win64/build/src\ast.c:1144
jl_expand_macros at /cygdrive/c/buildbot/worker/package_win64/build/src\ast.c:1187
jl_expand_macros at /cygdrive/c/buildbot/worker/package_win64/build/src\ast.c:1187
jl_expand_macros at /cygdrive/c/buildbot/worker/package_win64/build/src\ast.c:1154
jl_expand_macros at /cygdrive/c/buildbot/worker/package_win64/build/src\ast.c:1187
jl_expand_with_loc_warn at /cygdrive/c/buildbot/worker/package_win64/build/src\ast.c:1249
jl_toplevel_eval_flex at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:667
jl_toplevel_eval_flex at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:830
jl_toplevel_eval at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:894 [inlined]
jl_toplevel_eval_in at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:944
eval at .\boot.jl:373 [inlined]
eval_user_input at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.7\REPL\src\REPL.jl:150
repl_backend_loop at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.7\REPL\src\REPL.jl:244
start_repl_backend at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.7\REPL\src\REPL.jl:229
#run_repl#47 at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.7\REPL\src\REPL.jl:362
run_repl at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.7\REPL\src\REPL.jl:349
#930 at .\client.jl:394
jfptr_YY.930_36895 at C:\Users\jaakkor2\sysimageLV.dll (unknown line)
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1788 [inlined]
jl_f__call_latest at /cygdrive/c/buildbot/worker/package_win64/build/src\builtins.c:757
#invokelatest#2 at .\essentials.jl:716 [inlined]
invokelatest at .\essentials.jl:714 [inlined]
run_main_repl at .\client.jl:379
exec_options at .\client.jl:309
_start at .\client.jl:495
jfptr__start_24323 at C:\Users\jaakkor2\sysimageLV.dll (unknown line)
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1788 [inlined]
true_main at /cygdrive/c/buildbot/worker/package_win64/build/src\jlapi.c:559
jl_repl_entrypoint at /cygdrive/c/buildbot/worker/package_win64/build/src\jlapi.c:701
mainCRTStartup at /cygdrive/c/buildbot/worker/package_win64/build/cli\loader_exe.c:42
BaseThreadInitThunk at C:\WINDOWS\System32\KERNEL32.DLL (unknown line)
RtlUserThreadStart at C:\WINDOWS\SYSTEM32\ntdll.dll (unknown line)
Allocations: 4052535 (Pool: 4051118; Big: 1417); GC: 5

@chriselrod
Copy link
Member

Thanks for getting a more minimal reproducer.

@jaakkor2
Copy link
Contributor Author

I can now create the crash on AMD EPYC 7371 on Linux as well, so there is hope I could get rr running in that machine, but I am not an admin there.

@sloede
Copy link

sloede commented Mar 30, 2022

Are there any updates on this issue? We are trying to use PackageCompiler.jl to reduce startup times for parallel simulations of Trixi.jl. However, after creating a sysimage, Julia crashes on startup with the same error as shown above. Using @jaakkor2's example from above, I am able to reproduce the error also by just baking LoopVectorization.jl into the sysimage.

My system (if it helps):

julia> versioninfo()
Julia Version 1.7.2
Commit bf53498635 (2022-02-06 15:21 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: AMD Ryzen Threadripper 3990X 64-Core Processor
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, znver2)

Is there anything we can do to assist in debugging? I do have admin rights on said machine...

CC @ranocha

@sloede
Copy link

sloede commented Mar 30, 2022

FWIW, I seem to have been able to create an rr trace using --bug-report=rr-local (if that is of any help). Unfortunately, I am not in a position to do anything with it 😬, but I am happy to share.

@sloede
Copy link

sloede commented Apr 1, 2022

Interestingly, I managed to create a sysimage with LoopVectorization as an indirect dependency and that didn't crash. Is that weird or is it weird?

I basically took the same script I used before, except that I manually copied all dependencies from the Project.toml and removed :LoopVectorization.

@sloede
Copy link

sloede commented Nov 30, 2022

Small update: I am not able to reproduce this issue using the MWE from @jaakkor2 above anymore, with Julia v1.7.2, LoopVectorization v0.12.101, and PackageCompiler v2.0.4 and using the same machine as before. Unfortunately, I do not have the Manifest from back then - is it possible that this was automagically fixed by an updated dependency of PC or LV? Or are others still able to reproduce this?

@chriselrod
Copy link
Member

Small update: I am not able to reproduce this issue using the MWE from @jaakkor2 above anymore, with Julia v1.7.2, LoopVectorization v0.12.101, and PackageCompiler v2.0.4 and using the same machine as before. Unfortunately, I do not have the Manifest from back then - is it possible that this was automagically fixed by an updated dependency of PC or LV? Or are others still able to reproduce this?

I tried to fix this by having HostCPUFeatures check Julia's target, and update if not native: JuliaSIMD/HostCPUFeatures.jl@2bdb3df
I didn't try it, but someone on Slack did and told me it didn't help, so I didn't bother reporting it here.

Maybe it did actually help?

@jaakkor2
Copy link
Contributor Author

jaakkor2 commented Dec 1, 2022

I haven't seen this issue for months. I now tried with Julia 1.8.2/1.8.3 Linux/Windows, and the MWE above did not reproduce. The issue used to be stochastic, depending on the set of packages and their versions that were precompiled into the image.

@chriselrod
Copy link
Member

chriselrod commented Dec 1, 2022

FWIW, I work for PumasAI, and we build sysimages (that include LoopVectorization, an indirect dependency) for customers. I don't work on building the images, but AFAIK it never really caused problems there, and the list of dependencies is rather large (including OrdinaryDiffEq and many other packages).

@jaakkor2
Copy link
Contributor Author

jaakkor2 commented Apr 5, 2024

Retested quickly with Julia v1.10.2, LoopVectorization v0.12.169, Octavian v0.3.27, OrdinaryDiffEq v6.74.1, and I could not reproduce this issue anymore. Closing the issue.

@jaakkor2 jaakkor2 closed this as completed Apr 5, 2024
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