[MDEV-27170] TSAN: data race in mysqld_main when disabling InnoDB, setting Aria as the default SE Created: 2021-12-05 Updated: 2023-04-27 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - Aria |
| Affects Version/s: | 10.3, 10.4, 10.5, 10.6, 10.7, 10.8 |
| Fix Version/s: | 10.4, 10.5, 10.6 |
| Type: | Bug | Priority: | Major |
| Reporter: | Roel Van de Paar | Assignee: | Michael Widenius |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | not-10.2, regression-10.3 | ||
| Description |
|
Leads to:
Setup:
Bug confirmed present in: Bug (or feature/syntax) confirmed not present in: |
| Comments |
| Comment by Marko Mäkelä [ 2021-12-05 ] | |||||||||
|
If I understood correctly, the reported problem is that some code is accessing global_status_var.global_memory_used without an atomic memory operation. Example:
Side note: Do we still need a workaround for such an old compiler? The minimum requirement of 10.4 or later is GCC 4.8.5, to have enough support of C++11. In the above code, the DBUG_PRINT macro is reading the variable without using a proper atomic operation. That too should be flagged as a data race. The proper way would be to invoke the equivalent of std::atomic::fetch_add(std::memory_order_relaxed only once, and pass the return value to the DBUG_PRINT macro. On IA-32 and AMD64, the fetch_add() and fetch_sub() will translate into the 80486 instruction LOCK XADD. Likewise, in other accesses of global_status_var.global_memory_order, the equivalent of std::atomic::load(std::memory_order_relaxed) should be used. In processors with a strong memory model, atomic loads and stores do not differ at all from regular loads and stores. See https://www.cl.cam.ac.uk/~pes20/cpp/cpp0xmappings.html for some examples. It could be simplest to declare global_status_var.global_memory_order as Atomic_relaxed<int64>. In that way, all accesses are guaranteed to be atomic. |