线程:: Park失败了无效的争论

发布于 2025-02-06 16:14:13 字数 5258 浏览 1 评论 0原文

我试图通过ScheduleDthRe​​adPoolExecutor在Android R Automotive设备中执行一些定期操作。

  1. 有我的代码:

     私有静态类名为threadFactory实现threadfactory {
        私有最终原子素theminmicteger = new atomicInteger(1);
        私有最终字符串mnameprefix;
    
        名为threadFactory(字符串nameprefix){
            mnameprefix = nameprefix +“ -thread-”;
        }
    
        @Override
        公共线程newthread(可运行r){
            最终线程=新线程(r,mnameprefix + mthreadnumber.getandincrement());
            返回线程;
        }
    }
    
    私有计划threadpoolexecutor mpopdatarefreshexecutor =
        新的ScheduleDthRe​​adPoolExecutor(1,New New newThreadFactory(“ RefreshPopdata”));
    
    mpopdatarefreshexecutor.scheduuleatfixedrate(新的popdatarefresher(),
        timeunit.minutes.tomillis(5),
        timeunit.minutes.tomillis(10),
        timeunit.milliseconds);
     
  2. ,然后,它曾经引起一些本机信号6例外:

    修订:'0'

    abi:'臂'

    时间戳:1912-01-03 13:32:13+0800

    pid:9441,tid:11146,姓名:refreshpopdata->>>> com.demo<<<< UID:1010065

    信号6(sigabrt),代码-1(si_queue),故障addr --------

Abort message: 'Failed to park: Invalid argument'

r0  00000000  r1  00002b8a  r2  00000006  r3  bb98eb00

r4  bb98eb14  r5  bb98eaf8  r6  000024e1  r7  0000016b

r8  bb98eb10  r9  bb98eb00  r10 bb98eb30  r11 bb98eb20

ip  00002b8a  sp  bb98ead0  lr  f1fa158f  pc  f1fa15a2

backtrace:

  #00 pc 000545a2  /apex/com.android.runtime/lib/bionic/libc.so (abort+166) (BuildId: ced36bae419d8d9438cf6f91c6feea37)
  #01 pc 003a0f7d  /apex/com.android.runtime/lib/libart.so (art::Runtime::Abort(char const*)+1980) (BuildId: b1931727e2af1deddf3d63be01bc9e06)
  #02 pc 000085e1  /system/lib/libbase.so (android::base::LogMessage::~LogMessage()+488) (BuildId: d8f9959168f480e25050a2b6cf313736)
  #03 pc 003cff97  /apex/com.android.runtime/lib/libart.so (art::Thread::Park(bool, long long)+1570) (BuildId: b1931727e2af1deddf3d63be01bc9e06)
  #04 pc 003417e9  /apex/com.android.runtime/lib/libart.so (art::Unsafe_park(_JNIEnv*, _jobject*, unsigned char, long long)+440) (BuildId: b1931727e2af1deddf3d63be01bc9e06)
  #05 pc 000edfc9  /system/framework/arm/boot.oat (art_jni_trampoline+96) (BuildId: 16090464612e7610f7b849552ef4a978eef87738)
  #06 pc 0024e283  /system/framework/arm/boot.oat (java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos+818) (BuildId: 16090464612e7610f7b849552ef4a978eef87738)
  #07 pc 003914f7  /system/framework/arm/boot.oat (java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take+326) (BuildId: 16090464612e7610f7b849552ef4a978eef87738)
  #08 pc 003600dd  /system/framework/arm/boot.oat (sun.nio.fs.UnixPath.getParent [DEDUPED]+36) (BuildId: 16090464612e7610f7b849552ef4a978eef87738)
  #09 pc 0034b265  /system/framework/arm/boot.oat (java.util.concurrent.ThreadPoolExecutor.getTask+428) (BuildId: 16090464612e7610f7b849552ef4a978eef87738)
  #10 pc 0034c9ff  /system/framework/arm/boot.oat (java.util.concurrent.ThreadPoolExecutor.runWorker+222) (BuildId: 16090464612e7610f7b849552ef4a978eef87738)
  #11 pc 0034a0a7  /system/framework/arm/boot.oat (java.util.concurrent.ThreadPoolExecutor$Worker.run+54) (BuildId: 16090464612e7610f7b849552ef4a978eef87738)
  #12 pc 001da039  /system/framework/arm/boot.oat (java.lang.Thread.run+64) (BuildId: 16090464612e7610f7b849552ef4a978eef87738)
  #13 pc 000e4bc5  /apex/com.android.runtime/lib/libart.so (art_quick_invoke_stub_internal+68) (BuildId: b1931727e2af1deddf3d63be01bc9e06)
  #14 pc 0045e97b  /apex/com.android.runtime/lib/libart.so (art_quick_invoke_stub+250) (BuildId: b1931727e2af1deddf3d63be01bc9e06)
  #15 pc 000ecffd  /apex/com.android.runtime/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+160) (BuildId: b1931727e2af1deddf3d63be01bc9e06)
  #16 pc 0039ab77  /apex/com.android.runtime/lib/libart.so (art::(anonymous namespace)::InvokeWithArgArray(art::ScopedObjectAccessAlreadyRunnable const&, art::ArtMethod*, art::(anonymous namespace)::ArgArray*, art::JValue*, char const*)+54) (BuildId: b1931727e2af1deddf3d63be01bc9e06)
  #17 pc 0039b881  /apex/com.android.runtime/lib/libart.so (art::InvokeVirtualOrInterfaceWithJValues(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, jvalue const*)+300) (BuildId: b1931727e2af1deddf3d63be01bc9e06)
  #18 pc 003d0e73  /apex/com.android.runtime/lib/libart.so (art::Thread::CreateCallback(void*)+982) (BuildId: b1931727e2af1deddf3d63be01bc9e06)
  #19 pc 0009c5e7  /apex/com.android.runtime/lib/bionic/libc.so (__pthread_start(void*)+20) (BuildId: ced36bae419d8d9438cf6f91c6feea37)
  #20 pc 00055a97  /apex/com.android.runtime/lib/bionic/libc.so (__start_thread+30) (BuildId: ced36bae419d8d9438cf6f91c6feea37)
  1. When I tried to add some log to solve this problem ,它再也没有使用相同的APK和相同的设备发生。
  2. 是处理它的任何建议,我尝试阅读AOSP代码( https://cs.android.com/android/android/platform/superproject/superproject/+/master:art/runtime/thread.cc; cc; cc; l = 311?q =线程:: park )并找出这个堆栈的意思是futex有些失败。但是我不知道什么“无法停车:无效的论点”是什么意思。

I tried to do some periodic action in Android R automotive device by ScheduledThreadPoolExecutor.

  1. There is my code:

    private static class NamedThreadFactory implements ThreadFactory {
        private final AtomicInteger mThreadNumber = new AtomicInteger(1);
        private final String mNamePrefix;
    
        NamedThreadFactory(String namePrefix) {
            mNamePrefix = namePrefix + "-thread-";
        }
    
        @Override
        public Thread newThread(Runnable r) {
            final Thread thread = new Thread(r, mNamePrefix + mThreadNumber.getAndIncrement());
            return thread;
        }
    }
    
    private ScheduledThreadPoolExecutor mPopDataRefreshExecutor =
        new ScheduledThreadPoolExecutor(1, new NamedThreadFactory("refreshPopData"));
    
    mPopDataRefreshExecutor.scheduleAtFixedRate(new PopDataRefresher(),
        TimeUnit.MINUTES.toMillis(5),
        TimeUnit.MINUTES.toMillis(10),
        TimeUnit.MILLISECONDS);
    
  2. And then, it once raise some native signal 6 exception:

    Revision: '0'

    ABI: 'arm'

    Timestamp: 1912-01-03 13:32:13+0800

    pid: 9441, tid: 11146, name: RefreshPopData- >>> com.demo <<<
    uid: 1010065

    signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------

Abort message: 'Failed to park: Invalid argument'

r0  00000000  r1  00002b8a  r2  00000006  r3  bb98eb00

r4  bb98eb14  r5  bb98eaf8  r6  000024e1  r7  0000016b

r8  bb98eb10  r9  bb98eb00  r10 bb98eb30  r11 bb98eb20

ip  00002b8a  sp  bb98ead0  lr  f1fa158f  pc  f1fa15a2

backtrace:

  #00 pc 000545a2  /apex/com.android.runtime/lib/bionic/libc.so (abort+166) (BuildId: ced36bae419d8d9438cf6f91c6feea37)
  #01 pc 003a0f7d  /apex/com.android.runtime/lib/libart.so (art::Runtime::Abort(char const*)+1980) (BuildId: b1931727e2af1deddf3d63be01bc9e06)
  #02 pc 000085e1  /system/lib/libbase.so (android::base::LogMessage::~LogMessage()+488) (BuildId: d8f9959168f480e25050a2b6cf313736)
  #03 pc 003cff97  /apex/com.android.runtime/lib/libart.so (art::Thread::Park(bool, long long)+1570) (BuildId: b1931727e2af1deddf3d63be01bc9e06)
  #04 pc 003417e9  /apex/com.android.runtime/lib/libart.so (art::Unsafe_park(_JNIEnv*, _jobject*, unsigned char, long long)+440) (BuildId: b1931727e2af1deddf3d63be01bc9e06)
  #05 pc 000edfc9  /system/framework/arm/boot.oat (art_jni_trampoline+96) (BuildId: 16090464612e7610f7b849552ef4a978eef87738)
  #06 pc 0024e283  /system/framework/arm/boot.oat (java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos+818) (BuildId: 16090464612e7610f7b849552ef4a978eef87738)
  #07 pc 003914f7  /system/framework/arm/boot.oat (java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take+326) (BuildId: 16090464612e7610f7b849552ef4a978eef87738)
  #08 pc 003600dd  /system/framework/arm/boot.oat (sun.nio.fs.UnixPath.getParent [DEDUPED]+36) (BuildId: 16090464612e7610f7b849552ef4a978eef87738)
  #09 pc 0034b265  /system/framework/arm/boot.oat (java.util.concurrent.ThreadPoolExecutor.getTask+428) (BuildId: 16090464612e7610f7b849552ef4a978eef87738)
  #10 pc 0034c9ff  /system/framework/arm/boot.oat (java.util.concurrent.ThreadPoolExecutor.runWorker+222) (BuildId: 16090464612e7610f7b849552ef4a978eef87738)
  #11 pc 0034a0a7  /system/framework/arm/boot.oat (java.util.concurrent.ThreadPoolExecutor$Worker.run+54) (BuildId: 16090464612e7610f7b849552ef4a978eef87738)
  #12 pc 001da039  /system/framework/arm/boot.oat (java.lang.Thread.run+64) (BuildId: 16090464612e7610f7b849552ef4a978eef87738)
  #13 pc 000e4bc5  /apex/com.android.runtime/lib/libart.so (art_quick_invoke_stub_internal+68) (BuildId: b1931727e2af1deddf3d63be01bc9e06)
  #14 pc 0045e97b  /apex/com.android.runtime/lib/libart.so (art_quick_invoke_stub+250) (BuildId: b1931727e2af1deddf3d63be01bc9e06)
  #15 pc 000ecffd  /apex/com.android.runtime/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+160) (BuildId: b1931727e2af1deddf3d63be01bc9e06)
  #16 pc 0039ab77  /apex/com.android.runtime/lib/libart.so (art::(anonymous namespace)::InvokeWithArgArray(art::ScopedObjectAccessAlreadyRunnable const&, art::ArtMethod*, art::(anonymous namespace)::ArgArray*, art::JValue*, char const*)+54) (BuildId: b1931727e2af1deddf3d63be01bc9e06)
  #17 pc 0039b881  /apex/com.android.runtime/lib/libart.so (art::InvokeVirtualOrInterfaceWithJValues(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, jvalue const*)+300) (BuildId: b1931727e2af1deddf3d63be01bc9e06)
  #18 pc 003d0e73  /apex/com.android.runtime/lib/libart.so (art::Thread::CreateCallback(void*)+982) (BuildId: b1931727e2af1deddf3d63be01bc9e06)
  #19 pc 0009c5e7  /apex/com.android.runtime/lib/bionic/libc.so (__pthread_start(void*)+20) (BuildId: ced36bae419d8d9438cf6f91c6feea37)
  #20 pc 00055a97  /apex/com.android.runtime/lib/bionic/libc.so (__start_thread+30) (BuildId: ced36bae419d8d9438cf6f91c6feea37)
  1. When I tried to add some log to solve this problem, it never happends again with same apk and same device.
  2. Is any advice to deal with it, I tried to read AOSP code(https://cs.android.com/android/platform/superproject/+/master:art/runtime/thread.cc;l=311?q=Thread::park) and find out this stack mean to futex something failed. But I have no idea what "Failed to park: Invalid argument" means.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文