Bug #87068 always enable safe_mutex in debug builds, make memcached ubsan clean
Submitted: 14 Jul 2017 10:08 Modified: 23 Aug 2017 0:00
Reporter: Tor Didriksen Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:8.0.3 OS:Any
Assigned to: CPU Architecture:Any

[14 Jul 2017 10:08] Tor Didriksen
Description:
CMakeLists.txt contains this snippet:

# Add safemutex for debug configurations
IF(NOT WITH_INNODB_MEMCACHED)
  FOREACH(LANG C CXX)
      SET(CMAKE_${LANG}_FLAGS_DEBUG
          "${CMAKE_${LANG}_FLAGS_DEBUG} -DSAFE_MUTEX")
  ENDFOREACH()
ENDIF()

There should be no reason to disable safe_mutex if we build the memcached plugin.
Enabling it, and running with UBSAN shows a few issues, with wrong mutex usage, and undefined behaviour.

How to repeat:
Read the code
Run memcached test suite with UBSAN

Suggested fix:
See description.
[23 Aug 2017 0:00] Paul DuBois
Posted by developer:
 
Fixed in 8.0.3.

For debug builds, the SAFE_MUTEX compilation flag was disabled if the
memcached plugin was included in the build. This no longer occurs;
SAFE_MUTEX is alwys enabled for debug builds. Some code issues found
as a result of this change were corrected.