apache / apache/brpc

TimerThread的run_and_delete中用了memory_order_relaxed内存序,是否会导致与unschedule的竞争问题

Open
#1,070 0 comments 0 reactions 0 assignees View on GitHub
discussion
Dominant language
C++
Stars
17.6k
Forks
4.1k
Avg merge
2d 12h
Merged PRs (30d)
69

Description

**Is your feature request related to a problem? (你需要的功能是否与某个问题有关?)**
在braft的代码中,依赖于bthread_timer_del返回0来释放一些变量的内存。但是我研究TimerThread觉得这里似乎不是100%安全的,如下图所示。
![image](https://user-images.githubusercontent.com/9687347/77399404-5b4d8700-6de4-11ea-8e50-264b33c3ee86.png)

**Describe the solution you'd like (描述你期望的解决方法)**

用更安全的内存序
**Describe alternatives you've considered (描述你想到的折衷方案)**

**Additional context/screenshots (更多上下文/截图)**

Contributor guide

Open the contributing guide

Research direction

Start by tracing TimerThread::run_and_delete, unschedule, and bthread_timer_del, focusing on the memory_order_relaxed operation shown in the issue. Review the concurrent paths and existing timer tests to determine whether unschedule can race with cleanup. Done means a justified memory-order change, or evidence that the current ordering is safe, with regression coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.