UndefRefError on a global constant instatiation in the stdlib

question

#1

Running something like

init_TRNG() = init_TRNG(GLOBAL_RNG)
const threadRNG = init_TRNG()

in a Julia source works, the problem comes when I try to add it to the Random module in the stdlib.
There it returns during Julia’s compilation UndefRefError() on the const threadRNG instatiation, which seems absurd to me.
Is there some restriction to global const initialization in the stdlib or I am missing something?
Thanks!


#2

What version are you on, and can you copy the error message / stack trace here?


#3

Julia 0.7.0 - master The error is in full

DelimitedFiles  ─  2.354190 seconds
error during bootstrap:
LoadError("sysimg.jl", 493, LoadError("/home/rodia/dev/RNG-julia/usr/share/julia/stdlib/v0.7/Random/src/Random.jl", 254, LoadError("/home/rodia/dev/RNG-julia/usr/share/julia/stdlib/v0.7/Random/src/RNGs.jl", 586, UndefRefError())))
rec_backtrace at /home/rodia/dev/RNG-julia/src/stackwalk.c:94
record_backtrace at /home/rodia/dev/RNG-julia/src/task.c:246
jl_throw at /home/rodia/dev/RNG-julia/src/task.c:577
getproperty at ./sysimg.jl:18 [inlined]
getindex at ./refvalue.jl:32 [inlined]
calc_jump at /home/rodia/dev/RNG-julia/usr/share/julia/stdlib/v0.7/Random/src/DSFMT.jl:176 [inlined]
randjump at /home/rodia/dev/RNG-julia/usr/share/julia/stdlib/v0.7/Random/src/RNGs.jl:561 [inlined]
init_TRNG at /home/rodia/dev/RNG-julia/usr/share/julia/stdlib/v0.7/Random/src/RNGs.jl:580 [inlined]
init_TRNG at /home/rodia/dev/RNG-julia/usr/share/julia/stdlib/v0.7/Random/src/RNGs.jl:584
jl_fptr_trampoline at /home/rodia/dev/RNG-julia/src/gf.c:1813
jl_apply_generic at /home/rodia/dev/RNG-julia/src/gf.c:2142
do_call at /home/rodia/dev/RNG-julia/src/interpreter.c:324
eval_value at /home/rodia/dev/RNG-julia/src/interpreter.c:428
eval_stmt_value at /home/rodia/dev/RNG-julia/src/interpreter.c:363 [inlined]
eval_body at /home/rodia/dev/RNG-julia/src/interpreter.c:671
jl_interpret_toplevel_thunk_callback at /home/rodia/dev/RNG-julia/src/interpreter.c:788
unknown function (ip: 0xfffffffffffffffe)
unknown function (ip: 0x7fb65625f7ef)
unknown function (ip: (nil))
jl_interpret_toplevel_thunk at /home/rodia/dev/RNG-julia/src/interpreter.c:797
jl_toplevel_eval_flex at /home/rodia/dev/RNG-julia/src/toplevel.c:814
jl_parse_eval_all at /home/rodia/dev/RNG-julia/src/ast.c:854
jl_load at /home/rodia/dev/RNG-julia/src/toplevel.c:848
include at ./boot.jl:317 [inlined]
include_relative at ./loading.jl:1075
include at ./sysimg.jl:29 [inlined]
include at /home/rodia/dev/RNG-julia/usr/share/julia/stdlib/v0.7/Random/src/Random.jl:5
jl_apply_generic at /home/rodia/dev/RNG-julia/src/gf.c:2142
do_call at /home/rodia/dev/RNG-julia/src/interpreter.c:324
eval_value at /home/rodia/dev/RNG-julia/src/interpreter.c:428
eval_stmt_value at /home/rodia/dev/RNG-julia/src/interpreter.c:363 [inlined]
eval_body at /home/rodia/dev/RNG-julia/src/interpreter.c:671
jl_interpret_toplevel_thunk_callback at /home/rodia/dev/RNG-julia/src/interpreter.c:788
unknown function (ip: 0xfffffffffffffffe)
unknown function (ip: 0x7fb657524fcf)
unknown function (ip: 0xffffffffffffffff)
jl_interpret_toplevel_thunk at /home/rodia/dev/RNG-julia/src/interpreter.c:797
jl_toplevel_eval_flex at /home/rodia/dev/RNG-julia/src/toplevel.c:814
jl_eval_module_expr at /home/rodia/dev/RNG-julia/src/toplevel.c:233
jl_toplevel_eval_flex at /home/rodia/dev/RNG-julia/src/toplevel.c:605
jl_parse_eval_all at /home/rodia/dev/RNG-julia/src/ast.c:854
jl_load at /home/rodia/dev/RNG-julia/src/toplevel.c:848
include at ./boot.jl:317 [inlined]
include_relative at ./loading.jl:1075
_require at ./loading.jl:998
require at ./loading.jl:879
require at ./loading.jl:874
jl_apply_generic at /home/rodia/dev/RNG-julia/src/gf.c:2142
do_call at /home/rodia/dev/RNG-julia/src/interpreter.c:324
eval_value at /home/rodia/dev/RNG-julia/src/interpreter.c:428
eval_body at /home/rodia/dev/RNG-julia/src/interpreter.c:554
jl_interpret_toplevel_thunk_callback at /home/rodia/dev/RNG-julia/src/interpreter.c:788
unknown function (ip: 0xfffffffffffffffe)
unknown function (ip: 0x7fb6578a68ef)
unknown function (ip: 0x26)
jl_interpret_toplevel_thunk at /home/rodia/dev/RNG-julia/src/interpreter.c:797
jl_toplevel_eval_flex at /home/rodia/dev/RNG-julia/src/toplevel.c:814
jl_parse_eval_all at /home/rodia/dev/RNG-julia/src/ast.c:854
jl_load at /home/rodia/dev/RNG-julia/src/toplevel.c:848
exec_program at /home/rodia/dev/RNG-julia/ui/repl.c:36
true_main at /home/rodia/dev/RNG-julia/ui/repl.c:124
main at /home/rodia/dev/RNG-julia/ui/repl.c:243
__libc_start_main at /usr/lib/libc.so.6 (unknown line)
_start at /home/rodia/dev/RNG-julia/usr/bin/julia (unknown line)

*** This error is usually fixed by running `make clean`. If the error persists, try `make cleanall`. ***
make[1]: *** [Makefile:201: /home/rodia/dev/RNG-julia/usr/lib/julia/sys-o.a] Error 1
make: *** [Makefile:78: julia-sysimg-release] Error 2

Obviously make cleanall does not resolve the issue.


#4

Wwll actually it seems that the problem comes whenever calling init_TRNG, which is simply defined as
init_TRNG(r::MersenneTwister) = randjump(r, big(10)^20, Threads.nthreads())
randjump does nothing more than returing an n-array of MersenneTwister. So I still do not get why it goes to a UndefRefError, should I instatiate it as a type or something?