I am new to Julia and I am really surprised by the behavior of the following code.
using Random, Distributions
function get_a(a, b)
if b == 1
a = rand(Dirichlet([1,1]),1)'
end
return a
end
function test()
a = get_a([0 0] ,1)
println("a[2] = ", a[2])
t = a[2]
end
c = test()
I get the following errors when running this code.
Illegal inttoptr
%26 = ptrtoint %jl_value_t addrspace(10)* %20 to i64, !dbg !89
Illegal inttoptr
%27 = inttoptr i64 %26 to i64 addrspace(13)*, !dbg !89
signal (6): Aborted
in expression starting at /some_path//test.jl:16
gsignal at /usr/bin/../lib/x86_64-linux-gnu/libc.so.6 (unknown line)
abort at /usr/bin/../lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x7f7614d76d04)
_ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE at /usr/bin/../lib/x86_64-linux-gnu/libLLVM-8.so.1 (unknown line)
_ZN4llvm13FPPassManager11runOnModuleERNS_6ModuleE at /usr/bin/../lib/x86_64-linux-gnu/libLLVM-8.so.1 (unknown line)
_ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE at /usr/bin/../lib/x86_64-linux-gnu/libLLVM-8.so.1 (unknown line)
unknown function (ip: 0x7f7614e60ac1)
unknown function (ip: 0x7f7614e632d8)
unknown function (ip: 0x7f7614e638cd)
unknown function (ip: 0x7f7614d9eb4a)
unknown function (ip: 0x7f7614dd0082)
unknown function (ip: 0x7f7614df584b)
jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/libjulia.so.1 (unknown line)
unknown function (ip: 0x7f7614e0875b)
unknown function (ip: 0x7f7614e08389)
unknown function (ip: 0x7f7614e088f0)
unknown function (ip: 0x7f7614e099c8)
unknown function (ip: 0x7f7614e0a616)
unknown function (ip: 0x7f7614e22e08)
unknown function (ip: 0x7f7614dfe105)
jl_load at /usr/bin/../lib/x86_64-linux-gnu/libjulia.so.1 (unknown line)
include at ./Base.jl:377
exec_options at ./client.jl:288
_start at ./client.jl:484
jfptr__start_2075.clone_1 at /usr/lib/x86_64-linux-gnu/julia/sys.so (unknown line)
unknown function (ip: 0x55dde18589d9)
unknown function (ip: 0x55dde18585a6)
__libc_start_main at /usr/bin/../lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x55dde185864d)
Allocations: 6718336 (Pool: 6716442; Big: 1894); GC: 6
Aborted (core dumped)
These errors go away if I comment out the "if", "return", "t =", or "println" statements. I am aware of the method mismatch issue where "[0 0]" that goes into the "get_a" function are of integer type and "a" returned by "rand()" function is of float type. However, I would expect the code to return a method mismatch error instead of the cryptic error messages above. I really do not understand why commenting out some of the statements removes these errors. Thank you for your help.
P.S. The result of executing versioninfo() in Julia REPL produces the following output:
Julia Version 1.4.1
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-8.0.1 (ORCJIT, skylake)
@code_llvm test()
can help you understand the problem better. – Oskar