Bug #113422 Handler_test.TableCreateReturnsRecordFileFullWhenTempTableAllocatorThrowsRecordF
Submitted: 14 Dec 2023 13:14 Modified: 18 Dec 2023 16:18
Reporter: Laurynas Biveinis (OCA) Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:8.2.0 OS:Any
Assigned to: CPU Architecture:Any
Tags: sanitizer

[14 Dec 2023 13:14] Laurynas Biveinis
Description:
(the test name is longer than the bug title length limit)

The test Handler_test.TableCreateReturnsRecordFileFullWhenTempTableAllocatorThrowsRecordFileFull fails under sanitizer build (-DWITH_ASAN=ON -DWITH_ASAN_SCOPE=ON -DWITH_UBSAN=ON). Does not fail without the sanitizer flags.

$ runtime_output_directory/merge_temptable_tests-t
...
[ RUN      ] Handler_test.TableCreateReturnsRecordFileFullWhenTempTableAllocatorThrowsRecordFileFull
libc++abi: terminating due to uncaught exception of type temptable::Result

How to repeat:
See above
[14 Dec 2023 13:15] Laurynas Biveinis
[ RUN      ] Handler_test.TableCreateReturnsRecordFileFullWhenTempTableAllocatorThrowsRecordFileFull
libc++abi: terminating due to uncaught exception of type temptable::Result
2023-12-14T13:11:16Z UTC - mysqld got signal 6 ;
Thread pointer: 0x10ab03900
stack_bottom = 16d70a640 thread_stack 0x100000
...
6   libc++abi.dylib                     0x000000019041c6d8 __cxxabiv1::__aligned_malloc_with_fallback(unsigned long) + 0
7   libc++abi.dylib                     0x000000019040c7c8 demangling_terminate_handler() + 348
8   libobjc.A.dylib                     0x00000001900b78a4 _objc_terminate() + 160
9   libc++abi.dylib                     0x000000019041ba9c std::__terminate(void (*)()) + 16
10  libc++abi.dylib                     0x000000019041ea48 __cxa_get_exception_ptr + 0
11  libc++abi.dylib                     0x000000019041e9f4 __cxxabiv1::exception_cleanup_func(_Unwind_Reason_Code, _Unwind_Exception*) + 0
12  libserver_unittest_library.dylib    0x00000001279aeba4 temptable::Allocator<temptable::Column, temptable::Allocation_scheme<temptable::Exponential_policy, temptable::Prefer_RAM_over_MMAP_policy>>::allocate(unsigned long) + 1472
13  libserver_unittest_library.dylib    0x00000001279ae3d8 std::__1::__allocation_result<std::__1::allocator_traits<temptable::Allocator<temptable::Column, temptable::Allocation_scheme<temptable::Exponential_policy, temptable::Prefer_RAM_over_MMAP_policy>>>::pointer> std::__1::__allocate_at_least[abi:v160006]<temptable::Allocator<temptable::Column, temptable::Allocation_scheme<temptable::Exponential_policy, temptable::Prefer_RAM_over_MMAP_policy>>>(temptable::Allocator<temptable::Column, temptable::Allocat14  libserver_unittest_library.dylib    0x00000001279ae18c std::__1::__split_buffer<temptable::Column, temptable::Allocator<temptable::Column, temptable::Allocation_scheme<temptable::Exponential_policy, temptable::Prefer_RAM_over_MMAP_policy>>&>::__split_buffer(unsigned long, unsigned long, temptable::Allocator<temptable::Column, temptable::Allocation_scheme<temptable::Exponential_policy, temptable::Prefer_RAM_over_MMAP_policy>>&) + 264
15  libserver_unittest_library.dylib    0x000000012799fd50 std::__1::vector<temptable::Column, temptable::Allocator<temptable::Column, temptable::Allocation_scheme<temptable::Exponential_policy, temptable::Prefer_RAM_over_MMAP_policy>>>::reserve(unsigned long) + 288
16  libserver_unittest_library.dylib    0x000000012799f040 temptable::Table::Table(TABLE*, temptable::Block*, bool, unsigned long) + 1372
17  libserver_unittest_library.dylib    0x000000012797701c std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const, temptable::Table>::pair[abi:v160006]<char const*&, TABLE*&, temptable::Block*&, bool&, unsigned long&, 0ul, 0ul, 1ul, 2ul, 3ul>(std::__1::piecewise_construct_t, std::__1::tuple<char const*&>&, std::__1::tuple<TABLE*&, temptable::Block*&, bool&, unsigned long&>&, std::__1::__tuple_indices<0ul>, std::__1::__tuple_indices<0ul, 1ul, 2ul, 3ul>) + 218  libserver_unittest_library.dylib    0x0000000127976e24 std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const, temptable::Table>::pair[abi:v160006]<char const*&, TABLE*&, temptable::Block*&, bool&, unsigned long&>(std::__1::piecewise_construct_t, std::__1::tuple<char const*&>, std::__1::tuple<TABLE*&, temptable::Block*&, bool&, unsigned long&>) + 236
19  libserver_unittest_library.dylib    0x0000000127976c80 void std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, temptable::Table>, void*>>::construct[abi:v160006]<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const, temptable::Table>, std::__1::piecewise_construct_t const&, std::__1::tuple<char const*&>&, std::__1::tuple<TABLE*&, temptable::Block*20  libserver_unittest_library.dylib    0x0000000127975c08 std::__1::unique_ptr<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, temptable::Table>, void*>, std::__1::__hash_node_destructor<std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, temptable::Table>, void*>>>> std::__1::__hash_table<std::__1::__hash_value_type21  libserver_unittest_library.dylib    0x0000000127975960 std::__1::pair<std::__1::__hash_iterator<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, temptable::Table>, void*>*>, bool> std::__1::__hash_table<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, temptable::Table>, std::__1::__unordered_map_hasher<std::__1::basic_string<char, std::__1::char_traits<22  libserver_unittest_library.dylib    0x0000000127972594 std::__1::pair<std::__1::__hash_map_iterator<std::__1::__hash_iterator<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, temptable::Table>, void*>*>>, bool> std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, temptable::Table, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits<char>, std::__123  libserver_unittest_library.dylib    0x0000000127954934 std::__1::pair<std::__1::__hash_map_iterator<std::__1::__hash_iterator<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, temptable::Table>, void*>*>>, bool> temptable::Key_value_store<std::__1::shared_timed_mutex, std::__1::unordered_map>::emplace<std::__1::piecewise_construct_t const&, std::__1::tuple<char const*&>, std::__1::tuple<TABLE*&, temptable::Block*&, bo24  libserver_unittest_library.dylib    0x0000000127953df8 temptable::Handler::create(char const*, TABLE*, HA_CREATE_INFO*, dd::Table*) + 1772
25  merge_temptable_tests-t             0x0000000102733ef0 temptable_test::Handler_test_TableCreateReturnsRecordFileFullWhenTempTableAllocatorThrowsRecordFileFull_Test::TestBody() + 760
...
[14 Dec 2023 13:22] Laurynas Biveinis
Many MTR tests fail with a similar stacktrace too, i.e. main.distinct:

[ 50%] main.distinct                             [ fail ]
        Test ended at 2023-12-14 15:21:27

CURRENT_TEST: main.distinct
mysqltest: At line 688: Query 'INSERT INTO t1 SELECT a+8 FROM t1' failed.
ERROR 2013 (HY000): Lost connection to MySQL server during query
...
libc++abi: terminating due to uncaught exception of type temptable::Result
2023-12-14T13:21:27Z UTC - mysqld got signal 6 ;
Most likely, you have hit a bug, but this error can also be caused by malfunctioning hardware.
Thread pointer: 0x146450900
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 = 16ebd6e20 thread_stack 0x100000
0   mysqld                              0x000000010839d7a4 my_print_stacktrace(unsigned char const*, unsigned long) + 236
1   mysqld                              0x00000001056011f4 print_fatal_signal(int) + 1236
2   mysqld                              0x000000010560187c handle_fatal_signal + 128
3   libsystem_platform.dylib            0x0000000190493a24 _sigtramp + 56
4   libsystem_pthread.dylib             0x0000000190464cc0 pthread_kill + 288
5   libsystem_c.dylib                   0x0000000190374a40 abort + 180
6   libc++abi.dylib                     0x000000019041c6d8 __cxxabiv1::__aligned_malloc_with_fallback(unsigned long) + 0
7   libc++abi.dylib                     0x000000019040c7c8 demangling_terminate_handler() + 348
8   libobjc.A.dylib                     0x00000001900b78a4 _objc_terminate() + 160
9   libc++abi.dylib                     0x000000019041ba9c std::__terminate(void (*)()) + 16
10  libc++abi.dylib                     0x000000019041ea48 __cxa_get_exception_ptr + 0
11  libc++abi.dylib                     0x000000019041e9f4 __cxxabiv1::exception_cleanup_func(_Unwind_Reason_Code, _Unwind_Exception*) + 0
12  mysqld                              0x000000010af3cf4c temptable::Allocator<unsigned char, temptable::Allocation_scheme<temptable::Exponential_policy, temptable::Prefer_RAM_over_MMAP_policy>>::allocate(unsigned long) + 1412
13  mysqld                              0x000000010af41840 temptable::Storage::allocate_back() + 316
14  mysqld                              0x000000010af41288 temptable::Table::insert(unsigned char const*) + 84
15  mysqld                              0x000000010aefedd4 temptable::Handler::write_row(unsigned char*) + 524
16  mysqld                              0x000000010335e4e0 handler::ha_write_row(unsigned char*) + 1432
17  mysqld                              0x0000000103c89f08 MaterializeIterator<DummyIteratorProfiler>::MaterializeOperand(materialize_iterator::Operand const&, unsigned long long*) + 4676
18  mysqld                              0x0000000103c845c4 MaterializeIterator<DummyIteratorProfiler>::Init() + 7592
19  mysqld                              0x0000000105185650 Query_expression::ExecuteIteratorQuery(THD*) + 5832
20  mysqld                              0x0000000105186bb8 Query_expression::execute(THD*) + 356
21  mysqld                              0x0000000104ec8c04 Sql_cmd_dml::execute_inner(THD*) + 784
22  mysqld                              0x0000000104ec2a20 Sql_cmd_dml::execute(THD*) + 5444
23  mysqld                              0x0000000104c5da44 mysql_execute_command(THD*, bool) + 22724
24  mysqld                              0x0000000104c4fa8c dispatch_sql_command(THD*, Parser_state*) + 9504
25  mysqld                              0x0000000104c3cc60 dispatch_command(THD*, COM_DATA const*, enum_server_command) + 33660
26  mysqld                              0x0000000104c47c94 do_command(THD*) + 5040
27  mysqld                              0x000000010557beb8 handle_connection(void*) + 1132
28  mysqld                              0x000000010ab44c0c pfs_spawn_thread(void*) + 544
29  libsystem_pthread.dylib             0x0000000190465034 _pthread_start + 136
30  libsystem_pthread.dylib             0x000000019045fe3c thread_start + 8

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (1472483d0): INSERT INTO t1 SELECT a+8 FROM t1
[14 Dec 2023 14:02] MySQL Verification Team
Hi Mr. Biveinis,

Thank you for your bug report.

However, we can not repeat it with either our release or debug binary tests.

The test that you are referencing runs beautifully on two different operating systems:

[==========] Running 17 tests from 5 test suites.
[----------] Global test environment set-up.
[----------] 4 tests from Allocator
[ RUN      ] Allocator.BasicAlloc
[       OK ] Allocator.BasicAlloc (0 ms)
[ RUN      ] Allocator.ZeroSize
[       OK ] Allocator.ZeroSize (0 ms)
[ RUN      ] Allocator.ConstructDestroy
[       OK ] Allocator.ConstructDestroy (0 ms)
[ RUN      ] Allocator.Casts
[       OK ] Allocator.Casts (0 ms)
[----------] 4 tests from Allocator (0 ms total)

[----------] 4 tests from CellCalculator
[ RUN      ] CellCalculator.NullEmpty
[       OK ] CellCalculator.NullEmpty (0 ms)
[ RUN      ] CellCalculator.Short
[       OK ] CellCalculator.Short (0 ms)
[ RUN      ] CellCalculator.StringPad
[       OK ] CellCalculator.StringPad (0 ms)
[ RUN      ] CellCalculator.StringNoPad
[       OK ] CellCalculator.StringNoPad (0 ms)
[----------] 4 tests from CellCalculator (0 ms total)

[----------] 1 test from Cell
[ RUN      ] Cell.ConstructorAndGetters
[       OK ] Cell.ConstructorAndGetters (0 ms)
[----------] 1 test from Cell (0 ms total)

[----------] 7 tests from Handler_test
[ RUN      ] Handler_test.SimpleTableCreate
[       OK ] Handler_test.SimpleTableCreate (0 ms)
[ RUN      ] Handler_test.SimpleTableOpsFixedSize
[       OK ] Handler_test.SimpleTableOpsFixedSize (0 ms)
[ RUN      ] Handler_test.SimpleTableOpsVarSize
[       OK ] Handler_test.SimpleTableOpsVarSize (0 ms)
[ RUN      ] Handler_test.SingleIndex
[       OK ] Handler_test.SingleIndex (0 ms)
[ RUN      ] Handler_test.MultiIndex
[       OK ] Handler_test.MultiIndex (0 ms)
[ RUN      ] Handler_test.MultiIndexVarchar
[       OK ] Handler_test.MultiIndexVarchar (0 ms)
[ RUN      ] Handler_test.IndexOnOff
[       OK ] Handler_test.IndexOnOff (0 ms)
[----------] 7 tests from Handler_test (0 ms total)

[----------] 1 test from Result
[ RUN      ] Result.ToString
[       OK ] Result.ToString (0 ms)
[----------] 1 test from Result (0 ms total)

[----------] Global test environment tear-down
[==========] 17 tests from 5 test suites ran. (1 ms total)
[  PASSED  ] 17 tests.

Can't repeat.
[15 Dec 2023 14:03] Laurynas Biveinis
Usually the MySQL Bug Verification Team asks for additional information before closing the bug as "Can't reproduce". 

Can you help me to not reproduce this bug too? For instance, what XCode version and other CMake build flags do you use?
[15 Dec 2023 14:37] MySQL Verification Team
Hi,

Regarding options we provided them in 113421.

Regarding merge_temptable_tests-t we have got a much shorter output, with the following error:

merge_temptable_tests-t(30717,0x7ff84c56cb40) malloc: nano zone abandoned due to inability to reserve vm space.
[18 Dec 2023 16:18] Laurynas Biveinis
Trying the bug 113421 options results in a failure described in bug 113421
[19 Dec 2023 11:16] MySQL Verification Team
HI,

Please, just answer the questions from 113421.
[20 Dec 2023 15:57] MySQL Verification Team
No need to answer any questions here.

It is all handled in #113421.

Thanks.