JuliaInterop / JuliaCall

Embed Julia in R
https://non-contradiction.github.io/JuliaCall/index.html
Other
267 stars 36 forks source link

JuliaCall with Morpho segfault #228

Closed jjlynch2 closed 4 months ago

jjlynch2 commented 5 months ago

I'm having a very strange issue I cannot figure out. When loading JuliaCall and Morpho R packages, julia_setup() has a segfault on Linux systems? It works just fine on windows.

R version 4.3.3 Julia version 1.10.2 Manjaro Linux running 6.6.26. This also happens on 6.8.9 on an arch install.

library("JuliaCall") library("Morpho") julia_setup() Julia version 1.10.2 at location /usr/bin will be used.

[54089] signal (11.1): Segmentation fault in expression starting at none:0 unknown function (ip: 0x7f0231ab8c27) unknown function (ip: 0x7f0231ab8da7) _ZN4llvm14FoldingSetBase19FindNodeOrInsertPosERKNS_16FoldingSetNodeIDERPvRKNS0_14FoldingSetInfoE at /usr/bin/../lib/julia/../libLLVM-15jl.so (unknown line) _ZN4llvm12SelectionDAG19FindNodeOrInsertPosERKNS_16FoldingSetNodeIDERKNS_5SDLocERPv at /usr/bin/../lib/julia/../libLLVM-15jl.so (unknown line) _ZN4llvm12SelectionDAG11getConstantERKNS_11ConstantIntERKNS_5SDLocENS_3EVTEbb at /usr/bin/../lib/julia/../libLLVM-15jl.so (unknown line) _ZN4llvm19SelectionDAGBuilder18visitGetElementPtrERKNS_4UserE at /usr/bin/../lib/julia/../libLLVM-15jl.so (unknown line) _ZN4llvm19SelectionDAGBuilder5visitERKNS_11InstructionE at /usr/bin/../lib/julia/../libLLVM-15jl.so (unknown line) _ZN4llvm16SelectionDAGISel16SelectBasicBlockENS_14ilist_iteratorINS_12ilist_detail12node_optionsINS_11InstructionELb0ELb0EvEELb0ELb1EEES6_Rb at /usr/bin/../lib/julia/../libLLVM-15jl.so (unknown line) _ZN4llvm16SelectionDAGISel20SelectAllBasicBlocksERKNS_8FunctionE at /usr/bin/../lib/julia/../libLLVM-15jl.so (unknown line) unknown function (ip: 0x7f01f9df5b1e) unknown function (ip: 0x7f01fcb2a906) unknown function (ip: 0x7f01f98223f5) _ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE at /usr/bin/../lib/julia/../libLLVM-15jl.so (unknown line) _ZN4llvm13FPPassManager11runOnModuleERNS_6ModuleE at /usr/bin/../lib/julia/../libLLVM-15jl.so (unknown line) _ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE at /usr/bin/../lib/julia/../libLLVM-15jl.so (unknown line) _ZN4llvm3orc14SimpleCompilerclERNS_6ModuleE at /usr/bin/../lib/julia/../libLLVM-15jl.so (unknown line) unknown function (ip: 0x7f020d8d97b4) _ZN4llvm3orc14IRCompileLayer4emitESt10unique_ptrINS0_29MaterializationResponsibilityESt14default_deleteIS3_EENS0_16ThreadSafeModuleE at /usr/bin/../lib/julia/../libLLVM-15jl.so (unknown line) _ZN4llvm3orc16IRTransformLayer4emitESt10unique_ptrINS0_29MaterializationResponsibilityESt14default_deleteIS3_EENS0_16ThreadSafeModuleE at /usr/bin/../lib/julia/../libLLVM-15jl.so (unknown line) unknown function (ip: 0x7f020d8d8aaa) _ZN4llvm3orc31BasicIRLayerMaterializationUnit11materializeESt10unique_ptrINS0_29MaterializationResponsibilityESt14default_deleteIS3_EE at /usr/bin/../lib/julia/../libLLVM-15jl.so (unknown line) _ZN4llvm3orc19MaterializationTask3runEv at /usr/bin/../lib/julia/../libLLVM-15jl.so (unknown line) unknown function (ip: 0x7f02334cbfdb) _ZN4llvm3orc16ExecutionSession22dispatchOutstandingMUsEv at /usr/bin/../lib/julia/../libLLVM-15jl.so (unknown line) _ZN4llvm3orc16ExecutionSession17OL_completeLookupESt10unique_ptrINS0_21InProgressLookupStateESt14default_deleteIS3_EESt10shared_ptrINS0_23AsynchronousSymbolQueryEESt8functionIFvRKNS_8DenseMapIPNS0_8JITDylibENS_8DenseSetINS0_15SymbolStringPtrENS_12DenseMapInfoISF_vEEEENSG_ISD_vEENS_6detail12DenseMapPairISD_SI_EEEEEE at /usr/bin/../lib/julia/../libLLVM-15jl.so (unknown line) unknown function (ip: 0x7f01fb67cfee) _ZN4llvm3orc16ExecutionSession19OL_applyQueryPhase1ESt10unique_ptrINS0_21InProgressLookupStateESt14default_deleteIS3_EENS_5ErrorE at /usr/bin/../lib/julia/../libLLVM-15jl.so (unknown line) _ZN4llvm3orc16ExecutionSession6lookupENS0_10LookupKindERKSt6vectorISt4pairIPNS0_8JITDylibENS0_19JITDylibLookupFlagsEESaIS8_EENS0_15SymbolLookupSetENS0_11SymbolStateENS_15unique_functionIFvNS_8ExpectedINS_8DenseMapINS0_15SymbolStringPtrENS_18JITEvaluatedSymbolENS_12DenseMapInfoISI_vEENS_6detail12DenseMapPairISI_SJ_EEEEEEEEESt8functionIFvRKNSH_IS6_NS_8DenseSetISI_SL_EENSK_IS6_vEENSN_IS6_SV_EEEEEE at /usr/bin/../lib/julia/../libLLVM-15jl.so (unknown line) _ZN4llvm3orc16ExecutionSession6lookupERKSt6vectorISt4pairIPNS0_8JITDylibENS0_19JITDylibLookupFlagsEESaIS7_EENS0_15SymbolLookupSetENS0_10LookupKindENS0_11SymbolStateESt8functionIFvRKNS_8DenseMapIS5_NS_8DenseSetINS0_15SymbolStringPtrENS_12DenseMapInfoISI_vEEEENSJ_IS5_vEENS_6detail12DenseMapPairIS5_SL_EEEEEE at /usr/bin/../lib/julia/../libLLVM-15jl.so (unknown line) unknown function (ip: 0x7f020d8dcb8f) unknown function (ip: 0x7f020d8e0669) unknown function (ip: 0x7f020d8e1551) jl_generate_fptr_impl at /usr/bin/../lib/julia/libjulia-codegen.so.1.10 (unknown line) jl_compile_method_internal at /usr/bin/../lib/julia/libjulia-internal.so.1.10 (unknown line) ijl_apply_generic at /usr/bin/../lib/julia/libjulia-internal.so.1.10 (unknown line) ijl_parse at /usr/bin/../lib/julia/libjulia-internal.so.1.10 (unknown line) ijl_parse_all at /usr/bin/../lib/julia/libjulia-internal.so.1.10 (unknown line) ijl_eval_string at /usr/bin/../lib/julia/libjulia-internal.so.1.10 (unknown line) load_libjulia_modules at /tmp/RtmpXIGZHr/R.INSTALL33985a74fda7/JuliaCall/src/libjulia.cpp:156 juliacall_initialize at /tmp/RtmpXIGZHr/R.INSTALL33985a74fda7/JuliaCall/src/JuliaCall.cpp:45 _JuliaCall_juliacall_initialize at /tmp/RtmpXIGZHr/R.INSTALL33985a74fda7/JuliaCall/src/RcppExports.cpp:22 unknown function (ip: 0x7f02406a6f3d) unknown function (ip: 0x7f02406a74dc) unknown function (ip: 0x7f02406e6c60) Rf_eval at /usr/lib64/R/lib/libR.so (unknown line) unknown function (ip: 0x7f02406d39a2) Rf_applyClosure at /usr/lib64/R/lib/libR.so (unknown line) unknown function (ip: 0x7f02406e664c) Rf_eval at /usr/lib64/R/lib/libR.so (unknown line) unknown function (ip: 0x7f02406d39a2) Rf_applyClosure at /usr/lib64/R/lib/libR.so (unknown line) Rf_eval at /usr/lib64/R/lib/libR.so (unknown line) Rf_ReplIteration at /usr/lib64/R/lib/libR.so (unknown line) unknown function (ip: 0x7f0240732598) run_Rmainloop at /usr/lib64/R/lib/libR.so (unknown line) main at /usr/lib64/R/bin/exec/R (unknown line) unknown function (ip: 0x7f0240443ccf) __libc_start_main at /usr/lib/libc.so.6 (unknown line) _start at /usr/lib64/R/bin/exec/R (unknown line) Allocations: 2907 (Pool: 2897; Big: 10); GC: 0

jjlynch2 commented 5 months ago

Adding that it also happens if you change the order of libraries. If you run:

library(JuliaCall) julia_setup() Julia version 1.10.2 at location /usr/bin will be used. Loading setup script for JuliaCall... Finish loading setup script for JuliaCall. library(Morpho) Segmentation fault (core dumped)

zarquon42b commented 5 months ago

Hi, I just tried on Ubuntu 22.04 with julia installed with snap and here everything works smoothly. Maybe reinstall/recompile all packages first. Selection_206

jjlynch2 commented 5 months ago

I just updated Julia to 1.10.3 and R to 4.4.0 and still getting a segfault on Manjaro. I was able to get it working on Arch with some system updates. It must be something specific to the linux distro since Manjaro is based on Arch and a few weeks behind for updates. So odd.

zarquon42b commented 5 months ago

Did you run update.packages() in case some packages/dependencies were built against different versions of some libraries?

jjlynch2 commented 5 months ago

I tried update.packages() and still have the segfault. I'm going through checking whats different between Arch and Manjaro right now, so far it looks like GCC gets updated from 13.2.1 to 14.1.1. I'm not sure if that's causing the issue, but we should see in a few weeks when it updates on Manjaro.

jjlynch2 commented 4 months ago

Interestingly, even with the GCC update, this still happens. I also noticed it happens when using JuliaCall and rgl. The only thing I can think of is some weird hardware compatibility with any package that might use the GPU (uses an amd gpu). I even tried reinstalling several Linux distros and all of them have this issue on this particular laptop.