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

UBSAN: runtime error: signed integer overflow: 2148 * 1000000 cannot be represented in type 'int'

Details

    Description

      # mysqld options required for replay:  --thread_handling=pool-of-threads
      SET GLOBAL thread_pool_stall_limit=2148;  # >=2148 triggers the issue
      

      Valid values for thread-pool-stall-limit are 10 to 4294967295. However, when using >= 2148, we see this UBSAN error:

      11.5.0 3f9182126c64bcec359bebe9ebad2a0e559b13e2 (Debug)

      /test/11.5_dbg_san/sql/threadpool_generic.cc:572:5: runtime error: signed integer overflow: 2148 * 1000000 cannot be represented in type 'int'
          #0 0x56219dda558b in timer_thread /test/11.5_dbg_san/sql/threadpool_generic.cc:572
          #1 0x1553aca8f189 in start_thread nptl/pthread_create.c:444
          #2 0x1553acb1dbcf in clone3 ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
      

      Setup:

      Compiled with a recent version of GCC (I use GCC 12.3.0) and:
          -DWITH_ASAN=ON -DWITH_ASAN_SCOPE=ON -DWITH_UBSAN=ON -DWSREP_LIB_WITH_ASAN=ON
      Set before execution:
          export ASAN_OPTIONS=quarantine_size_mb=512:atexit=0:detect_invalid_pointer_pairs=3:dump_instruction_bytes=1:abort_on_error=1:allocator_may_return_null=1
      

      Present in 10.5-11.5 dbg+opt.

      Attachments

        Activity

          MTR readily reproduces the issue in an UBSAN+ASAN build with:

          # Command: ./mtr --mysqld=--thread_handling=pool-of-threads test
          SET GLOBAL thread_pool_stall_limit=2148;  # >=2148 triggers the issue
          

          11.5.0 3f9182126c64bcec359bebe9ebad2a0e559b13e2 (Debug, UBASAN)

          SET GLOBAL thread_pool_stall_limit=2148;
          main.test                                [ fail ]  Found warnings/errors in server log file!
                  Test ended at 2024-05-03 17:10:24
          line
          /test/11.5_dbg_san/sql/threadpool_generic.cc:572:5: runtime error: signed integer overflow: 2148 * 1000000 cannot be represented in type 'int'
          ^ Found warnings in /test/UBASAN_MD240424-mariadb-11.5.0-linux-x86_64-dbg/mariadb-test/var/log/mysqld.1.err
          

          Though the stack is not included in the error log, unlike when using the CLI.

          Roel Roel Van de Paar added a comment - MTR readily reproduces the issue in an UBSAN+ASAN build with: # Command: ./mtr --mysqld=--thread_handling=pool-of-threads test SET GLOBAL thread_pool_stall_limit=2148; # >=2148 triggers the issue 11.5.0 3f9182126c64bcec359bebe9ebad2a0e559b13e2 (Debug, UBASAN) SET GLOBAL thread_pool_stall_limit=2148; main.test [ fail ] Found warnings/errors in server log file! Test ended at 2024-05-03 17:10:24 line /test/11.5_dbg_san/sql/threadpool_generic.cc:572:5: runtime error: signed integer overflow: 2148 * 1000000 cannot be represented in type 'int' ^ Found warnings in /test/UBASAN_MD240424-mariadb-11.5.0-linux-x86_64-dbg/mariadb-test/var/log/mysqld.1.err Though the stack is not included in the error log, unlike when using the CLI.

          Thank you wlad for the VERY quick turnaround.

          Roel Roel Van de Paar added a comment - Thank you wlad for the VERY quick turnaround.

          People

            wlad Vladislav Vaintroub
            Roel Roel Van de Paar
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.