Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-10335

Galera initialization breaks when compiled with gcc 6 or --std=c++11

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.1.14, 10.1.15
    • 10.0.27-galera
    • wsrep
    • fedora 24

    Description

      In the WSREP file wsrep_mysqld.cc, there is an unexpected const
      qualifier on static global variable cluster_uuid.

      static const wsrep_uuid_t cluster_uuid = WSREP_UUID_UNDEFINED;

      From a compilation standpoint, this variable being initialized
      from the value of another variable WSREP_UUID_UNDEFINED, the
      C++ compiler used to perform the init at runtime, and to emit
      variable cluster_uuid in segment .bss rather than .rodata.
      Incidentally, that is why further write accesses to the address of
      that variable succeed (e.g. in wsrep_view_handler_cb()).

      Now starting with gcc 6.0, or when using gcc 5.x with -std=c++11,
      the C++ compiler determines that cluster_uuid is being initialized
      from a constant value, and so decides to emit variable cluster_uuid
      in segment .rodata with value set at compile-time.

      Any write to cluster_uuid's address will end up in SIGSEGV, which prevents
      using the Galera replication.

      For the record, this bug has been reported as well at https://github.com/codership/mysql-wsrep/issues/267

      Reproducer:

      Ensure the following variable are set in /etc/my.cnf

      [galera]

      1. Mandatory settings
        wsrep_on=ON
        wsrep_provider=/usr/lib64/galera/libgalera_smm.so
        wsrep_cluster_address=gcomm://
        wsrep_cluster_name=galera
        binlog_format=row
        default_storage_engine=InnoDB
        innodb_autoinc_lock_mode=2

      Start a new galera cluster, and wait for a segfault to happen.

      [root@fedora2 ~]# mysqld_safe --wsrep-new-cluster
      160705 12:34:43 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
      160705 12:34:43 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
      160705 12:34:43 mysqld_safe WSREP: Running position recovery with --log_error='/var/lib/mysql/wsrep_recovery.X8ZxeH' --pid-file='/var/lib/mysql/fedora2.localdomain-recover.pid'
      160705 12:34:46 mysqld_safe WSREP: Recovered position 00000000-0000-0000-0000-000000000000:-1
      /usr/bin/mysqld_safe: line 188: 1799 Segmentation fault (core dumped) nohup /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --wsrep_provider=/usr/lib64/galera/libgalera_smm.so --wsrep-new-cluster --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/var/lib/mysql/mysql.sock --wsrep_start_position=00000000-0000-0000-0000-000000000000:-1 < /dev/null >> /var/log/mariadb/mariadb.log 2>&1
      160705 12:34:46 mysqld_safe mysqld from pid file /var/run/mariadb/mariadb.pid ended

      The mariadb.log should log the context of the dump:

      160705 12:34:46 [ERROR] mysqld got signal 11 ;
      This could be because you hit a bug. It is also possible that this binary
      or one of the libraries it was linked against is corrupt, improperly built,
      or misconfigured. This error can also be caused by malfunctioning hardware.

      To report this bug, see https://mariadb.com/kb/en/reporting-bugs

      We will try our best to scrape up some info that will hopefully help
      diagnose the problem, but since we have already crashed,
      something is definitely wrong and this may fail.

      Server version: 10.1.14-MariaDB
      key_buffer_size=0
      read_buffer_size=131072
      max_used_connections=0
      max_threads=153
      thread_count=2
      It is possible that mysqld could use up to
      key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 336041 K bytes of memory
      Hope that's ok; if not, decrease some variables in the equation.

      Thread pointer: 0x0x7f4e38000998
      Attempting backtrace. You can use the following information to find out
      where mysqld died. If you see no messages after this, something went
      terribly wrong...
      2016-07-05 12:34:46 139974166951680 [Note] WSREP: Member 0.0 () synced with group.
      2016-07-05 12:34:46 139974166951680 [Note] WSREP: Shifting JOINED -> SYNCED (TO: 0)
      stack_bottom = 0x7f4e54072d18 thread_stack 0x48400
      /usr/libexec/mysqld(my_print_stacktrace+0x2e)[0x565322e6f39e]
      /usr/libexec/mysqld(handle_fatal_signal+0x3f5)[0x5653229b4d25]
      /lib64/libpthread.so.0(+0x10c10)[0x7f4e5a210c10]
      /usr/libexec/mysqld(+0x53928e)[0x56532295328e]
      /usr/lib64/galera/libgalera_smm.so(_ZN6galera13ReplicatorSMM19process_conf_changeEPvRK15wsrep_view_infoiNS_10Replicator5StateEl+0x38a)[0x7f4e553e178a]
      /usr/lib64/galera/libgalera_smm.so(_ZN6galera15GcsActionSource8dispatchEPvRK10gcs_actionRb+0x54b)[0x7f4e553baa7b]
      /usr/lib64/galera/libgalera_smm.so(_ZN6galera15GcsActionSource7processEPvRb+0x76)[0x7f4e553bc166]
      /usr/lib64/galera/libgalera_smm.so(_ZN6galera13ReplicatorSMM10async_recvEPv+0x86)[0x7f4e553e0f46]
      /usr/lib64/galera/libgalera_smm.so(galera_recv+0x2e)[0x7f4e553fb61e]
      /usr/libexec/mysqld(+0x5483f7)[0x5653229623f7]
      /usr/libexec/mysqld(start_wsrep_THD+0x484)[0x565322951ef4]
      /lib64/libpthread.so.0(+0x75ba)[0x7f4e5a2075ba]
      /lib64/libc.so.6(clone+0x6d)[0x7f4e5871a7cd]

      Attachments

        Issue Links

          Activity

            People

              nirbhay_c Nirbhay Choubey (Inactive)
              dciabrin Damien Ciabrini
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.