Skip to content

Segfault on model open and close #80

@shuttie

Description

@shuttie

On a latest 3.4.1 version I have a JVM crash when using this code:

val params = new ModelParameters().setModelFilePath("qwen2-0_5b-instruct-q4_0.gguf")
val model = new LlamaModel(params)
model.close() // <-- crashes here

For a code where I actually do generation (like in README), then the close() call causes no crash. It does not depend on model, but the qwen2 is small enough to illustrate the issue.

JVM Crash log:

Stack: [0x00007f3cb1c01000,0x00007f3cb2401000],  sp=0x00007f3cb23ffa08,  free space=8186k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [libc.so.6+0x15ed00]

siginfo: si_signo: 11 (SIGSEGV), si_code: 1 (SEGV_MAPERR), si_addr: 0x00007f3c1cc00000

Native stacktrace:

jhsdb jstack --core core --exe /usr/lib/jvm/openjdk-17/bin/java
Attaching to core core from executable /usr/lib/jvm/openjdk-17/bin/java, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 17.0.12+7
Deadlock Detection:

No deadlocks found.

"main" #1 prio=5 tid=0x00007f4da402e130 nid=0x17f2 runnable [0x00007f4daa5fe000]
   java.lang.Thread.State: RUNNABLE
   JavaThread state: _thread_in_native
 - de.kherud.llama.LlamaModel.delete() @bci=0 (Interpreted frame)
 - de.kherud.llama.LlamaModel.close() @bci=1, line=115 (Interpreted frame)
 - ai.nixiesearch.util.LlamaCrash$.main(java.lang.String[]) @bci=43, line=15 (Interpreted frame)
 - ai.nixiesearch.util.LlamaCrash.main(java.lang.String[]) @bci=4 (Interpreted frame)

clhsdb pstack:

----------------- 6130 -----------------
"main" #1 prio=5 tid=0x00007f4da402e130 nid=0x17f2 runnable [0x00007f4daa5fe000]
   java.lang.Thread.State: RUNNABLE
   JavaThread state: _thread_in_native
0x00007f4d5fa3264f      std::_Rb_tree<std::pair<std::string, std::string>, std::pair<std::pair<std::string, std::string> const, int>, std::_Select1st<std::pair<std::pair<std::string, std::string> const, int> >, std::less<std::pair<std::string, std::string> >, std::allocator<std::pair<std::pair<std::string, std::string> const, int> > >::_M_erase(std::_Rb_tree_node<std::pair<std::pair<std::string, std::string> const, int> >*) [clone .isra.0] + 0x2f
Locked ownable synchronizers:
    - None

I will later build a -DLLAMA_DEBUG version of the native library and check out the proper stacktrace. But for me sounds like something not fully being initialized on start, and got deleted on close.

hs_err_pid30598.log

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions