Skip to content

fix: resolve_process JNI 空指针导致 :remote 进程 SIGABRT#1996

Open
TuTouPower wants to merge 1 commit into
chen08209:mainfrom
TuTouPower:fix/resolve-process-null-check
Open

fix: resolve_process JNI 空指针导致 :remote 进程 SIGABRT#1996
TuTouPower wants to merge 1 commit into
chen08209:mainfrom
TuTouPower:fix/resolve-process-null-check

Conversation

@TuTouPower
Copy link
Copy Markdown

@TuTouPower TuTouPower commented May 3, 2026

问题

Android 端启动 VPN 代理后,:remote 进程在约 2 秒内以 SIGABRT 崩溃。退出应用重新打开代理同样 2 秒内再次崩溃。VPN 完全无法使用。

详细分析见 #1995

崩溃信息

JNI DETECTED ERROR IN APPLICATION: obj == null
    in call to CallObjectMethodV
#08 libclash.so (_cgo_4e86939d2e9c_Cfunc_resolve_process+48)

修复内容

两处空指针检查:

  1. core/lib.gohandleResolveProcess 增加 th.callback == nil 检查,避免将空指针传入 CGO
  2. android/core/src/main/cpp/core.cppcall_tun_interface_resolve_process_impl 增加 tun_interface == nullptr 检查,避免对空 jobject 调用 JNI 方法

测试计划

  • 验证 VPN 启动后不再崩溃
  • 验证退出重开后代理功能正常

在后台管理激进的设备(如魅族)上,:remote 进程被系统杀掉重启后,
resolveProcess 回调的 jobject 可能为 null,导致 CallObjectMethod
触发 SIGABRT,进程进入崩溃-重启死循环。

修复:
- lib.go: handleResolveProcess 增加 callback nil 检查
- core.cpp: call_tun_interface_resolve_process_impl 增加 nullptr 检查

Closes chen08209#1995
oviron added a commit to oviron/FlClash that referenced this pull request May 7, 2026
Backport chen08209#1996 (TuTouPower). Two-layer defence against the
':remote' core process SIGABRT that hits ~2s after VPN start on Android
14+ when the ':remote' subprocess is killed and respawned: Go side does
not invoke a nil callback, C++ side does not call JNI methods on a null
jobject.
oviron added a commit to oviron/FlClash that referenced this pull request May 8, 2026
Backport chen08209#1996 (TuTouPower). Two-layer defence against the
':remote' core process SIGABRT that hits ~2s after VPN start on Android
14+ when the ':remote' subprocess is killed and respawned: Go side does
not invoke a nil callback, C++ side does not call JNI methods on a null
jobject.
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

Successfully merging this pull request may close these issues.

1 participant