wenjin272 opened a new issue, #1087:
URL: https://github.com/apache/flink-agents/issues/1087

   ### Search before asking
   
   - [x] I searched in the 
[issues](https://github.com/apache/flink-agents/issues) and found nothing 
similar.
   
   ### Description
   
   The cross-language Mem0 long-term-memory E2E test can terminate the JVM with 
a native `SIGSEGV` while a Java agent calls `MemorySet.add()` from durable 
async execution.
   
   The failing path is:
   
   ```text
   Java durable async worker
     -> Java MemorySet.add
     -> Java Mem0LongTermMemory wrapper
     -> Pemja PythonInterpreter.invoke
     -> Python Mem0LongTermMemory.add
     -> Mem0 chat / embedding / vector-store processing
   ```
   
   The failure was first observed in this CI job:
   
   
https://github.com/apache/flink-agents/actions/runs/33615851952/job/100201365522
   
   It is also reproducible locally. Instead of reporting a Java or Python 
exception, the JVM writes an `hs_err_pid*.log` and exits. A sanitized excerpt 
from a local reproduction is:
   
   ```text
   # A fatal error has been detected by the Java Runtime Environment:
   # SIGSEGV (0xb)
   # JRE version: Java(TM) SE Runtime Environment (21.0.8+12)
   # Java VM: Java HotSpot(TM) 64-Bit Server VM (bsd-aarch64)
   # Problematic frame:
   C  [Python+0xfbaf0]  _PyObject_GetMethod+0x30
   
   Current thread: JavaThread "flink-agents-java-async-pool-5-thread-2" 
[_thread_in_native]
   
   C  [Python]  _PyEval_EvalFrameDefault
   C  [pemja_core.cpython-311-darwin.so]  JcpPyObject_Call
   C  [pemja_core.cpython-311-darwin.so]  
Java_pemja_core_PythonInterpreter_invoke
   j  pemja.core.PythonInterpreter.invoke(...)
   j  
org.apache.flink.agents.runtime.python.utils.PythonResourceAdapterImpl.callMethod(...)
   j  org.apache.flink.agents.runtime.memory.Mem0LongTermMemory.add(...)
   j  org.apache.flink.agents.api.memory.MemorySet.add(...)
   j  
org.apache.flink.agents.runtime.context.JavaRunnerContextImpl.lambda$executeAsyncCallable$3(...)
   ```
   
   The exact operation inside `mem0.add()` that triggers the crash is still 
under investigation. The Mem0 write path can call back into Java OpenAI 
ChatModel, Ollama EmbeddingModel, and Elasticsearch VectorStore resources. 
Focused entry/return logging is being added around those boundaries to identify 
the last completed step.
   
   A normal cross-language ChatModel call can already execute the Java -> 
Python setup -> Java connection path asynchronously on a non-main worker thread 
without crashing. Therefore, async execution or a Java -> Python -> Java 
callback alone is not yet sufficient to explain this failure.
   
   Expected behavior: `MemorySet.add()` completes successfully, or a managed 
Java/Python exception is returned without terminating the JVM.
   
   Actual behavior: the entire JVM exits with a native crash from CPython 
evaluation through Pemja.
   
   ### How to reproduce
   
   1. Build Flink Agents and install its Python dependencies.
   2. Start Ollama with the `nomic-embed-text` model.
   3. Start Elasticsearch and export `ES_HOST=http://localhost:9200`.
   4. Export a valid `ACTION_API_KEY` and, if needed, `ACTION_BASE_URL` for the 
OpenAI-compatible chat model.
   5. Run the cross-language Mem0 test:
   
   ```bash
   mvn -pl e2e-test/flink-agents-end-to-end-tests-resource-cross-language \
     -Dtest=Mem0LongTermMemoryTest test
   ```
   
   The test sends interleaved facts for two keys. 
`Mem0LongTermMemoryAgent.addItems()` invokes `memorySet.add()` using 
`durableExecuteAsync()`. During one of the later Mem0 additions, the Maven 
Surefire JVM may abort and produce an `hs_err_pid*.log`.
   
   ### Version and environment
   
   - Flink Agents: `0.4-SNAPSHOT`
   - Flink: `2.3.0`
   - Pemja: `0.5.7`
   - CI: `ubuntu-latest`, Temurin JDK 21, Python 3.12
   - Local reproduction: macOS aarch64, Oracle JDK 21.0.8, Python 3.11
   
   ### Are you willing to submit a PR?
   
   - [x] I'm willing to submit a PR!
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to