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

OR + incorrect bound null causes segfault

    XMLWordPrintable

Details

    Description

      Firstly I apologise that my reproduction testcase is in PHP, I have tried to reproduce it on the command line using PREPARE but cannot - so I am suspecting maybe the mysqlnd driver but it is beyond my understanding which bit is failing.

      I have tried it on 2 different servers with the same result.

      Test Case

      CREATE TABLE `testdb`.`t` (
       `id` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL
      ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
      

      try {
      	mysqli_report(MYSQLI_REPORT_ERROR |MYSQLI_REPORT_STRICT);
       
      	$mysqli = new \mysqli('localhost','username','password');
       
      	$prepare = $mysqli->prepare("
      		SELECT id 
      		FROM `testdb`.`t` 
      		WHERE id = ? OR id = ? 
      	");
       
      	$p1 = '';
      	$p2 = null;
       
      	$prepare->bind_param('ss',$p1, $p2);
       
      	$prepare->execute();
      } catch (\mysqli_sql_exception $e) {
      	print_r($e);
      }
      

      Expected

      Nothing

      Actual

      MariaDB crashes with a segfault:

      200326 16:05:40 [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.4.12-MariaDB-log
      key_buffer_size=402653184
      read_buffer_size=2097152
      max_used_connections=6
      max_threads=1026
      thread_count=15
      It is possible that mysqld could use up to
      key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 4621016 K  bytes of memory
      Hope that's ok; if not, decrease some variables in the equation.
       
      Thread pointer: 0x7fe0fc0009a8
      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...
      stack_bottom = 0x7fe1c0060cf0 thread_stack 0x49000
      /usr/sbin/mysqld(my_print_stacktrace+0x2e)[0x561f86e17a1e]
      /usr/sbin/mysqld(handle_fatal_signal+0x30f)[0x561f868abd8f]
      sigaction.c:0(__restore_rt)[0x7fe1ca8625f0]
      /usr/sbin/mysqld(_Z7sortcmpPK6StringS1_PK15charset_info_st+0xe)[0x561f8671d40e]
      /usr/sbin/mysqld(_ZNK26Type_handler_string_result13Item_const_eqEPK10Item_constS2_b+0x9a)[0x561f867d403a]
      /usr/sbin/mysqld(_ZN4Item15eq_by_collationEPS_bPK15charset_info_st+0x3f)[0x561f868d177f]
      /usr/sbin/mysqld(_ZN9Item_cond14add_key_fieldsEP4JOINPP9KEY_FIELDPjyPP14SARGABLE_PARAM+0x2a1)[0x561f866c1591]
      /usr/sbin/mysqld(+0x6daae1)[0x561f866c8ae1]
      /usr/sbin/mysqld(_ZN4JOIN14optimize_innerEv+0x1663)[0x561f866f0d93]
      /usr/sbin/mysqld(_ZN4JOIN8optimizeEv+0x9d)[0x561f866f2bad]
      /usr/sbin/mysqld(_Z12mysql_selectP3THDP10TABLE_LISTjR4ListI4ItemEPS4_jP8st_orderS9_S7_S9_yP13select_resultP18st_select_lex_unitP13st_select_lex+0xe1)[0x561f866f2                                                  cb1]
      /usr/sbin/mysqld(_Z13handle_selectP3THDP3LEXP13select_resultm+0x1d7)[0x561f866f38c7]
      /usr/sbin/mysqld(+0x59f3d4)[0x561f8658d3d4]
      /usr/sbin/mysqld(_Z21mysql_execute_commandP3THD+0x467d)[0x561f866994fd]
      /usr/sbin/mysqld(_ZN18Prepared_statement7executeEP6Stringb+0x4b6)[0x561f866b1cc6]
      /usr/sbin/mysqld(_ZN18Prepared_statement12execute_loopEP6StringbPhS2_+0x92)[0x561f866b1e82]
      /usr/sbin/mysqld(+0x6c47e7)[0x561f866b27e7]
      /usr/sbin/mysqld(_Z19mysqld_stmt_executeP3THDPcj+0x27)[0x561f866b2877]
      /usr/sbin/mysqld(_Z16dispatch_command19enum_server_commandP3THDPcjbb+0x17f5)[0x561f866a0f85]
      /usr/sbin/mysqld(_Z10do_commandP3THD+0x11c)[0x561f866a2a4c]
      /usr/sbin/mysqld(_Z24do_handle_one_connectionP7CONNECT+0x1fa)[0x561f8678132a]
      /usr/sbin/mysqld(handle_one_connection+0x3d)[0x561f8678140d]
      pthread_create.c:0(start_thread)[0x7fe1ca85ae65]
      /lib64/libc.so.6(clone+0x6d)[0x7fe1c8bfb88d]
       
      Trying to get some variables.
      Some pointers may be invalid and cause the dump to abort.
      Query (0x7fe0fc00fe20): SELECT id       FROM `generaldb`.`test_crash`       WHERE id = '' OR id = NULL
      Connection ID (thread ID): 519
      Status: NOT_KILLED
       
      Optimizer switch: index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pu                                                  shdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_ma                                                  tch_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,joi                                                  n_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equ                                                  alities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
       
      The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
      information that should help you find out what is causing the crash.
      Writing a core file...
      Working directory at /mnt/storage/database/mysql
      Resource Limits:
      Limit                     Soft Limit           Hard Limit           Units
      Max cpu time              unlimited            unlimited            seconds
      Max file size             unlimited            unlimited            bytes
      Max data size             unlimited            unlimited            bytes
      Max stack size            8388608              unlimited            bytes
      Max core file size        0                    unlimited            bytes
      Max resident set          unlimited            unlimited            bytes
      Max processes             63133                63133                processes
      Max open files            16364                16364                files
      Max locked memory         65536                65536                bytes
      Max address space         unlimited            unlimited            bytes
      Max file locks            unlimited            unlimited            locks
      Max pending signals       63133                63133                signals
      Max msgqueue size         819200               819200               bytes
      Max nice priority         0                    0
      Max realtime priority     0                    0
      Max realtime timeout      unlimited            unlimited            us
      Core pattern: |/usr/libexec/abrt-hook-ccpp %s %c %p %u %g %t e %P %I %h
      

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              ChrisHSandN Chris Hewett
              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.