Javet icon indicating copy to clipboard operation
Javet copied to clipboard

oom setNearHeapLimitCallback

Open Vectorted opened this issue 3 months ago • 8 comments

The setNearHeapLimitCallback interception of OOM does not take effect, and the JVM still terminates.

2025-09-02 21:17:50.767 21218-21356 :script_proces com.plus.vectorclient D Features: 0 0 0 2025-09-02 21:17:50.767 21218-21356 :script_proces com.plus.vectorclient E vulkan version is 4206881 2025-09-02 21:17:56.045 21218-21348 nodejs com.plus.vectorclient E FATAL ERROR: invalid array length Allocation failed - JavaScript heap out of memory 2025-09-02 21:17:56.043 21218-21218 Thread-8 com.plus.vectorclient I type=1400 audit(0.0:89429): avc: denied { use } for path="/dev/null" dev="tmpfs" ino=11273 scontext=u:r:untrusted_app:s0:c85,c256,c512,c768 tcontext=u:r:kernel:s0 tclass=fd permissive=1 app=com.plus.vectorclient 2025-09-02 21:17:57.607 21218-21348 SIGNAL_LOG com.plus.vectorclient I signal pid 21218 uid 10085 signal_num 6 si_code -1 si_errno 0 si_val 0 2025-09-02 21:17:57.612 21218-21348 SIGNAL_LOG com.plus.vectorclient I houdini base 0x7021f8650000 2025-09-02 21:17:57.612 21218-21348 SIGNAL_LOG com.plus.vectorclient I houdini arm64 regs base 0x7021d4da4070 2025-09-02 21:17:57.613 21218-21348 SIGNAL_LOG com.plus.vectorclient I dump signal file ok! path: /data/tombstones/app/com.plus.vectorclient/10085.log 2025-09-02 21:17:57.614 21218-21348 libc com.plus.vectorclient A Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 21348 (Thread-8), pid 21218 (:script_process) 2025-09-02 21:17:57.609 21218-21218 Thread-8 com.plus.vectorclient I type=1400 audit(0.0:89451): avc: denied { search } for name="tombstones" dev="sdc3" ino=18 scontext=u:r:untrusted_app:s0:c85,c256,c512,c768 tcontext=u:object_r:tombstone_data_file:s0 tclass=dir permissive=1 app=com.plus.vectorclient ---------------------------- PROCESS STARTED (21375) for package com.plus.vectorclient ---------------------------- 2025-09-02 21:17:58.118 21373-21373 DEBUG crash_dump64 A Cmdline: com.plus.vectorclient:script_process 2025-09-02 21:17:58.118 21373-21373 DEBUG crash_dump64 A pid: 21218, tid: 21348, name: Thread-8 >>> com.plus.vectorclient:script_process <<<

Vectorted avatar Sep 02 '25 13:09 Vectorted

Did you follow the doc? Please show me your code.

caoccao avatar Sep 02 '25 13:09 caoccao

你跟着医生看了吗?请给我看你的代码。

/V8Node.setNearHeapLimitCallback(new IJavetNearHeapLimitCallback() { @Override public long callback(long currentHeapLimit, long initialHeapLimit) { Log.i("test", "stop"); //stop(Context, -1); return currentHeapLimit * 2; } });/

Vectorted avatar Sep 02 '25 13:09 Vectorted

你跟着医生看了吗?请给我看你的代码。

I copied it from your test documentation code

Vectorted avatar Sep 02 '25 13:09 Vectorted

You could call terminateExecution to prevent JVM crash.

caoccao avatar Sep 02 '25 14:09 caoccao

You could call terminateExecution to prevent JVM crash.

It's useless. The commented-out stop method is the one I wrapped to stop the engine. It was functioning normally when there was no OOM, and your OOM interception callback didn't trigger at all. I wrote a log, but there was no output, meaning this callback wasn't triggered. If the callback had been triggered, there wouldn't have been this error.

Vectorted avatar Sep 02 '25 15:09 Vectorted

您可以调用 terminateExecution 来防止 JVM 崩溃。

In other words, after the oom occurs, setNearHeapLimitCallback did not execute at all.

Vectorted avatar Sep 02 '25 15:09 Vectorted

您可以调用 terminateExecution 来防止 JVM 崩溃。

if(V8Node != null) {

            Task.interrupt();
            if(exec) {
                V8Node.terminateExecution();
                exec = false;
            }
        }

您可以调用 terminateExecution 来防止 JVM 崩溃。

This is the stopping logic of my stop method, which is normal. After testing, I found that the callback did not trigger the interception of the out of memory (oom) error, and the Log.i output was also absent.

Vectorted avatar Sep 02 '25 15:09 Vectorted

您可以调用 terminateExecution 来防止 JVM 崩溃。

Are there specific conditions or settings that trigger this callback? I really can't find any other reason. After testing a few rounds, I found that this callback has not been executed and directly causes the JVM to terminate.

Vectorted avatar Sep 02 '25 15:09 Vectorted