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

运行时so层报错 #29

Open
hlz9494 opened this issue Dec 25, 2023 · 5 comments
Open

运行时so层报错 #29

hlz9494 opened this issue Dec 25, 2023 · 5 comments

Comments

@hlz9494
Copy link

hlz9494 commented Dec 25, 2023

报错日志

2023-12-25 18:12:39.617 5343-6263/com.hlz.demo.mark A/libc: Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x8 in tid 6263 (QuickJS-1), pid 5343 (.ib.camera.mark) 2023-12-25 18:12:39.878 1027-4530/? E/SDM: CompManager::PrepareStrategyConstraints: PrepareStrategyConstraints,idle_fallback=1, thermal_fallback_=0 2023-12-25 18:12:39.966 6609-6609/? A/DEBUG: Process name is com.hlz.demo.mark, not key_process 2023-12-25 18:12:39.966 6609-6609/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 2023-12-25 18:12:39.966 6609-6609/? A/DEBUG: Build fingerprint: 'realme/RMX2051/RMX2051CN:11/RKQ1.201217.002/1647099377877:user/release-keys' 2023-12-25 18:12:39.966 6609-6609/? A/DEBUG: Revision: '0' 2023-12-25 18:12:39.966 6609-6609/? A/DEBUG: ABI: 'arm64' 2023-12-25 18:12:39.966 6609-6609/? A/DEBUG: Timestamp: 2023-12-25 18:12:39+0800 2023-12-25 18:12:39.966 6609-6609/? A/DEBUG: pid: 5343, tid: 6263, name: QuickJS-1 >>> com.h l z.mark <<< 2023-12-25 18:12:39.966 6609-6609/? A/DEBUG: uid: 10309 2023-12-25 18:12:39.966 6609-6609/? A/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x8 2023-12-25 18:12:39.966 6609-6609/? A/DEBUG: Cause: null pointer dereference 2023-12-25 18:12:39.966 6609-6609/? A/DEBUG: x0 b400007bb38b8100 x1 b400007add15e570 x2 ffffffffffffffff x3 0000007b4eb92330 2023-12-25 18:12:39.966 6609-6609/? A/DEBUG: x4 0000007bba9d8a28 x5 0000007bba9d8a48 x6 0000007b4eb92170 x7 0000007b4eb92150 2023-12-25 18:12:39.966 6609-6609/? A/DEBUG: x8 0000000000000000 x9 0000000000000000 x10 0000007bbe6bcbd0 x11 0000000000000008 2023-12-25 18:12:39.966 6609-6609/? A/DEBUG: x12 0000007b4eb922a0 x13 0000007b4eb92230 x14 0000000000000000 x15 0000000000000001 2023-12-25 18:12:39.966 6609-6609/? A/DEBUG: x16 0000007bbe77ac50 x17 0000007bbe6bcb74 x18 0000000000000001 x19 b400007bb38b8100 2023-12-25 18:12:39.966 6609-6609/? A/DEBUG: x20 b400007add15e578 x21 b400007bb38b8198 x22 0000000000000000 x23 0000000000000010 2023-12-25 18:12:39.966 6609-6609/? A/DEBUG: x24 0000000000000001 x25 b400007bc64e3d38 x26 b400007add4e0190 x27 0000000000000000 2023-12-25 18:12:39.966 6609-6609/? A/DEBUG: x28 0000000000000000 x29 0000007b6e670e20 2023-12-25 18:12:39.966 6609-6609/? A/DEBUG: lr 0000007bbe6e996c sp 0000007b6e670e00 pc 0000007bbe6bcbe8 pst 0000000080001000 2023-12-25 18:12:40.086 6609-6609/? A/DEBUG: backtrace: 2023-12-25 18:12:40.086 6609-6609/? A/DEBUG: #00 pc 0000000000035be8 /data/app/~~8HamuObff_73LLzw57cUpg==/com.hlz.demo.mark-vVSoF19id1FLGbgOEmpGMw==/lib/arm64/libquickjs.so (__JS_FreeValueRT+116) (BuildId: 058f4040780ee9252f5d0c27c36356dd9aa011c3) 2023-12-25 18:12:40.086 6609-6609/? A/DEBUG: #01 pc 0000000000062968 /data/app/~~8HamuObff_73LLzw57cUpg==/com.hlz.demo.mark-vVSoF19id1FLGbgOEmpGMw==/lib/arm64/libquickjs.so (BuildId: 058f4040780ee9252f5d0c27c36356dd9aa011c3) 2023-12-25 18:12:40.086 6609-6609/? A/DEBUG: #02 pc 0000000000064d98 /data/app/~~8HamuObff_73LLzw57cUpg==/com.hlz.demo.mark-vVSoF19id1FLGbgOEmpGMw==/lib/arm64/libquickjs.so (BuildId: 058f4040780ee9252f5d0c27c36356dd9aa011c3) 2023-12-25 18:12:40.086 6609-6609/? A/DEBUG: #03 pc 0000000000035c54 /data/app/~~8HamuObff_73LLzw57cUpg==/com.hlz.demo.mark-vVSoF19id1FLGbgOEmpGMw==/lib/arm64/libquickjs.so (__JS_FreeValueRT+224) (BuildId: 058f4040780ee9252f5d0c27c36356dd9aa011c3) 2023-12-25 18:12:40.086 6609-6609/? A/DEBUG: #04 pc 00000000000a89c4 /data/app/~~8HamuObff_73LLzw57cUpg==/com.hlz.demo.mark-vVSoF19id1FLGbgOEmpGMw==/oat/arm64/base.odex (art_jni_trampoline+164) 2023-12-25 18:12:40.086 6609-6609/? A/DEBUG: #05 pc 00000000021978c0 /memfd:jit-cache (deleted) (offset 0x2000000) (com.quickjs.EventQueue.lambda$_releasePtr$15$EventQueue+96) 2023-12-25 18:12:40.086 6609-6609/? A/DEBUG: #06 pc 0000000002197b8c /memfd:jit-cache (deleted) (offset 0x2000000) (com.quickjs.-$$Lambda$EventQueue$GXnJGGFzvyXYbYgXX0W6-F1vQYY.run+108) 2023-12-25 18:12:40.086 6609-6609/? A/DEBUG: #07 pc 00000000020c0b0c /memfd:jit-cache (deleted) (offset 0x2000000) (com.quickjs.EventQueue.lambda$postVoid$1$EventQueue+140) 2023-12-25 18:12:40.086 6609-6609/? A/DEBUG: #08 pc 00000000020c2fbc /memfd:jit-cache (deleted) (offset 0x2000000) (com.quickjs.-$$Lambda$EventQueue$9q9qVcE2GlOF6r852nMR2uKwJrs.run+124) 2023-12-25 18:12:40.086 6609-6609/? A/DEBUG: #09 pc 0000000002122a64 /memfd:jit-cache (deleted) (offset 0x2000000) (android.os.Handler.handleCallback+68) 2023-12-25 18:12:40.086 6609-6609/? A/DEBUG: #10 pc 00000000021504e0 /memfd:jit-cache (deleted) (offset 0x2000000) (android.os.Handler.dispatchMessage+64) 2023-12-25 18:12:40.086 6609-6609/? A/DEBUG: #11 pc 0000000002065978 /memfd:jit-cache (deleted) (offset 0x2000000) (android.os.Looper.loop+2072) 2023-12-25 18:12:40.086 6609-6609/? A/DEBUG: #12 pc 00000000001337e8 /apex/com.android.art/lib64/libart.so (art_quick_invoke_static_stub+568) (BuildId: 5fc46038f91aa117c85260cbdc94cd1b) 2023-12-25 18:12:40.086 6609-6609/? A/DEBUG: #13 pc 00000000001a8a94 /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+228) (BuildId: 5fc46038f91aa117c85260cbdc94cd1b) 2023-12-25 18:12:40.086 6609-6609/? A/DEBUG: #14 pc 0000000000318288 /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+376) (BuildId: 5fc46038f91aa117c85260cbdc94cd1b) 2023-12-25 18:12:40.086 6609-6609/? A/DEBUG: #15 pc 000000000030e5b4 /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+996) (BuildId: 5fc46038f91aa117c85260cbdc94cd1b) 2023-12-25 18:12:40.086 6609-6609/? A/DEBUG: #16 pc 0000000000680034 /apex/com.android.art/lib64/libart.so (MterpInvokeStatic+548) (BuildId: 5fc46038f91aa117c85260cbdc94cd1b) 2023-12-25 18:12:40.086 6609-6609/? A/DEBUG: #17 pc 000000000012d994 /apex/com.android.art/lib64/libart.so (mterp_op_invoke_static+20) (BuildId: 5fc46038f91aa117c85260cbdc94cd1b) 2023-12-25 18:12:40.086 6609-6609/? A/DEBUG: #18 pc 00000000003d2eb4 /system/framework/framework.jar (offset 0x97f000) (android.os.HandlerThread.run+56) 2023-12-25 18:12:40.086 6609-6609/? A/DEBUG: #19 pc 0000000000305bb0 /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.17481138192350454783)+268) (BuildId: 5fc46038f91aa117c85260cbdc94cd1b) 2023-12-25 18:12:40.086 6609-6609/? A/DEBUG: #20 pc 000000000066bdf4 /apex/com.android.art/lib64/libart.so (artQuickToInterpreterBridge+780) (BuildId: 5fc46038f91aa117c85260cbdc94cd1b) 2023-12-25 18:12:40.086 6609-6609/? A/DEBUG: #21 pc 000000000013cff8 /apex/com.android.art/lib64/libart.so (art_quick_to_interpreter_bridge+88) (BuildId: 5fc46038f91aa117c85260cbdc94cd1b) 2023-12-25 18:12:40.086 6609-6609/? A/DEBUG: #22 pc 0000000000133564 /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+548) (BuildId: 5fc46038f91aa117c85260cbdc94cd1b) 2023-12-25 18:12:40.086 6609-6609/? A/DEBUG: #23 pc 00000000001a8a78 /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+200) (BuildId: 5fc46038f91aa117c85260cbdc94cd1b) 2023-12-25 18:12:40.086 6609-6609/? A/DEBUG: #24 pc 000000000055581c /apex/com.android.art/lib64/libart.so (art::JValue art::InvokeVirtualOrInterfaceWithJValues<art::ArtMethod*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, art::ArtMethod*, jvalue const*)+460) (BuildId: 5fc46038f91aa117c85260cbdc94cd1b) 2023-12-25 18:12:40.086 6609-6609/? A/DEBUG: #25 pc 00000000005a4b80 /apex/com.android.art/lib64/libart.so (art::Thread::CreateCallback(void*)+1308) (BuildId: 5fc46038f91aa117c85260cbdc94cd1b) 2023-12-25 18:12:40.086 6609-6609/? A/DEBUG: #26 pc 00000000000da278 /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+64) (BuildId: e81bf516b888e895d4e757da439c8117) 2023-12-25 18:12:40.086 6609-6609/? A/DEBUG: #27 pc 000000000007a448 /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64) (BuildId: e81bf516b888e895d4e757da439c8117)

@GentlemanHao
Copy link

GentlemanHao commented Dec 27, 2023

遇到了同样的问题,终于有队友了
@hlz9494 大佬解决了吗?

@GentlemanHao
Copy link

image

@hlz9494
Copy link
Author

hlz9494 commented Dec 28, 2023

解决了 出错问题是底层quickjs释放jsValue变量的时候找不到这个 jsValue报了空指针
原因是因为 quickJs是线程不安全 的,特别是在创建jsValue的时候
比如说我在quickJs里面开启了一个新的线程处理一些事情,之前我直接在新线程里面创建jsvalue并回调回来,可能几次没有事情,但是执行次数多了就会报这个问题。
后面我改成在新线程里面回调回默认的quickJs-1的线程就没有出现这个问题了

@GentlemanHao
Copy link

GentlemanHao commented Jan 4, 2024

解决了 出错问题是底层quickjs释放jsValue变量的时候找不到这个 jsValue报了空指针 原因是因为 quickJs是线程不安全 的,特别是在创建jsValue的时候 比如说我在quickJs里面开启了一个新的线程处理一些事情,之前我直接在新线程里面创建jsvalue并回调回来,可能几次没有事情,但是执行次数多了就会报这个问题。 后面我改成在新线程里面回调回默认的quickJs-1的线程就没有出现这个问题了

多谢大佬解答,我使用的时候都是在主线程的,没有使用新的线程,下面是我的用法:

mQuickJS = QuickJS.createRuntimeWithEventQueue();
mJsContext = mQuickJS.createContext();

mJsContext.registerJavaMethod()

JSObject jsObject = mJsContext.executeObjectScript(javaScript, null);
            if (jsObject instanceof JSFunction) {
                JSFunction jsFunction = (JSFunction) jsObject;
                if (!jsFunction.getContext().isReleased()) {
                    JSFunction callback = new JSFunction(mJsContext, new JavaVoidCallback() {
                        @Override
                        public void invoke(JSObject receiver, JSArray args) {
                            
                        }
                    });
                    JSArray jsArray = new JSArray(mJsContext).push(JSUtils.getParams(mJsContext, methodParam)).push(callback);
                    jsFunction.call(null, jsArray);
                }
            }

我这样使用OK吗?大佬是怎么使用的?能否贴个示例,多谢

@GentlemanHao
Copy link

mJsContext.registerJavaMethod(new JavaVoidCallback() {
            @Override
            public void invoke(JSObject receiver, JSArray args) {
                
                });
            }
        }, "exit");

另外测了下,这里的 invoke 方法是在 quickJs-1 线程,我把这里的内容抛回主线程还是有这个问题

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

2 participants