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

Segfault when running CxxWrap example #3

Open
rossviljoen opened this issue May 12, 2022 · 6 comments
Open

Segfault when running CxxWrap example #3

rossviljoen opened this issue May 12, 2022 · 6 comments

Comments

@rossviljoen
Copy link
Collaborator

When running CxxWrapExample/src/example.jl:

signal (11): Segmentation fault
in expression starting at REPL[4]:1
_ZN9mindspore7compile7FinalVM4EvalERKNS_9VectorRefE at /home/ross/msproj/mindspore/mindspore/_c_expression.cpython-37m-x86_64-linux-gnu.so (unknown line)
_ZNSt17_Function_handlerIFN9mindspore7BaseRefERNS0_7compile7FinalVMERKNS0_9VectorRefEEZN5jlcxx11TypeWrapperIS3_E6methodIS1_S3_JS7_EEERSB_RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEMT0_FT_DpT1_EEUlS4_S7_E_E9_M_invokeERKSt9_Any_dataS4_S7_ at /home/ross/msproj/MindSpore.jl/build/lib/libcxx_graph_api.so (unknown line)
_ZN5jlcxx6detail11CallFunctorIN9mindspore7BaseRefEJRNS2_7compile7FinalVMERKNS2_9VectorRefEEE5applyEPKvNS_13WrappedCppPtrESD_ at /home/ross/msproj/MindSpore.jl/build/lib/libcxx_graph_api.so (unknown line)
Eval at /home/ross/.julia/packages/CxxWrap/ptbgM/src/CxxWrap.jl:619
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1788 [inlined]
do_call at /buildworker/worker/package_linux64/build/src/interpreter.c:126
eval_value at /buildworker/worker/package_linux64/build/src/interpreter.c:215
eval_stmt_value at /buildworker/worker/package_linux64/build/src/interpreter.c:166 [inlined]
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:587
jl_interpret_toplevel_thunk at /buildworker/worker/package_linux64/build/src/interpreter.c:731
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:885
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:830
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:830
jl_toplevel_eval_in at /buildworker/worker/package_linux64/build/src/toplevel.c:944
eval at ./boot.jl:373 [inlined]
eval_user_input at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:150
repl_backend_loop at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:246
start_repl_backend at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:231
#run_repl#47 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:364
run_repl at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:351
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
#930 at ./client.jl:394
jfptr_YY.930_45169.clone_1 at /home/ross/julia-1.7.2/lib/julia/sys.so (unknown line)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1788 [inlined]
jl_f__call_latest at /buildworker/worker/package_linux64/build/src/builtins.c:757
#invokelatest#2 at ./essentials.jl:716 [inlined]
invokelatest at ./essentials.jl:714 [inlined]
run_main_repl at ./client.jl:379
exec_options at ./client.jl:309
_start at ./client.jl:495
jfptr__start_38732.clone_1 at /home/ross/julia-1.7.2/lib/julia/sys.so (unknown line)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1788 [inlined]
true_main at /buildworker/worker/package_linux64/build/src/jlapi.c:559
jl_repl_entrypoint at /buildworker/worker/package_linux64/build/src/jlapi.c:701
main at julia (unknown line)
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x400808)
Allocations: 6386357 (Pool: 6383760; Big: 2597); GC: 6
./runjulia: line 10:  5855 Segmentation fault      (core dumped)

This appears to be a segfault when attempting to run the VM that is produced after compiling the graph. In this case, the graph is empty (has no operations) - but it is possible to execute a blank graph directly from C++ (see CxxWrapExample/ccsrc/main.cc)

@agdkyang
Copy link

agdkyang commented May 17, 2022

Hi, rossviljoen, have you ever compiled and run ./cxx_example successfully
(https://gitee.com/ginfung/ms_cxx_graph_api_example/tree/master)?

@rossviljoen
Copy link
Collaborator Author

Hi! Yes, I am able to run that example using version 1.2.1 of MindSpore

@agdkyang
Copy link

@rossviljoen Errors may occur when you run an empty graph. You need add non-empty graph just like the function TensorAddExample and CreateTensorAddGraph in https://github.com/cambridge-mlg/MindSpore.jl/blob/master/ms_cxx_graph_api_example/main.cc. Also you can try an empty graph with c++ interface and check if the error is created from this problem.

@rossviljoen
Copy link
Collaborator Author

I can confirm that running an empty graph with the c++ interface doesn't error and seems to work fine.

See the code for this here

I think that the error comes from limitations in Julia's C++ FFI CxxWrap.jl - I think that this is probably not a MindSpore issue. Many thanks for the help though!

@yebai
Copy link
Contributor

yebai commented May 26, 2022

@rossviljoen can you try to call these C++ functions via extern c instead of using CxxWrap.jl?

@agdkyang
Copy link

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

3 participants