https://github.com/trpc-group/trpc-cpp/blob/0e5a67f8ed71c9e6b9d121d53cb99cfcb1b5f0d9/trpc/runtime/common/periphery_task_scheduler.cc#L179 // 这里需要判断队列不是empty,否则下面执行top会出现内存访问异常。这里解释下为何会有这种场景: // 此时m_timerTasks为空,且m_exited为false也就是还没stop, // 此时定时器线程执行到if(m_exited.load(std::memory_order_relaxed)){break;}时 为false, // 所以会往下走执行if(!pred()) {continue;}。 // 此时恰好调用了Timer::Stop,也就是设置了m_exited为true,所以pred()条件为true // 自然就会走到下面m_timerTasks.top()等逻辑,就会出现内存访问异常。 if (m_timerTasks.empty()) { continue; }
Activity
Bugfix: fixed the following bugs
Bugfix: fixed the following bugs
Bugfix: fixed the following bugs (#228)
chhy2009 commentedon Apr 16, 2026
Already fix in #230