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 @code_native on eltype #34434

Closed
sethaxen opened this issue Jan 19, 2020 · 4 comments · Fixed by #34458
Closed

Segfault calling @code_native on eltype #34434

sethaxen opened this issue Jan 19, 2020 · 4 comments · Fixed by #34458
Labels
regression Regression in behavior compared to a previous version

Comments

@sethaxen
Copy link
Contributor

@code_native segfaults when called on eltype in Julia 3.1. I've tested with numeric and array inputs:

julia> @code_native eltype(1)

signal (11): Segmentation fault: 11
in expression starting at REPL[3]:1
Twine at /Users/julia/buildbot/worker/package_macos64/build/usr/include/llvm/ADT/Twine.h:164 [inlined]
Twine at /Users/julia/buildbot/worker/package_macos64/build/usr/include/llvm/ADT/Twine.h:268 [inlined]
jl_get_llvmf_decl at /Users/julia/buildbot/worker/package_macos64/build/src/codegen.cpp:1662
_dump_function_linfo at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/InteractiveUtils/src/codeview.jl:100
_dump_function at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/InteractiveUtils/src/codeview.jl:84
_dump_function at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/InteractiveUtils/src/codeview.jl:71 [inlined]
#code_native#9 at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/InteractiveUtils/src/codeview.jl:148 [inlined]
#code_native at ./none:0
#code_native#10 at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/InteractiveUtils/src/codeview.jl:150
code_native at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/InteractiveUtils/src/codeview.jl:150
jl_apply at /Users/julia/buildbot/worker/package_macos64/build/src/./julia.h:1631 [inlined]
do_call at /Users/julia/buildbot/worker/package_macos64/build/src/interpreter.c:328
eval_body at /Users/julia/buildbot/worker/package_macos64/build/src/interpreter.c:0
jl_interpret_toplevel_thunk_callback at /Users/julia/buildbot/worker/package_macos64/build/src/interpreter.c:888
unknown function (ip: 0xfffffffffffffffe)
unknown function (ip: 0x11ceeee8f)
unknown function (ip: 0x0)
jl_interpret_toplevel_thunk at /Users/julia/buildbot/worker/package_macos64/build/src/interpreter.c:897
jl_toplevel_eval_flex at /Users/julia/buildbot/worker/package_macos64/build/src/toplevel.c:814
jl_toplevel_eval_flex at /Users/julia/buildbot/worker/package_macos64/build/src/toplevel.c:764
jl_toplevel_eval at /Users/julia/buildbot/worker/package_macos64/build/src/toplevel.c:823 [inlined]
jl_toplevel_eval_in at /Users/julia/buildbot/worker/package_macos64/build/src/toplevel.c:843
eval at ./boot.jl:330
eval_user_input at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/REPL/src/REPL.jl:86
macro expansion at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/REPL/src/REPL.jl:118 [inlined]
#26 at ./task.jl:333
jl_apply at /Users/julia/buildbot/worker/package_macos64/build/src/./julia.h:1631 [inlined]
start_task at /Users/julia/buildbot/worker/package_macos64/build/src/task.c:659
Allocations: 7344139 (Pool: 7342220; Big: 1919); GC: 8
Segmentation fault: 11

Version info:

julia> versioninfo()
Julia Version 1.3.1
Commit 2d5741174c (2019-12-30 21:36 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin18.6.0)
  CPU: Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, haswell)

(v1.3) pkg> st
    Status `~/.julia/environments/v1.3/Project.toml`
  [c52e3926] Atom v0.8.8
  [98e50ef6] JuliaFormatter v0.2.4
  [e5e0dc1b] Juno v0.7.2
@JeffBezanson
Copy link
Member

Looks like a regression in 1.3; works in 1.2 and prior.

@JeffBezanson JeffBezanson added the regression Regression in behavior compared to a previous version label Jan 19, 2020
@maleadt
Copy link
Member

maleadt commented Jan 20, 2020

Only seems to happen with the binaries? Fresh build (with no Make.user or other flags):

$ build/release/julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.3.1 (2019-12-30)
 _/ |\__'_|_|_|\__'_|  |  
|__/                   |

julia> @code_native eltype(1)
        .text
; ┌ @ array.jl:125 within `eltype'
        movabsq $jl_system_image_data, %rax
        retq
        nopl    (%rax,%rax)
; └

vs

$ build/binary-x64/julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.3.1 (2019-12-30)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> @code_native eltype(1)

signal (11): Segmentation fault

@Keno
Copy link
Member

Keno commented Jan 20, 2020

I'm thinking this change might fix it, but it'd be nice to have a test that fails properly on a source build:

diff --git a/src/codegen.cpp b/src/codegen.cpp
index 1d6e98dc8c..2a512f1b61 100644
--- a/src/codegen.cpp
+++ b/src/codegen.cpp
@@ -1636,6 +1636,7 @@ void *jl_get_llvmf_decl(jl_method_instance_t *mi, size_t world, bool getwrapper,
             if (codeinst == NULL)
                 // internal error
                 return NULL;
+            decls = codeinst->functionObjectsDecls;
         }
         JL_UNLOCK(&codegen_lock);
     }

@ararslan
Copy link
Member

Only seems to happen with the binaries?

Happens for me with a source build of current master on Linux, the only build customizations being -j8 USECCACHE=1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regression Regression in behavior compared to a previous version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants