Bug #93105 writing to ‘struct buf_buddy_free_t’ with no trivial copy-assignment
Submitted: 7 Nov 2018 12:34 Modified: 13 Nov 2018 11:16
Reporter: Przemysław Skibiński (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:8.0.13, 5.7.24 OS:Linux
Assigned to: CPU Architecture:Any
Tags: valgrind

[7 Nov 2018 12:34] Przemysław Skibiński
Description:
Compilation on Ubuntu 18.04 with valgrind 3.13.0 and gcc-8.2.0 fails with:

In file included from /mysql-8.0/storage/innobase/include/ut0counter.h:42,
                 from /mysql-8.0/storage/innobase/include/sync0sync.h:45,
                 from /mysql-8.0/storage/innobase/include/sync0types.h:39,
                 from /mysql-8.0/storage/innobase/include/univ.i:590,
                 from /mysql-8.0/storage/innobase/include/os0event.h:37,
                 from /mysql-8.0/storage/innobase/include/buf0types.h:36,
                 from /mysql-8.0/storage/innobase/include/buf0buddy.h:41,
                 from /mysql-8.0/storage/innobase/buf/buf0buddy.cc:33:
/mysql-8.0/storage/innobase/buf/buf0buddy.cc: In function ‘buf_buddy_free_t* buf_buddy_alloc_zip(buf_pool_t*, ulint)’:
/mysql-8.0/storage/innobase/include/univ.i:631:30: error: ‘void* memset(void*, int, size_t)’ writing to an object of type ‘struct buf_buddy_free_t’ with no trivial copy-assignment [-Werror=class-memaccess]
     ut_d(memset(addr, c, size));      \
                              ^
/mysql-8.0/storage/innobase/include/ut0dbg.h:62:20: note: in definition of macro ‘ut_d’
 #define ut_d(EXPR) EXPR
                    ^~~~
/mysql-8.0/storage/innobase/buf/buf0buddy.cc:327:5: note: in expansion of macro ‘UNIV_MEM_TRASH’
     UNIV_MEM_TRASH(buf, ~i, BUF_BUDDY_STAMP_OFFSET);
     ^~~~~~~~~~~~~~
In file included from /mysql-8.0/storage/innobase/include/buf0buddy.ic:39,
                 from /mysql-8.0/storage/innobase/include/buf0buddy.h:76,
                 from /mysql-8.0/storage/innobase/buf/buf0buddy.cc:33:
/mysql-8.0/storage/innobase/include/buf0buf.h:1609:8: note: ‘struct buf_buddy_free_t’ declared here
 struct buf_buddy_free_t {
        ^~~~~~~~~~~~~~~~         

How to repeat:
cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_CONFIG=mysql_release -DFEATURE_SET=community -DREPRODUCIBLE_BUILD=OFF -DENABLE_DOWNLOADS=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=../deps -DMYSQL_MAINTAINER_MODE=ON -DWITH_MECAB=system -DWITH_ICU=bundled -DWITH_VALGRIND=ON
[7 Nov 2018 16:27] MySQL Verification Team
Thank you for the bug report. Looks like the issue here is the default gcc flag -W:

cc1plus: all warnings being treated as errors
storage/innobase/CMakeFiles/innobase.dir/build.make:302: recipe for target 'storage/innobase/CMakeFiles/innobase.dir/buf/buf0buddy.cc.o' failed
make[2]: *** [storage/innobase/CMakeFiles/innobase.dir/buf/buf0buddy.cc.o] Error 1

Using -w it compiles:

Scanning dependencies of target master_key_test_writer
[100%] Building CXX object router/tests/component/CMakeFiles/master_key_test_writer.dir/__/helpers/master_key_test_writer.cc.o
[100%] Linking CXX executable ../../../runtime_output_directory/master_key_test_writer
[100%] Built target master_key_test_writer
Scanning dependencies of target test_component_routing_connection
[100%] Building CXX object router/tests/component/CMakeFiles/test_component_routing_connection.dir/test_routing_connection.cc.o
[100%] Linking CXX executable ../../../runtime_output_directory/test_component_routing_connection
[100%] Built target test_component_routing_connection
miguel@tikal:~/tmp/mysql-8.0.13 $ lsb_release -a && gcc --version && valgrind --version
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.1 LTS
Release:        18.04
Codename:       bionic
gcc (Ubuntu 8.2.0-1ubuntu2~18.04) 8.2.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

valgrind-3.13.0
miguel@tikal:~/tmp/mysql-8.0.13 $ cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_CONFIG=mysql_release -DFEATURE_SET=community -DREPRODUCIBLE_BUILD=OFF -DENABLE_DOWNLOADS=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=../deps -DMYSQL_MAINTAINER_MODE=ON -DWITH_MECAB=system -DWITH_ICU=bundled -DWITH_VALGRIND=ON -DCMAKE_C_FLAGS=-w -DCMAKE_CXX_FLAGS=-w
[8 Nov 2018 7:09] Tor Didriksen
Fixed in 8.0.14 by

commit 3f8b46668352becdcc3a4dfef35c89b889bb4877
Author: Tor Didriksen <tor.didriksen@oracle.com>
Date:   Fri Sep 28 14:26:27 2018 +0200

    Bug #26826272: REMOVE GCC 8 WARNINGS
   
    Post-push fix for UNIV_MEM_TRASH which is use for WITH_VALGRIND build.
   
    Same as TRASH macro: do memset through a void pointer to avoid
    error: 'void* memset(void*, int, size_t)'
    writing to an object of type 'struct buf_buddy_free_t'
    with no trivial copy-assignment [-Werror=class-memaccess]
[13 Nov 2018 10:12] Przemysław Skibiński
The issue also concerns 5.7.24