From 828cc2ba7cdbe47c55fd679437e6e7f0bc714dff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 27 Mar 2019 11:34:53 +0200 Subject: [PATCH] MDEV-18417/MDEV-18656/MDEV-18417: Work around compiler ASAN bug In a Ubuntu Xenial build environment, the compiler identified as g++-5.real (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609 seems to be emitting incorrect code for the compilation unit trx0rec.cc, triggering a bogus-looking AddressSanitizer report of an invalid read of something in the function trx_undo_rec_get_pars(). This is potentially affecting any larger tests where the InnoDB purge subsystem is being exercised. When the optimization level of trx0rec.cc is limited to -O1, no bogus failure is being reported. With -O2 or -O3, a lot of things seemed to be inlined in the function, and the disassembly of the generated code did not make sense to me. --- storage/innobase/CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt index 18efa58b2a3..c3cb0ce94c6 100644 --- a/storage/innobase/CMakeLists.txt +++ b/storage/innobase/CMakeLists.txt @@ -1,4 +1,5 @@ # Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2019, MariaDB Corporation. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -74,6 +75,12 @@ SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DUNIV_DEBUG -DUNIV_SYNC_DEB CHECK_FUNCTION_EXISTS(sched_getcpu HAVE_SCHED_GETCPU) IF(NOT MSVC) + # Work around MDEV-18417, MDEV-18656, MDEV-18417 + IF(WITH_ASAN AND CMAKE_COMPILER_IS_GNUCC AND + CMAKE_C_COMPILER_VERSION VERSION_LESS "6.0.0") + SET_SOURCE_FILES_PROPERTIES(trx/trx0rec.cc PROPERTIES COMPILE_FLAGS -O1) + ENDIF() + # either define HAVE_IB_GCC_ATOMIC_BUILTINS or not # workaround for old gcc on x86, gcc atomic ops only work under -march=i686 IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "i686" AND CMAKE_COMPILER_IS_GNUCC AND