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

Problem to use variable in module #810

Closed
zhaoli-IHEP opened this issue Mar 7, 2020 · 3 comments
Closed

Problem to use variable in module #810

zhaoli-IHEP opened this issue Mar 7, 2020 · 3 comments

Comments

@zhaoli-IHEP
Copy link

It is strange crash shown by the following example.

First, we created a module file "ConstVar.jl"

module ConstVar

using Nemo

  export RR

  RR = RealField(512)
  bb = RR("1e-100")
  #bb = 1::Int64 # native type works okay.

end # module ConstVar

Then another file to use it "test.jl"

using Nemo

push!(LOAD_PATH, ".")
using ConstVar

# define function here
function mod_test(x::arb)
  println( "bb = ", x )
end

# run the function here
mod_test(ConstVar.bb)

We confronted the random crash (signal (11): Segmentation fault) on Linux version Julia1.3.1.
And we found it constantly crashes on MacOS version Julia1.3.0.

In the beginning we thought it is due to mistake in Julia grammar, but it works fine if we change to "bb = 1::Int64"

And here is the lengthy error message on Linux machine


Welcome to Nemo version 0.16.1

Nemo comes with absolutely no warranty whatsoever

bb = 
signal (11): Segmentation fault
in expression starting at /home/zhaoli/works/play_julia/test26.jl:11
mag_fast_init_set_arf at /workspace/srcdir/arb/arf.h:1202 [inlined]
arb_mul at /workspace/srcdir/arb/arb/mul.c:79
arb_get_fmpz_mid_rad_10exp at /workspace/srcdir/arb/arb/get_fmpz_mid_rad_10exp.c:83
arb_get_str_parts at /workspace/srcdir/arb/arb/get_str.c:335
arb_get_str at /workspace/srcdir/arb/arb/get_str.c:453
show at /home/zhaoli/.julia/packages/Nemo/5aSWJ/src/arb/arb.jl:144
print at ./strings/io.jl:35
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2141 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2305
print at ./strings/io.jl:46
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2141 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2305
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1631 [inlined]
jl_f__apply at /buildworker/worker/package_linux64/build/src/builtins.c:627
println at ./strings/io.jl:73
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2141 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2305
println at ./coreio.jl:4
mod_test at /home/zhaoli/works/play_julia/test26.jl:8
unknown function (ip: 0x7fc02c08faac)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2141 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2305
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1631 [inlined]
do_call at /buildworker/worker/package_linux64/build/src/interpreter.c:328
eval_value at /buildworker/worker/package_linux64/build/src/interpreter.c:417
eval_stmt_value at /buildworker/worker/package_linux64/build/src/interpreter.c:368 [inlined]
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:778
jl_interpret_toplevel_thunk_callback at /buildworker/worker/package_linux64/build/src/interpreter.c:888
unknown function (ip: 0xfffffffffffffffe)
unknown function (ip: 0x7fbfc599ef0f)
unknown function (ip: 0xffffffffffffffff)
jl_interpret_toplevel_thunk at /buildworker/worker/package_linux64/build/src/interpreter.c:897
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:814
jl_parse_eval_all at /buildworker/worker/package_linux64/build/src/ast.c:873
jl_load at /buildworker/worker/package_linux64/build/src/toplevel.c:878
include at ./boot.jl:328 [inlined]
include_relative at ./loading.jl:1105
include at ./Base.jl:31
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2135 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2305
exec_options at ./client.jl:287
_start at ./client.jl:460
jfptr__start_2084.clone_1 at /home/zhaoli/works/public_code/julia-1.3.1/lib/julia/sys.so (unknown line)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2135 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2305
jl_apply at /buildworker/worker/package_linux64/build/ui/../src/julia.h:1631 [inlined]
true_main at /buildworker/worker/package_linux64/build/ui/repl.c:96
main at /buildworker/worker/package_linux64/build/ui/repl.c:217
__libc_start_main at /lib64/libc.so.6 (unknown line)
_start at /home/zhaoli/works/public_code/julia-1.3.1/bin/julia (unknown line)
Allocations: 1554931 (Pool: 1554578; Big: 353); GC: 1
Segmentation fault (core dumped)
@thofma
Copy link
Member

thofma commented Mar 7, 2020

This is probably the same as #790. Try putting the declaration inside the __init()__ function of your module.

We should document this somewhere.

@zhaoli-IHEP
Copy link
Author

This is probably the same as #790. Try putting the declaration inside the __init()__ function of your module.

We should document this somewhere.

Thank you so much. So it seems all fine by adding the function

  function __init__()
    global bb = RR("1e-100")
    nothing
  end

@thofma
Copy link
Member

thofma commented Mar 9, 2020

Glad it works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants