SQLite Forum

SQLIte 3.37.0 breaks SQLITE_OPEN_NOMUTEX - TSAN failure
Login
You appear to be building with -DSQLITE_DEBUG.

The races are occurring inside the testcase() macro.  This macro is for
testing only and is a no-op
for release builds, so the races cannot occur release build.
For debugging builds,
the testcase() macro increments a global variable (to prevent the compiler
from optimizing it out) and that global variable is not protected by mutex.
Two threads hitting a testcase() macro at the same time might therefore
generate a race condition.  But as the global variable is never used for
anything, and exists purely to defeat compiler optimizations, no harm can
come up this.  And, of course, the global variable does not even exist
for release builds.

Your fix is to remove the -DSQLITE_DEBUG compile-time option
for release builds and for TSAN builds.

The change in 3.37.0 that appears to have caused this TSAN report is
that the testcase() macro used to only be defined
for -DSQLITE_COVERAGE_TEST, but is now also defined for -DSQLITE_DEBUG.