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

SIGSEGV in store_duckdb_field_in_mysql_format and Got error 168 on ALTER TABLE

    XMLWordPrintable

Details

    Description

      --source include/have_partition.inc
      INSTALL SONAME 'ha_duckdb';
      CREATE TABLE t (c1 INT KEY) ENGINE=DuckDB;
      INSERT INTO t VALUES (1),(1);
      --error ER_GET_ERRMSG
      ALTER TABLE t ADD c2 INT NOT NULL;
      ALTER TABLE t PARTITION BY HASH (c1) (PARTITION p1,PARTITION p2);
      

      Leads to:

      CS 13.1.0 934108aab5cb541b3fc09672b5d4090558ab408e (Debug, Clang 22.1.8-20260622) Build 22/07/2026

      13.1.0-dbg>ALTER TABLE t ADD c2 INT NOT NULL;
      ERROR 1296 (HY000): Got error 168 'Constraint Error: NOT NULL constraint failed: t.c2' from DuckDB
      13.1.0-dbg>ALTER TABLE t PARTITION BY HASH (c1) (PARTITION p1,PARTITION p2);
       
      ERROR 2026 (HY000): TLS/SSL error: The TLS connection was non-properly terminated.
      

      CS 13.1.0 934108aab5cb541b3fc09672b5d4090558ab408e (Optimized, Clang 22.1.8-20260622) Build 22/07/2026

      Core was generated by `/test/MD220726-mariadb-13.1.0-linux-x86_64-opt/bin/mariadbd --no-defaults --loo'.
      Program terminated with signal SIGSEGV, Segmentation fault.
      #0  store_duckdb_field_in_mysql_format (field=0x0, value=..., thd=thd@entry=0x6c52b0000c70)at /test/13.1_opt/storage/duckdb/convertor/duckdb_select.cc:55
       
      [Current thread is 1 (LWP 1118577)]
      (gdb) bt
      #0  store_duckdb_field_in_mysql_format (field=0x0, value=@0x7453cc3c8a30: <incomplete type>, thd=thd@entry=0x6c52b0000c70)at /test/13.1_opt/storage/duckdb/convertor/duckdb_select.cc:55
      #1  0x00006c530d814acc in ha_duckdb::rnd_next (this=0x6c52b035b910, buf=0x6c52b035bf60 "") at /test/13.1_opt/storage/duckdb/ha_duckdb.cc:690
      #2  0x00005b66ce8a8f6f in handler::ha_rnd_next (this=0x6c52b035b910, buf=0x6c52b035bf60 "") at /test/13.1_opt/sql/handler.cc:4045
      #3  0x00005b66cea407a9 in rr_sequential (info=0x7453cc3c8b50)at /test/13.1_opt/sql/records.cc:509
      #4  0x00005b66cec568a0 in READ_RECORD::read_record (this=0x7453cc3c8b50)at /test/13.1_opt/sql/records.h:77
      #5  copy_data_between_tables (thd=thd@entry=0x6c52b0000c70, from=from@entry=0x6c52b032a740, to=to@entry=0x6c52b03560a0, ignore=false, order_num=0, order=<optimized out>, copied=0x7453cc3ca2a8, deleted=0x7453cc3ca2b0, alter_info=0x7453cc3ccb20, alter_ctx=0x7453cc3cac98, online=<optimized out>, start_alter_id=0)at /test/13.1_opt/sql/sql_table.cc:12824
      #6  0x00005b66cec50a98 in mysql_alter_table (thd=thd@entry=0x6c52b0000c70, new_db=new_db@entry=0x6c52b0005b38, new_name=new_name@entry=0x6c52b0005fd0, create_info=create_info@entry=0x7453cc3ccc98, table_list=0x6c52b0017d30, recreate_info=recreate_info@entry=0x7453cc3cc3c0, alter_info=0x7453cc3ccb20, order_num=0, order=0x0, ignore=<optimized out>, if_exists=<optimized out>) at /test/13.1_opt/sql/sql_table.cc:11958
      #7  0x00005b66cecdc248 in Sql_cmd_alter_table::execute (this=<optimized out>, thd=0x6c52b0000c70) at /test/13.1_opt/sql/sql_alter.cc:697
      #8  0x00005b66ceb7f673 in mysql_execute_command (thd=thd@entry=0x6c52b0000c70, is_called_from_prepared_stmt=false) at /test/13.1_opt/sql/sql_parse.cc:5905
      #9  0x00005b66ceb7ae2d in mysql_parse (thd=thd@entry=0x6c52b0000c70, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x7453cc3cd4e0)at /test/13.1_opt/sql/sql_parse.cc:7958
      #10 0x00005b66ceb79605 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x6c52b0000c70, packet=packet@entry=0x6c52b0008e01 "ALTER TABLE t PARTITION BY HASH (c1) (PARTITION p1,PARTITION p2)", packet_length=packet_length@entry=64, blocking=true)at /test/13.1_opt/sql/sql_parse.cc:1903
      #11 0x00005b66ceb7b2b0 in do_command (thd=thd@entry=0x6c52b0000c70, blocking=true) at /test/13.1_opt/sql/sql_parse.cc:1437
      #12 0x00005b66cecd44fd in do_handle_one_connection (connect=<optimized out>, connect@entry=0x5b66d0a4e9a0, put_in_cache=true)at /test/13.1_opt/sql/sql_connect.cc:1510
      #13 0x00005b66cecd4332 in handle_one_connection (arg=arg@entry=0x5b66d0a4e9a0)at /test/13.1_opt/sql/sql_connect.cc:1422
      #14 0x00005b66cee98793 in pfs_spawn_thread (arg=0x5b66d0a6f400)at /test/13.1_opt/storage/perfschema/pfs.cc:2198
      #15 0x00007453d5a9ca94 in start_thread (arg=<optimized out>)at ./nptl/pthread_create.c:447
      #16 0x00007453d5b29c3c in clone3 ()at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
      

      CS 13.1.0 934108aab5cb541b3fc09672b5d4090558ab408e (Debug, Clang 22.1.8-20260622) Build 22/07/2026

      Core was generated by `/test/MD220726-mariadb-13.1.0-linux-x86_64-dbg/bin/mariadbd --no-defaults --loo'.
      Program terminated with signal SIGSEGV, Segmentation fault.
      #0  0x00006f91f4754d86 in store_duckdb_field_in_mysql_format (field=0x0, value=..., thd=0x6f91f8000d60)at /test/13.1_dbg/storage/duckdb/convertor/duckdb_select.cc:55
       
      [Current thread is 1 (LWP 1114441)]
      (gdb) bt
      #0  0x00006f91f4754d86 in store_duckdb_field_in_mysql_format (field=0x0, value=@0x77935cd1bf60: {type_ = {id_ = duckdb::LogicalTypeId::INTEGER, physical_type_ = duckdb::PhysicalType::INT32, type_info_ = {internal = std::shared_ptr<duckdb::ExtraTypeInfo> (empty) = {        get() = 0x0      }}, static SQLNULL = duckdb::LogicalTypeId::SQLNULL, static UNKNOWN = duckdb::LogicalTypeId::UNKNOWN, static BOOLEAN = duckdb::LogicalTypeId::BOOLEAN, static TINYINT = duckdb::LogicalTypeId::TINYINT, static UTINYINT = duckdb::LogicalTypeId::UTINYINT, static SMALLINT = duckdb::LogicalTypeId::SMALLINT, static USMALLINT = duckdb::LogicalTypeId::USMALLINT, static INTEGER = duckdb::LogicalTypeId::INTEGER, static UINTEGER = duckdb::LogicalTypeId::UINTEGER, static BIGINT = duckdb::LogicalTypeId::BIGINT, static UBIGINT = duckdb::LogicalTypeId::UBIGINT, static FLOAT = duckdb::LogicalTypeId::FLOAT, static DOUBLE = duckdb::LogicalTypeId::DOUBLE, static DATE = duckdb::LogicalTypeId::DATE, static TIMESTAMP = duckdb::LogicalTypeId::TIMESTAMP, static TIMESTAMP_S = duckdb::LogicalTypeId::TIMESTAMP_SEC, static TIMESTAMP_MS = duckdb::LogicalTypeId::TIMESTAMP_MS, static TIMESTAMP_NS = duckdb::LogicalTypeId::TIMESTAMP_NS, static TIME = duckdb::LogicalTypeId::TIME, static TIME_NS = duckdb::LogicalTypeId::TIME_NS, static TIMESTAMP_TZ = duckdb::LogicalTypeId::TIMESTAMP_TZ, static TIME_TZ = duckdb::LogicalTypeId::TIME_TZ, static VARCHAR = duckdb::LogicalTypeId::VARCHAR, static ANY = duckdb::LogicalTypeId::ANY, static BLOB = duckdb::LogicalTypeId::BLOB, static BIT = duckdb::LogicalTypeId::BIT, static BIGNUM = duckdb::LogicalTypeId::BIGNUM, static INTERVAL = duckdb::LogicalTypeId::INTERVAL, static HUGEINT = duckdb::LogicalTypeId::HUGEINT, static UHUGEINT = duckdb::LogicalTypeId::UHUGEINT, static UUID = duckdb::LogicalTypeId::UUID, static HASH = duckdb::LogicalTypeId::UBIGINT, static POINTER = duckdb::LogicalTypeId::POINTER, static TABLE = duckdb::LogicalTypeId::TABLE, static LAMBDA = duckdb::LogicalTypeId::LAMBDA, static INVALID = duckdb::LogicalTypeId::INVALID, static ROW_TYPE = duckdb::LogicalTypeId::BIGINT, static JSON_TYPE_NAME = <optimized out>}, is_null = true, value_ = {boolean = true, tinyint = 1 '\001', smallint = 1, integer = 1, bigint = 122668560941057, utinyint = 1 '\001', usmallint = 1, uinteger = 1, ubigint = 122668560941057, hugeint = {lower = 122668560941057, upper = 122672721693936}, uhugeint = {lower = 122668560941057, upper = 122672721693936}, float_ = 1.40129846e-45, double_ = 6.0606321785759637e-310, pointer = 122668560941057, hash = 122668560941057, date = {days = 1}, time = {micros = 122668560941057}, time_ns = {<duckdb::dtime_t> = {micros = 122668560941057}, <No data fields>}, timetz = {static TIME_BITS = 40, static OFFSET_BITS = 24, static OFFSET_MASK = 16777215, static MAX_OFFSET = 57599, static MIN_OFFSET = -57599, static OFFSET_MICROS = 1000000, bits = 122668560941057}, timestamp = {value = 122668560941057}, timestamp_s = {<duckdb::timestamp_t> = {value = 122668560941057}, <No data fields>}, timestamp_ms = {<duckdb::timestamp_t> = {value = 122668560941057}, <No data fields>}, timestamp_ns = {<duckdb::timestamp_t> = {value = 122668560941057}, <No data fields>}, timestamp_tz = {<duckdb::timestamp_t> = {value = 122668560941057}, <No data fields>}, interval = {months = 1, days = 28561, micros = 122672721693936}}, value_info_ = {internal = std::shared_ptr<duckdb::ExtraValueInfo> (empty) = {      get() = 0x0    }}}, thd=0x6f91f8000d60)at /test/13.1_dbg/storage/duckdb/convertor/duckdb_select.cc:55
      #1  0x00006f91f46cd865 in ha_duckdb::rnd_next (this=0x6f91f837e730, buf=0x6f91f837ed80 "") at /test/13.1_dbg/storage/duckdb/ha_duckdb.cc:690
      #2  0x000061fa43eb513c in handler::ha_rnd_next (this=0x6f91f837e730, buf=0x6f91f837ed80 "") at /test/13.1_dbg/sql/handler.cc:4045
      #3  0x000061fa4412f6b0 in rr_sequential (info=0x77935cd1c5b0)at /test/13.1_dbg/sql/records.cc:509
      #4  0x000061fa4410e996 in READ_RECORD::read_record (this=0x77935cd1c5b0)at /test/13.1_dbg/sql/records.h:77
      #5  0x000061fa4448881b in copy_data_between_tables (thd=0x6f91f8000d60, from=0x6f91f8386160, to=0x6f91f833a010, ignore=false, order_num=0, order=0x0, copied=0x77935cd1f040, deleted=0x77935cd1f038, alter_info=0x77935cd21de8, alter_ctx=0x77935cd1fdb8, online=true, start_alter_id=0) at /test/13.1_dbg/sql/sql_table.cc:12824
      #6  0x000061fa4447f5c7 in mysql_alter_table (thd=0x6f91f8000d60, new_db=0x6f91f8005c00, new_name=0x6f91f8006098, create_info=0x77935cd21f60, table_list=0x6f91f801a590, recreate_info=0x77935cd21668, alter_info=0x77935cd21de8, order_num=0, order=0x0, ignore=false, if_exists=false)at /test/13.1_dbg/sql/sql_table.cc:11958
      #7  0x000061fa44553e38 in Sql_cmd_alter_table::execute (this=0x6f91f801b210, thd=0x6f91f8000d60) at /test/13.1_dbg/sql/sql_alter.cc:697
      #8  0x000061fa4434f9cb in mysql_execute_command (thd=0x6f91f8000d60, is_called_from_prepared_stmt=false) at /test/13.1_dbg/sql/sql_parse.cc:5905
      #9  0x000061fa44340ab8 in mysql_parse (thd=0x6f91f8000d60, rawbuf=0x6f91f801a430 "ALTER TABLE t PARTITION BY HASH (c1) (PARTITION p1,PARTITION p2)", length=64, parser_state=0x77935cd239c0)at /test/13.1_dbg/sql/sql_parse.cc:7958
      #10 0x000061fa4433e1de in dispatch_command (command=COM_QUERY, thd=0x6f91f8000d60, packet=0x6f91f800b661 "ALTER TABLE t PARTITION BY HASH (c1) (PARTITION p1,PARTITION p2)", packet_length=64, blocking=true)at /test/13.1_dbg/sql/sql_parse.cc:1903
      #11 0x000061fa4434153a in do_command (thd=0x6f91f8000d60, blocking=true)at /test/13.1_dbg/sql/sql_parse.cc:1437
      #12 0x000061fa44547d0e in do_handle_one_connection (connect=0x61fa47fd1d80, put_in_cache=true) at /test/13.1_dbg/sql/sql_connect.cc:1510
      #13 0x000061fa44547af1 in handle_one_connection (arg=0x61fa47fade60)at /test/13.1_dbg/sql/sql_connect.cc:1422
      #14 0x000077935fc9ca94 in start_thread (arg=<optimized out>)at ./nptl/pthread_create.c:447
      #15 0x000077935fd29c3c in clone3 ()at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
      

      Bug Detection Matrix

          Rel    o/d  Build   Commit                                    UniqueID observed             
      CS  10.6   dbg  220726  5520c9aac5b6a5a9ea60d78582ddffa5349e2d0f  No bug found                  
      CS  10.6   opt  220726  5520c9aac5b6a5a9ea60d78582ddffa5349e2d0f  No bug found                  
      CS  10.11  dbg  220726  6268f6023fe3e8dc8ec81869dea711e14cbb28c3  No bug found                  
      CS  10.11  opt  220726  6268f6023fe3e8dc8ec81869dea711e14cbb28c3  No bug found                  
      CS  11.4   dbg  220726  2cbce592c39dd39902c8f03db2b35069832fd10b  SIGSEGV|__GI___nptl_deallocate_tsd|__GI___nptl_deallocate_tsd|start_thread|clone3
      CS  11.4   opt  220726  2cbce592c39dd39902c8f03db2b35069832fd10b  SIGSEGV|__GI___nptl_deallocate_tsd|__GI___nptl_deallocate_tsd|start_thread|clone3
      CS  11.8   dbg  220726  1d23deff797ab448f091e39756434903d81a98c2  SIGSEGV|__GI___nptl_deallocate_tsd|__GI___nptl_deallocate_tsd|start_thread|clone3
      CS  11.8   opt  220726  1d23deff797ab448f091e39756434903d81a98c2  SIGSEGV|__GI___nptl_deallocate_tsd|__GI___nptl_deallocate_tsd|start_thread|clone3
      CS  12.3   dbg  220726  9b075b2cb53338f67e7230cc585e02d2d34514ed  SIGSEGV|__GI___nptl_deallocate_tsd|__GI___nptl_deallocate_tsd|start_thread|clone3
      CS  12.3   opt  220726  9b075b2cb53338f67e7230cc585e02d2d34514ed  SIGSEGV|__GI___nptl_deallocate_tsd|__GI___nptl_deallocate_tsd|start_thread|clone3
      CS  13.0   dbg  220726  84c246ca5387c0611f75097136ff4f4bea092aa3  SIGSEGV|__GI___nptl_deallocate_tsd|__GI___nptl_deallocate_tsd|start_thread|clone3
      CS  13.0   opt  220726  84c246ca5387c0611f75097136ff4f4bea092aa3  SIGSEGV|__GI___nptl_deallocate_tsd|__GI___nptl_deallocate_tsd|start_thread|clone3
      CS  13.1   dbg  220726  934108aab5cb541b3fc09672b5d4090558ab408e  SIGSEGV|store_duckdb_field_in_mysql_format|ha_duckdb::rnd_next|handler::ha_rnd_next|rr_sequential
      CS  13.1   opt  220726  934108aab5cb541b3fc09672b5d4090558ab408e  SIGSEGV|store_duckdb_field_in_mysql_format|ha_duckdb::rnd_next|handler::ha_rnd_next|rr_sequential
      ES  10.6   dbg  220726  fcecb2620f25965723d640decede7c018bcb1dcc  No bug found                  
      ES  10.6   opt  220726  fcecb2620f25965723d640decede7c018bcb1dcc  No bug found                  
      ES  11.4   dbg  220726  3b34189bfe675c18c4ced3ef531d016ea74c76f4  No bug found                  
      ES  11.4   opt  220726  3b34189bfe675c18c4ced3ef531d016ea74c76f4  No bug found                  
      ES  11.8   dbg  220726  4694e931d10fecf733c34f83ea2146d31b708eb3  No bug found                  
      ES  11.8   opt  220726  4694e931d10fecf733c34f83ea2146d31b708eb3  No bug found                  
      ES  12.3   dbg  220726  9d8abb61e913bec023cd8caeccad4b42717151cb  No bug found                  
      ES  12.3   opt  220726  9d8abb61e913bec023cd8caeccad4b42717151cb  No bug found                                   
      

      CS 13.1.0 934108aab5cb541b3fc09672b5d4090558ab408e (Debug, UBASAN, Clang 22.1.8-20260622) Build 22/07/2026

      /test/13.1_dbg_san/storage/duckdb/convertor/duckdb_select.cc:55:12: runtime error: member call on null pointer of type 'Field'
          #0 0x64e568010153 in store_duckdb_field_in_mysql_format(Field*, duckdb::Value&, THD*) /test/13.1_dbg_san/storage/duckdb/convertor/duckdb_select.cc:55:12
          #1 0x64e567f10024 in ha_duckdb::rnd_next(unsigned char*) /test/13.1_dbg_san/storage/duckdb/ha_duckdb.cc:690:5
          #2 0x62f17800fc7c in handler::ha_rnd_next(unsigned char*) /test/13.1_dbg_san/sql/handler.cc:4045:17
          #3 0x62f1788b8377 in rr_sequential(READ_RECORD*) /test/13.1_dbg_san/sql/records.cc:509:35
          #4 0x62f179528b54 in copy_data_between_tables(THD*, TABLE*, TABLE*, bool, unsigned int, st_order*, unsigned long long*, unsigned long long*, Alter_info*, Alter_table_ctx*, bool, unsigned long long) /test/13.1_dbg_san/sql/sql_table.cc:12824:21
          #5 0x62f1794fe060 in mysql_alter_table(THD*, st_mysql_const_lex_string const*, st_mysql_const_lex_string const*, Table_specification_st*, TABLE_LIST*, Recreate_info*, Alter_info*, unsigned int, st_order*, bool, bool) /test/13.1_dbg_san/sql/sql_table.cc:11958:9
          #6 0x62f17983421e in Sql_cmd_alter_table::execute(THD*) /test/13.1_dbg_san/sql/sql_alter.cc:697:11
          #7 0x62f178ff2c28 in mysql_execute_command(THD*, bool) /test/13.1_dbg_san/sql/sql_parse.cc:5905:26
          #8 0x62f178fd5b0a in mysql_parse(THD*, char*, unsigned int, Parser_state*) /test/13.1_dbg_san/sql/sql_parse.cc:7958:18
          #9 0x62f178fcdaee in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /test/13.1_dbg_san/sql/sql_parse.cc:1903:7
          #10 0x62f178fd7ef6 in do_command(THD*, bool) /test/13.1_dbg_san/sql/sql_parse.cc:1437:17
          #11 0x62f179807f0c in do_handle_one_connection(CONNECT*, bool) /test/13.1_dbg_san/sql/sql_connect.cc:1510:11
          #12 0x62f179807a35 in handle_one_connection /test/13.1_dbg_san/sql/sql_connect.cc:1422:5
          #13 0x70e66e348e16 in asan_thread_start(void*) /test/llvm-build/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:246:28
          #14 0x70e66da9ca93 in start_thread nptl/pthread_create.c:447:8
          #15 0x70e66db29c3b in clone3 misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
       
      SUMMARY: UndefinedBehaviorSanitizer: null-pointer-use /test/13.1_dbg_san/storage/duckdb/convertor/duckdb_select.cc:55:12 
      

      SAN Bug Detection Matrix

      CS  13.1   dbg  220726  934108aab5cb541b3fc09672b5d4090558ab408e  UBSAN|member call on null pointer of type 'Field'|storage/duckdb/convertor/duckdb_select.cc|store_duckdb_field_in_mysql_format|ha_duckdb::rnd_next|handler::ha_rnd_next|rr_sequential
      CS  13.1   opt  220726  934108aab5cb541b3fc09672b5d4090558ab408e  UBSAN|member call on null pointer of type 'Field'|storage/duckdb/convertor/duckdb_select.cc|store_duckdb_field_in_mysql_format|ha_duckdb::rnd_next|handler::ha_rnd_next|rr_sequential
      

      Attachments

        Issue Links

          Activity

            People

              drrtuy Roman
              Roel Roel Van de Paar
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - Not Specified
                  Not Specified
                  Logged:
                  Time Spent - 0.75h
                  0.75h

                  Git Integration

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