JuliaSparse / SuiteSparseGraphBLAS.jl

Sparse, General Linear Algebra for Graphs!
MIT License
102 stars 17 forks source link

Segfault when using jl_ memory functions #39

Closed rayegun closed 3 years ago

rayegun commented 3 years ago

When using

libgb.GxB_init(libgb.GrB_NONBLOCKING, cglobal(:jl_malloc), cglobal(:jl_calloc), cglobal(:jl_realloc), cglobal(:jl_free), true)

instead of

libgb.GrB_init(libgb.GrB_NONBLOCKING)

we segfault with:

free(): invalid pointer

signal (6): Aborted
in expression starting at /home/will/.julia/dev/SuiteSparseGraphBLAS.jl/test/gbarray.jl:1
gsignal at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
abort at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x7f3ea221a507)
unknown function (ip: 0x7f3ea2220c19)
unknown function (ip: 0x7f3ea222242b)
jl_gc_counted_free_with_size at /buildworker/worker/package_linux64/build/src/gc.c:3387
GB_free_memory at /home/will/.julia/artifacts/1f93b9028928b30c16345d26d889adc8815ac7df/lib/libgraphblas.so (unknown line)
GB_dealloc_memory at /home/will/.julia/artifacts/1f93b9028928b30c16345d26d889adc8815ac7df/lib/libgraphblas.so (unknown line)
GB_bix_free at /home/will/.julia/artifacts/1f93b9028928b30c16345d26d889adc8815ac7df/lib/libgraphblas.so (unknown line)
GB_phbix_free at /home/will/.julia/artifacts/1f93b9028928b30c16345d26d889adc8815ac7df/lib/libgraphblas.so (unknown line)
GB_Matrix_free at /home/will/.julia/artifacts/1f93b9028928b30c16345d26d889adc8815ac7df/lib/libgraphblas.so (unknown line)
GrB_Matrix_free at /home/will/.julia/artifacts/1f93b9028928b30c16345d26d889adc8815ac7df/lib/libgraphblas.so (unknown line)
GrB_Matrix_free at /home/will/.julia/dev/SuiteSparseGraphBLAS.jl/src/lib/LibGraphBLAS.jl:926
f at /home/will/.julia/dev/SuiteSparseGraphBLAS.jl/src/types.jl:97
unknown function (ip: 0x7f3e88043a84)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2237 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2419
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1703 [inlined]
run_finalizer at /buildworker/worker/package_linux64/build/src/gc.c:278
jl_gc_run_finalizers_in_list at /buildworker/worker/package_linux64/build/src/gc.c:367
run_finalizers at /buildworker/worker/package_linux64/build/src/gc.c:394
jl_gc_run_pending_finalizers at /buildworker/worker/package_linux64/build/src/gc.c:404
jl_mutex_unlock at /buildworker/worker/package_linux64/build/src/locks.h:136 [inlined]
jl_generate_fptr at /buildworker/worker/package_linux64/build/src/jitlayers.cpp:361
jl_compile_method_internal at /buildworker/worker/package_linux64/build/src/gf.c:1970
jl_compile_method_internal at /buildworker/worker/package_linux64/build/src/gf.c:2236 [inlined]
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2229 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2419
eval_test at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:277
jfptr_eval_test_20160.clone_1 at /home/will/julia-1.6.0/lib/julia/sys.so (unknown line)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2237 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2419
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1703 [inlined]
do_call at /buildworker/worker/package_linux64/build/src/interpreter.c:115
eval_value at /buildworker/worker/package_linux64/build/src/interpreter.c:204
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:434
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:489
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:489
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:489
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:489
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:489
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:489
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:489
jl_interpret_toplevel_thunk at /buildworker/worker/package_linux64/build/src/interpreter.c:669
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:877
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:825
jl_toplevel_eval_in at /buildworker/worker/package_linux64/build/src/toplevel.c:929
eval at ./boot.jl:360 [inlined]
include_string at ./loading.jl:1094
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2237 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2419
_include at ./loading.jl:1148
include at ./client.jl:444 [inlined]
macro expansion at ./timing.jl:210 [inlined]
include_test at /home/will/.julia/dev/SuiteSparseGraphBLAS.jl/test/runtests.jl:11
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2237 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2419
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1703 [inlined]
do_call at /buildworker/worker/package_linux64/build/src/interpreter.c:115
eval_value at /buildworker/worker/package_linux64/build/src/interpreter.c:204
eval_stmt_value at /buildworker/worker/package_linux64/build/src/interpreter.c:155 [inlined]
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:561
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:489
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:489
jl_interpret_toplevel_thunk at /buildworker/worker/package_linux64/build/src/interpreter.c:669
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:877
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:825
jl_toplevel_eval_in at /buildworker/worker/package_linux64/build/src/toplevel.c:929
eval at ./boot.jl:360 [inlined]
include_string at ./loading.jl:1094
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2237 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2419
_include at ./loading.jl:1148
include at ./client.jl:444
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2237 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2419
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1703 [inlined]
do_call at /buildworker/worker/package_linux64/build/src/interpreter.c:115
eval_value at /buildworker/worker/package_linux64/build/src/interpreter.c:204
eval_stmt_value at /buildworker/worker/package_linux64/build/src/interpreter.c:155 [inlined]
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:561
jl_interpret_toplevel_thunk at /buildworker/worker/package_linux64/build/src/interpreter.c:669
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:877
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:825
jl_toplevel_eval_in at /buildworker/worker/package_linux64/build/src/toplevel.c:929
eval at ./boot.jl:360 [inlined]
exec_options at ./client.jl:261
_start at ./client.jl:485
jfptr__start_41020.clone_1 at /home/will/julia-1.6.0/lib/julia/sys.so (unknown line)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2237 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2419
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1703 [inlined]
true_main at /buildworker/worker/package_linux64/build/src/jlapi.c:560
repl_entrypoint at /buildworker/worker/package_linux64/build/src/jlapi.c:702
main at /buildworker/worker/package_linux64/build/cli/loader_exe.c:51
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
_start at /home/will/julia-1.6.0/bin/julia (unknown line)
Allocations: 5194925 (Pool: 5193993; Big: 932); GC: 4

We want to do this so Julia responds to memory pressure from SuiteSparse:GraphBLAS. But GC triggers the above segfault. Will need to investigate further.

@ViralBShah this isn't urgent, but towards the end of next week I might need some pointers (haha) on this. For now I'm leaving it as libgb.GrB_init(libgb.GrB_NONBLOCKING), but I'd like to solve this before 1.0.

ViralBShah commented 3 years ago

I'm not sure I understand enough of this to be able to help. Clearly, it is trying to free something that has been freed before. I suppose this is the kind of thing that RR could help with.

rayegun commented 3 years ago

Fixed by cfb15eae8a7ce97070bb7383f0b36e1594e5bc05