You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by Zhanhui Li <li...@apache.org> on 2022/01/11 09:54:45 UTC

Thread Safety Analysis Project

Hi RocketMQ CPP SDK developers,

Existing codebase makes heavy use of STL containers, which requires
external synchronization when concurrent read/write access happens.  Even
though we have employed technics like RAII(lock_guard) to ensure locks are
properly used and unlocked. Still there are potential risks uncovered. This
noticeably raises the bar for new contributors.

This challenge is not unique to us, instead, developers from various roles
are attempting to meet this challenge.
Guys from google published the following articles:
https://static.googleusercontent.com/media/research.google.com/zh-CN//pubs/archive/42958.pdf
https://llvm.org/devmtg/2011-11/Hutchins_ThreadSafety.pdf
Then compilers including GCC and Clang supports static thread analysis.
Abseil, open-sourced common library at Google, includes tools and macros to
ease application of this feature:
https://github.com/abseil/abseil-cpp/blob/master/absl/base/thread_annotations.h
and this guide: https://abseil.io/docs/cpp/guides/synchronization

I am proposing annotate our containers and mutex, functions to perform
thread sanitizing at build time.

Any comment is welcome and looking for guys having interest in this.

Zhanhui Li