已关闭
[Bug]: Data race in ThreadStart / ThreadEnd events #11796
slynkodenis创建于  6月5日关闭于  6月10日
slynkodenis
slynkodenis
6月5日 创建

感谢对OpenHarmony社区的支持与关注,欢迎反馈缺陷。

发生了什么问题?

There is a data race in ThreadStart / ThreadEnd events implementation in RuntimeNotificationManager

期望行为是什么?

No data race

如何复现该缺陷

Run with TSAN:

[2026-06-05T07:43:24.711Z] WARNING: ThreadSanitizer: data race (pid=11542)

[2026-06-05T07:43:24.711Z]   Write of size 1 at 0x7b5000001582 by thread T22:

[2026-06-05T07:43:24.711Z]     #0 void ark::RuntimeNotificationManager::AddListenerIfMatches<bool>(ark::RuntimeListener*, unsigned int, std::__cxx11::list<ark::RuntimeListener*, ark::mem::AllocatorAdapter<ark::RuntimeListener*, (ark::mem::AllocScope)0> >*, ark::RuntimeNotificationManager::Event, bool*) /home/jenkins/agent/workspace/Panda/Pre_Merge_Builds_and_Sanitizers3/panda_src/runtime_core/static_core/runtime/include/runtime_notification.h:567 (libarkruntime.so+0x11552c1)

[2026-06-05T07:43:24.711Z]     #1 ark::RuntimeNotificationManager::AddListener(ark::RuntimeListener*, unsigned int) /home/jenkins/agent/workspace/Panda/Pre_Merge_Builds_and_Sanitizers3/panda_src/runtime_core/static_core/runtime/include/runtime_notification.h:158 (libarkruntime.so+0x1153a3e)

[2026-06-05T07:43:24.711Z]     #2 ark::tooling::Debugger::Debugger(ark::Runtime const*) /home/jenkins/agent/workspace/Panda/Pre_Merge_Builds_and_Sanitizers3/panda_src/runtime_core/static_core/runtime/tooling/debugger.h:133 (libarkruntime.so+0x15635b4)

[2026-06-05T07:43:24.711Z]     #3 std::enable_if<!std::is_array_v<ark::tooling::Debugger>, ark::tooling::Debugger*>::type ark::mem::Allocator::New<ark::tooling::Debugger, ark::Runtime*>(ark::Runtime*&&) /home/jenkins/agent/workspace/Panda/Pre_Merge_Builds_and_Sanitizers3/panda_src/runtime_core/static_core/runtime/include/mem/allocator.h:220 (libarkruntime.so+0x15633ab)

[2026-06-05T07:43:24.711Z]     #4 std::enable_if<!std::is_array_v<ark::tooling::Debugger>, std::unique_ptr<ark::tooling::Debugger, ark::DefaultPandaDelete<ark::tooling::Debugger> > >::type ark::MakePandaUnique<ark::tooling::Debugger, ark::Runtime*>(ark::Runtime*&&) /home/jenkins/agent/workspace/Panda/Pre_Merge_Builds_and_Sanitizers3/panda_src/runtime_core/static_core/runtime/include/mem/panda_smart_pointers.h:75 (libarkruntime.so+0x153778a)

[2026-06-05T07:43:24.711Z]     #5 ark::Runtime::DebugSession::DebugSession(ark::Runtime&) /home/jenkins/agent/workspace/Panda/Pre_Merge_Builds_and_Sanitizers3/panda_src/runtime_core/static_core/runtime/runtime.cpp:186 (libarkruntime.so+0x1526f39)

[2026-06-05T07:43:24.711Z]     #6 std::enable_if<!std::is_array_v<ark::Runtime::DebugSession>, ark::Runtime::DebugSession*>::type ark::mem::Allocator::New<ark::Runtime::DebugSession, ark::Runtime&>(ark::Runtime&) /home/jenkins/agent/workspace/Panda/Pre_Merge_Builds_and_Sanitizers3/panda_src/runtime_core/static_core/runtime/include/mem/allocator.h:220 (libarkruntime.so+0x1592f5b)

[2026-06-05T07:43:24.712Z]     #7 std::enable_if<!std::is_array_v<ark::Runtime::DebugSession>, std::shared_ptr<ark::Runtime::DebugSession> >::type ark::MakePandaShared<ark::Runtime::DebugSession, ark::Runtime&>(ark::Runtime&) /home/jenkins/agent/workspace/Panda/Pre_Merge_Builds_and_Sanitizers3/panda_src/runtime_core/static_core/runtime/include/mem/panda_smart_pointers.h:94 (libarkruntime.so+0x153d46a)

[2026-06-05T07:43:24.712Z]     #8 ark::Runtime::StartDebugSession() /home/jenkins/agent/workspace/Panda/Pre_Merge_Builds_and_Sanitizers3/panda_src/runtime_core/static_core/runtime/runtime.cpp:1456 (libarkruntime.so+0x1530389)

[2026-06-05T07:43:24.712Z]     #9 ark::tooling::Tools::AttachDebugSession() /home/jenkins/agent/workspace/Panda/Pre_Merge_Builds_and_Sanitizers3/panda_src/runtime_core/static_core/runtime/tooling/tools.cpp:167 (libarkruntime.so+0x114a2c0)

[2026-06-05T07:43:24.712Z]     #10 AttachDebugSession(__ani_env*) /home/jenkins/agent/workspace/Panda/Pre_Merge_Builds_and_Sanitizers3/panda_src/runtime_core/static_core/plugins/ets/tests/runtime/tooling/debug_session_attach/utils.cpp:58 (libets_debug_session_attach_lib.so+0x23596)

[2026-06-05T07:43:24.712Z]     #11 <null> <null> (libarkruntime.so+0x201f700)

[2026-06-05T07:43:24.712Z]     #12 ark::Value ark::Method::InvokeImpl<ark::InvokeHelperStatic, ark::Value>(ark::ManagedThread*, unsigned int, ark::Value*, ark::CallFlags) /home/jenkins/agent/workspace/Panda/Pre_Merge_Builds_and_Sanitizers3/panda_src/runtime_core/static_core/runtime/include/method-inl.h:435 (libarkruntime.so+0x14daaa1)

[2026-06-05T07:43:24.712Z]     #13 ark::Method::Invoke(ark::ManagedThread*, ark::Value*, ark::CallFlags) /home/jenkins/agent/workspace/Panda/Pre_Merge_Builds_and_Sanitizers3/panda_src/runtime_core/static_core/runtime/method.cpp:235 (libarkruntime.so+0x14d6536)

[2026-06-05T07:43:24.712Z]     #14 ark::Coroutine::ExecuteJob(ark::Job*) /home/jenkins/agent/workspace/Panda/Pre_Merge_Builds_and_Sanitizers3/panda_src/runtime_core/static_core/runtime/execution/coroutines/coroutine.cpp:133 (libarkruntime.so+0x1854742)

[2026-06-05T07:43:24.712Z]     #15 ark::StackfulCoroutineContext::ThreadProcImpl() /home/jenkins/agent/workspace/Panda/Pre_Merge_Builds_and_Sanitizers3/panda_src/runtime_core/static_core/runtime/execution/coroutines/stackful/stackful_coroutine.cpp:154 (libarkruntime.so+0x1858d18)

[2026-06-05T07:43:24.712Z]     #16 ark::StackfulCoroutineContext::CoroThreadProc(void*) /home/jenkins/agent/workspace/Panda/Pre_Merge_Builds_and_Sanitizers3/panda_src/runtime_core/static_core/runtime/execution/coroutines/stackful/stackful_coroutine.cpp:132 (libarkruntime.so+0x1858595)

[2026-06-05T07:43:24.712Z]     #17 GetCurrentContext <null> (libarkruntime.so+0x189b33f)

[2026-06-05T07:43:24.712Z] 

[2026-06-05T07:43:24.712Z]   Previous read of size 1 at 0x7b5000001582 by thread T26:

[2026-06-05T07:43:24.712Z]     #0 ark::RuntimeNotificationManager::ThreadEndEvent(ark::ManagedThread*) /home/jenkins/agent/workspace/Panda/Pre_Merge_Builds_and_Sanitizers3/panda_src/runtime_core/static_core/runtime/include/runtime_notification.h:251 (libarkruntime.so+0x15b1aac)

[2026-06-05T07:43:24.712Z]     #1 ark::StackfulCoroutineManager::TerminateCoroutine(ark::Coroutine*) /home/jenkins/agent/workspace/Panda/Pre_Merge_Builds_and_Sanitizers3/panda_src/runtime_core/static_core/runtime/execution/coroutines/stackful/stackful_coroutine_manager.cpp:352 (libarkruntime.so+0x185c675)

[2026-06-05T07:43:24.712Z]     #2 ark::StackfulCoroutineContext::ThreadProcImpl() /home/jenkins/agent/workspace/Panda/Pre_Merge_Builds_and_Sanitizers3/panda_src/runtime_core/static_core/runtime/execution/coroutines/stackful/stackful_coroutine.cpp:157 (libarkruntime.so+0x1858d5e)

[2026-06-05T07:43:24.713Z]     #3 ark::StackfulCoroutineContext::CoroThreadProc(void*) /home/jenkins/agent/workspace/Panda/Pre_Merge_Builds_and_Sanitizers3/panda_src/runtime_core/static_core/runtime/execution/coroutines/stackful/stackful_coroutine.cpp:132 (libarkruntime.so+0x1858595)

[2026-06-05T07:43:24.713Z]     #4 GetCurrentContext <null> (libarkruntime.so+0x189b33f)

[2026-06-05T07:43:24.713Z]     #5 ark::StackfulCoroutineWorker::SwitchCoroutineContext(ark::StackfulCoroutineContext*, ark::StackfulCoroutineContext*) /home/jenkins/agent/workspace/Panda/Pre_Merge_Builds_and_Sanitizers3/panda_src/runtime_core/static_core/runtime/execution/coroutines/stackful/stackful_coroutine_worker.cpp:559 (libarkruntime.so+0x186ea4d)

[2026-06-05T07:43:24.713Z]     #6 ark::StackfulCoroutineWorker::ScheduleNextCoroUnlockNone() /home/jenkins/agent/workspace/Panda/Pre_Merge_Builds_and_Sanitizers3/panda_src/runtime_core/static_core/runtime/execution/coroutines/stackful/stackful_coroutine_worker.cpp:526 (libarkruntime.so+0x186fdeb)

[2026-06-05T07:43:24.713Z]     #7 ark::StackfulCoroutineWorker::RequestFinalization(ark::Coroutine*) /home/jenkins/agent/workspace/Panda/Pre_Merge_Builds_and_Sanitizers3/panda_src/runtime_core/static_core/runtime/execution/coroutines/stackful/stackful_coroutine_worker.cpp:192 (libarkruntime.so+0x186fd85)

[2026-06-05T07:43:24.713Z]     #8 ark::StackfulCoroutineManager::TerminateCoroutine(ark::Coroutine*) /home/jenkins/agent/workspace/Panda/Pre_Merge_Builds_and_Sanitizers3/panda_src/runtime_core/static_core/runtime/execution/coroutines/stackful/stackful_coroutine_manager.cpp:356 (libarkruntime.so+0x185c6b7)

[2026-06-05T07:43:24.713Z]     #9 ark::StackfulCoroutineContext::ThreadProcImpl() /home/jenkins/agent/workspace/Panda/Pre_Merge_Builds_and_Sanitizers3/panda_src/runtime_core/static_core/runtime/execution/coroutines/stackful/stackful_coroutine.cpp:157 (libarkruntime.so+0x1858d5e)

[2026-06-05T07:43:24.713Z]     #10 ark::StackfulCoroutineContext::CoroThreadProc(void*) /home/jenkins/agent/workspace/Panda/Pre_Merge_Builds_and_Sanitizers3/panda_src/runtime_core/static_core/runtime/execution/coroutines/stackful/stackful_coroutine.cpp:132 (libarkruntime.so+0x1858595)

[2026-06-05T07:43:24.713Z]     #11 GetCurrentContext <null> (libarkruntime.so+0x189b33f)

其他补充信息

版本或分支信息

likedislike
openharmony_ci
openharmony_ci成员
6月5日 评论:

感谢提交Issue!关于Issue的交互操作,请访问OpenHarmony社区支持命令清单。如果有问题,请联系 [@weng-changcheng](https://gitcode.com/weng-changcheng) [@godmiaozi](https://gitcode.com/godmiaozi) [@liyiming13](https://gitcode.com/liyiming13) [@lijin1039](https://gitcode.com/lijin1039) [@Prof](https://gitcode.com/Prof) [@dingding5](https://gitcode.com/dingding5) [@vpukhov](https://gitcode.com/vpukhov) [@v-cherkashin](https://gitcode.com/v-cherkashin) 。如果需要调整订阅PR、Issue的变更状态,请访问链接。


Thanks for submitting the issue. For more commands, please visit OpenHarmony Command List. If you have any questions, please refer to committer gitcode for help. If you need to change the subscription of a Pull Request or Issue, please visit the link.

likedislike
openharmony_ciopenharmony_ci成员
6月5日 添加了label:waiting_for_assign
slynkodenisslynkodenis
6月5日 关联了pull request:Fix race in ThreadStart / ThreadEnd events
openharmony_ciopenharmony_ci成员
6月10日 关闭了 issue
openharmony_ciopenharmony_ci成员
6月10日 issue状态由 待办的 改变为 已完成