Fix ABA and UAF problem in ConditionVariable notify operation using internal spinlock (#458)#459
Conversation
…baba#458) Serialize notifyOne and notifyAll with an internal SpinLock (MPSC model) to prevent Use-After-Free and ABA memory corruption during concurrent pops, while preserving the lock-free performance of wait().
|
应该是cppm的依赖顺序问题,我去调一下 |
|
@poor-circle @ChuanqiXu9 非常感谢两位大佬的指导,ci问题已修复,麻烦大佬们再帮忙Review一下。 |
|
The diff you sent is not formatted correctly.
这个格式错误如果要更改的话,我怕影响到本来的先后依赖关系,Clang Format想全部按照字母顺序排。 |
没事,format 不是强制检查。你签一下 CLA 吧,不然没法合 |
好的,已同意。谢谢Review@ChuanqiXu9 |
这个项目的头文件在 bazel 构建中没有使用 |
在普通的 Bazel 构建下它确实是自包含的。但是在 .cppm 模块化构建时,由于开启了 ASYNC_SIMPLE_USE_MODULES 宏,ConditionVariable.h 内部的 #include "SpinLock.h" 被 #ifndef 屏蔽了,导致在 .cppm 内部失去了自包含特性,所以这两个文件产生了先后顺序依赖。 那我再操作一下// clang-format off 和 // clang-format on 隔离一下这个代码块,感谢@c8ef |
Fixes(#458)
Why
修复并发操作ConditionVariable的notify可能会导致UAF和ABA的线程安全问题
What is changing
给ConditionVariable的notify操作加了自旋锁,专门使notify操作串行化