From cfa8268ef914cde4bfe03b1ae9349849d1384820 Mon Sep 17 00:00:00 2001 From: Monty Date: Tue, 12 Mar 2024 18:23:51 +0200 Subject: [PATCH] MDEV-33622 Server crashes when the UPDATE statement (which has duplicate key) is run after setting a low thread_stack This was caused by wrong allocation of variable on stack. (Was allocating 4K of data instead of 512 bytes). No test case as the original MDEV test cases is not usable for mtr. --- include/my_bitmap.h | 1 + sql/sql_update.cc | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/my_bitmap.h b/include/my_bitmap.h index 5589236664d..42a093c5bed 100644 --- a/include/my_bitmap.h +++ b/include/my_bitmap.h @@ -88,6 +88,7 @@ extern void bitmap_lock_clear_bit(MY_BITMAP *map, uint bitmap_bit); #define my_bitmap_map_bytes sizeof(my_bitmap_map) #define my_bitmap_map_bits (my_bitmap_map_bytes*8) +/* Size in bytes to store 'bits' number of bits */ #define bitmap_buffer_size(bits) (MY_ALIGN((bits), my_bitmap_map_bits)/8) #define my_bitmap_buffer_size(map) bitmap_buffer_size((map)->n_bits) #define no_bytes_in_export_map(map) (((map)->n_bits + 7)/8) diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 81910cf651b..8617c41c522 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -257,7 +257,7 @@ static void prepare_record_for_error_message(int error, TABLE *table) Field *field; uint keynr; MY_BITMAP unique_map; /* Fields in offended unique. */ - my_bitmap_map unique_map_buf[bitmap_buffer_size(MAX_FIELDS)]; + my_bitmap_map unique_map_buf[bitmap_buffer_size(MAX_FIELDS)/sizeof(my_bitmap_map)]; DBUG_ENTER("prepare_record_for_error_message"); /*