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

assertion failure at codegen.cpp:1021 #14735

Closed
JeffBezanson opened this issue Jan 20, 2016 · 4 comments
Closed

assertion failure at codegen.cpp:1021 #14735

JeffBezanson opened this issue Jan 20, 2016 · 4 comments
Labels
bug Indicates an unexpected problem or unintended behavior compiler:codegen Generation of LLVM IR and native code regression Regression in behavior compared to a previous version

Comments

@JeffBezanson
Copy link
Sponsor Member

Found this while looking into package failures on jb/functions, and it also seems to affect master with LLVM 3.7. For example when running Pkg.test("SymPy"):

julia: /home/jeff/src/julia-master/julia/src/codegen.cpp:1021: uint64_t getAddressForOrCompileFunction(llvm::Function*): Assertion `addr != 0' failed.
ERROR: LoadError: LoadError: Failed to precompile SymPy to /home/jeff/.julia/lib/v0.5/SymPy.ji

I get the same assertion failure with PyPlot and ShapeModels.

@JeffBezanson JeffBezanson added bug Indicates an unexpected problem or unintended behavior compiler:codegen Generation of LLVM IR and native code labels Jan 20, 2016
@ihnorton
Copy link
Member

All of these are caused by PyCall. Backtrace on the precompile worker:

(lldb) bt
* thread #1: tid = 0x10c4c88, 0x0000000101274c30 libLLVM-3.9svn.dylib`abort + 32, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
  * frame #0: 0x0000000101274c30 libLLVM-3.9svn.dylib`abort + 32
    frame #1: 0x0000000101274c01 libLLVM-3.9svn.dylib`__assert_rtn + 81
    frame #2: 0x000000010008be61 libjulia-debug.dylib`getAddressForOrCompileFunction(llvmf=0x000000031327cc48) + 641 at codegen.cpp:1021
    frame #3: 0x000000010008c78e libjulia-debug.dylib`::jl_function_ptr(f=0x000000010a9e2a10, rt=0x000000010a12f6d0, argt=0x000000010b0e7490) + 382 at codegen.cpp:1209
    frame #4: 0x00000003138694cd JIT(0x308005030)`julia_call_27071 + 573
    frame #5: 0x000000031385c320 JIT(0x308005030)`julia_make_io_methods_27057 + 480
    frame #6: 0x0000000313859309 JIT(0x308005030)`julia___init___26570 + 4841
    frame #7: 0x0000000313858010 JIT(0x308005030)`jlcall___init___26570 + 16
    frame #8: 0x000000010002dcf0 libjulia-debug.dylib`jl_apply(f=0x000000010a993dd0, args=0x0000000000000000, nargs=0) + 64 at julia.h:1391
    frame #9: 0x000000010003068c libjulia-debug.dylib`jl_trampoline(F=0x000000010a993dd0, args=0x0000000000000000, nargs=0) + 220 at builtins.c:1036
    frame #10: 0x000000010001a7e0 libjulia-debug.dylib`jl_apply(f=0x000000010a993dd0, args=0x0000000000000000, nargs=0) + 64 at julia.h:1391
    frame #11: 0x000000010001d56d libjulia-debug.dylib`jl_apply_generic(F=0x000000010a990e50, args=0x0000000000000000, nargs=0) + 541 at gf.c:1922
    frame #12: 0x0000000100037990 libjulia-debug.dylib`jl_apply(f=0x000000010a990e50, args=0x0000000000000000, nargs=0) + 64 at julia.h:1391
    frame #13: 0x000000010003788a libjulia-debug.dylib`jl_module_run_initializer(m=0x000000010b0c9d50) + 154 at module.c:625
    frame #14: 0x000000010004c966 libjulia-debug.dylib`jl_init_restored_modules(init_order=0x0000000109fd9690) + 102 at dump.c:1764
    frame #15: 0x0000000100051333 libjulia-debug.dylib`_jl_restore_incremental(f=0x00007fff5fbfcd20) + 1395 at dump.c:2265
    frame #16: 0x0000000100051424 libjulia-debug.dylib`jl_restore_incremental(fname="/Users/inorton/.julia/lib/v0.5/PyCall.ji") + 164 at dump.c:2289

(full backtrace)

Stepping through, the outer method has a null linfo:

(lldb) f 3
frame #3: 0x000000010008c78e libjulia-debug.dylib`::jl_function_ptr(f=0x000000010a9e2a10, rt=0x000000010a12f6d0, argt=0x000000010b0e7490) + 382 at codegen.cpp:1209
   1206     JL_GC_POP();
   1207
   1208 #ifdef USE_MCJIT
-> 1209     if (uint64_t addr = getAddressForOrCompileFunction(llvmf))
   1210         return (void*)(intptr_t)addr;
   1211     if (llvmf->getParent() == shadow_module) {
   1212         // Copy the function out of the shadow module
(lldb) p llvmf->getName()
(llvm::StringRef) $11 = (Data = "jlcapi_jl_IO_close_27276", Length = 24)
(lldb) p f->linfo
(jl_lambda_info_t *) $12 = 0x0000000000000000

Stepping through jl_cfunction_object, it looks like the specialization has a function object attached:

(lldb) f
frame #0: 0x00000001000badd2 libjulia-debug.dylib`gen_cfun_wrapper(ff=0x000000010a9e2a90, jlrettype=0x000000010a12f6d0, argt=0x000000010b0e7490, isref=0) + 210 at codegen.cpp:4091
   4088         size_t i;
   4089         for (i = 0; i < list->len; i++) {
   4090             if (list->data()[i].isref == isref) {
-> 4091                 return list->data()[i].f;
   4092             }
   4093         }
   4094     }

but when we look up the function, there is no symbol associated with the name:

(lldb) fin
Process 34374 stopped
* thread #1: tid = 0x10c4c88, 0x00000001000b563f libjulia-debug.dylib`llvm::orc::IRCompileLayer<llvm::orc::ObjectLinkingLayer<(anonymous namespace)::DebugObjectRegistrar> >::findSymbol(this=0x000000010311c0e0, Name=0x00007fff5fbfbc18, ExportedSymbolsOnly=false) + 687 at IRCompileLayer.h:99, queue = 'com.apple.main-thread', stop reason = step out
Return value: (llvm::orc::JITSymbol) $73 = {
  llvm::JITSymbolBase = (Flags = None)
  GetAddress = {
    __buf_ = (__lx = unsigned char [24] @ 0x00007fe68c68b920)
    __f_ = 0x0000000000000000
  }
  CachedAddr = 0
}

    frame #0: 0x00000001000b563f libjulia-debug.dylib`llvm::orc::IRCompileLayer<llvm::orc::ObjectLinkingLayer<(anonymous namespace)::DebugObjectRegistrar> >::findSymbol(this=0x000000010311c0e0, Name=0x00007fff5fbfbc18, ExportedSymbolsOnly=false) + 687 at IRCompileLayer.h:99
   96     /// @param ExportedSymbolsOnly If true, search only for exported symbols.
   97     /// @return A handle for the given named symbol, if it exists.
   98     JITSymbol findSymbol(const std::string &Name, bool ExportedSymbolsOnly) {
-> 99       return BaseLayer.findSymbol(Name, ExportedSymbolsOnly);
   100    }
   101
   102    /// @brief Get the address of the given symbol in the context of the set of
(lldb) bt 10
* thread #1: tid = 0x10c4c88, 0x00000001000b563f libjulia-debug.dylib`llvm::orc::IRCompileLayer<llvm::orc::ObjectLinkingLayer<(anonymous namespace)::DebugObjectRegistrar> >::findSymbol(this=0x000000010311c0e0, Name=0x00007fff5fbfbc18, ExportedSymbolsOnly=false) + 687 at IRCompileLayer.h:99, queue = 'com.apple.main-thread', stop reason = step out
Return value: (llvm::orc::JITSymbol) $73 = {
  llvm::JITSymbolBase = (Flags = None)
  GetAddress = {
    __buf_ = (__lx = unsigned char [24] @ 0x00007fe68c68b920)
    __f_ = 0x0000000000000000
  }
  CachedAddr = 0
}

  * frame #0: 0x00000001000b563f libjulia-debug.dylib`llvm::orc::IRCompileLayer<llvm::orc::ObjectLinkingLayer<(anonymous namespace)::DebugObjectRegistrar> >::findSymbol(this=0x000000010311c0e0, Name=0x00007fff5fbfbc18, ExportedSymbolsOnly=false) + 687 at IRCompileLayer.h:99
    frame #1: 0x000000010008bb92 libjulia-debug.dylib`(anonymous namespace)::JuliaOJIT::getFunctionAddress(this=0x000000010381b000, Name=0x00007fff5fbfbd40) + 146 at jitlayers.cpp:364
    frame #2: 0x000000010008be10 libjulia-debug.dylib`getAddressForOrCompileFunction(llvmf=0x000000031327cc48) + 560 at codegen.cpp:1020
    frame #3: 0x00000003146c564f $__lldb_expr`$__lldb_expr($__lldb_arg=0x00000003146440d0) + 95 at lldb-5fa1c1.expr:43
    frame #4: 0x0000000100000eb0 julia-debug`_mh_execute_header + 3760
    frame #5: 0x0000000100000eb0 julia-debug`_mh_execute_header + 3760
    frame #6: 0x0000000101274c01 libLLVM-3.9svn.dylib`__assert_rtn + 81
    frame #7: 0x000000010008be61 libjulia-debug.dylib`getAddressForOrCompileFunction(llvmf=0x000000031327cc48) + 641 at codegen.cpp:1021
    frame #8: 0x000000010008c78e libjulia-debug.dylib`::jl_function_ptr(f=0x000000010a9e2a10, rt=0x000000010a12f6d0, argt=0x000000010b0e7490) + 382 at codegen.cpp:1209
    frame #9: 0x00000003138694cd JIT(0x308005030)`julia_call_27071 + 573

(note that this jl_IO_close function is precompiled here.)

@JeffBezanson JeffBezanson added the regression Regression in behavior compared to a previous version label Jan 26, 2016
@stevengj
Copy link
Member

stevengj commented Feb 4, 2016

Is this only on Linux? PyCall master works fine for me with Julia master on MacOS X.

@perrinmeyer
Copy link

i'm trying to build PyPlot on a samsung chromebook2 / arm / crouton trusty (14). Related? thanks

               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.5.0-dev+3000 (2016-03-04 04:34 UTC)
 _/ |\__'_|_|_|\__'_|  |  Commit ca6f253 (0 days old master)
|__/                   |  arm-linux-gnueabihf

julia> Pkg.build("PyPlot")
INFO: Building PyCall
INFO: Recompiling stale cache file /home/perrin/.julia/lib/v0.5/Compat.ji for module Compat.
INFO: Recompiling stale cache file /home/perrin/.julia/lib/v0.5/Conda.ji for module Conda.
INFO: Recompiling stale cache file /home/perrin/.julia/lib/v0.5/JSON.ji for module JSON.
INFO: Recompiling stale cache file /home/perrin/.julia/lib/v0.5/BinDeps.ji for module BinDeps.
INFO: Recompiling stale cache file /home/perrin/.julia/lib/v0.5/URIParser.ji for module URIParser.
INFO: Recompiling stale cache file /home/perrin/.julia/lib/v0.5/SHA.ji for module SHA.
WARNING: readall is deprecated, use readstring instead.
while loading /home/perrin/.julia/v0.5/PyCall/deps/build.jl, in expression starting on line 17
WARNING: readall is deprecated, use readstring instead.
while loading /home/perrin/.julia/v0.5/PyCall/deps/build.jl, in expression starting on line 17
WARNING: readall is deprecated, use readstring instead.
while loading /home/perrin/.julia/v0.5/PyCall/deps/build.jl, in expression starting on line 17
WARNING: readall is deprecated, use readstring instead.
while loading /home/perrin/.julia/v0.5/PyCall/deps/build.jl, in expression starting on line 17
WARNING: readall is deprecated, use readstring instead.
while loading /home/perrin/.julia/v0.5/PyCall/deps/build.jl, in expression starting on line 17
WARNING: readall is deprecated, use readstring instead.
while loading /home/perrin/.julia/v0.5/PyCall/deps/build.jl, in expression starting on line 17
WARNING: readall is deprecated, use readstring instead.
while loading /home/perrin/.julia/v0.5/PyCall/deps/build.jl, in expression starting on line 17
WARNING: readall is deprecated, use readstring instead.
while loading /home/perrin/.julia/v0.5/PyCall/deps/build.jl, in expression starting on line 17
WARNING: readall is deprecated, use readstring instead.
while loading /home/perrin/.julia/v0.5/PyCall/deps/build.jl, in expression starting on line 17
INFO: PyCall is using /usr/bin/python (Python 2.7.6) at /usr/bin/python, libpython = libpython2.7

julia> Pkg.update()
INFO: Updating METADATA...
INFO: Computing changes...
INFO: No packages to install, update or remove

julia> using PyPlot
INFO: Precompiling module PyPlot...
julia: /home/psmsd/julia_builds/julia_latest/src/ccall.cpp:183: llvm::Value* llvm_type_rewrite(llvm::Value*, llvm::Type*, llvm::Type*, bool, bool, bool, jl_codectx_t*): Assertion `from_type->isPointerTy() == target_type->isPointerTy()' failed.
ERROR: LoadError: Failed to precompile PyCall to /home/perrin/.julia/lib/v0.5/PyCall.ji
while loading /home/perrin/.julia/v0.5/PyPlot/src/PyPlot.jl, in expression starting on line 5
ERROR: Failed to precompile PyPlot to /home/perrin/.julia/lib/v0.5/PyPlot.ji

julia>

@ihnorton ihnorton mentioned this issue Mar 7, 2016
2 tasks
@vtjnash
Copy link
Sponsor Member

vtjnash commented Apr 4, 2016

fixed by #15556

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior compiler:codegen Generation of LLVM IR and native code regression Regression in behavior compared to a previous version
Projects
None yet
Development

No branches or pull requests

5 participants