Skip to content

Commit 0fd89a1

Browse files
committed
Merge remote-tracking branch 'origin/10.4' into 10.5
2 parents 70684af + e9f06b1 commit 0fd89a1

40 files changed

+182
-173
lines changed

include/my_valgrind.h

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,22 @@
2424
# define __SANITIZE_ADDRESS__ 1
2525
#endif
2626

27-
#ifdef HAVE_valgrind
28-
#define IF_VALGRIND(A,B) A
29-
#else
30-
#define IF_VALGRIND(A,B) B
31-
#endif
32-
33-
#if defined(HAVE_VALGRIND_MEMCHECK_H) && defined(HAVE_valgrind)
27+
#if __has_feature(memory_sanitizer)
28+
# include <sanitizer/msan_interface.h>
29+
# define HAVE_valgrind
30+
# define MEM_UNDEFINED(a,len) __msan_allocated_memory(a,len)
31+
# define MEM_MAKE_ADDRESSABLE(a,len) MEM_UNDEFINED(a,len)
32+
# define MEM_MAKE_DEFINED(a,len) __msan_unpoison(a,len)
33+
# define MEM_NOACCESS(a,len) ((void) 0)
34+
# define MEM_CHECK_ADDRESSABLE(a,len) ((void) 0)
35+
# define MEM_CHECK_DEFINED(a,len) __msan_check_mem_is_initialized(a,len)
36+
# define MEM_GET_VBITS(a,b,len) __msan_copy_shadow(b,a,len)
37+
# define MEM_SET_VBITS(a,b,len) __msan_copy_shadow(a,b,len)
38+
# define REDZONE_SIZE 8
39+
#elif defined(HAVE_VALGRIND_MEMCHECK_H) && defined(HAVE_valgrind)
3440
# include <valgrind/memcheck.h>
35-
# define HAVE_valgrind_or_MSAN
3641
# define MEM_UNDEFINED(a,len) VALGRIND_MAKE_MEM_UNDEFINED(a,len)
42+
# define MEM_MAKE_ADDRESSABLE(a,len) MEM_UNDEFINED(a,len)
3743
# define MEM_MAKE_DEFINED(a,len) VALGRIND_MAKE_MEM_DEFINED(a,len)
3844
# define MEM_NOACCESS(a,len) VALGRIND_MAKE_MEM_NOACCESS(a,len)
3945
# define MEM_CHECK_ADDRESSABLE(a,len) VALGRIND_CHECK_MEM_IS_ADDRESSABLE(a,len)
@@ -45,53 +51,50 @@
4551
# include <sanitizer/asan_interface.h>
4652
/* How to do manual poisoning:
4753
https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning */
48-
# define MEM_UNDEFINED(a,len) ASAN_UNPOISON_MEMORY_REGION(a,len)
54+
# define MEM_UNDEFINED(a,len) ((void) 0)
55+
# define MEM_MAKE_ADDRESSABLE(a,len) ASAN_UNPOISON_MEMORY_REGION(a,len)
4956
# define MEM_MAKE_DEFINED(a,len) ((void) 0)
5057
# define MEM_NOACCESS(a,len) ASAN_POISON_MEMORY_REGION(a,len)
51-
# define MEM_CHECK_ADDRESSABLE(a,len) ((void) 0)
58+
# define MEM_CHECK_ADDRESSABLE(a,len) \
59+
assert(!__asan_region_is_poisoned((void*) a,len))
5260
# define MEM_CHECK_DEFINED(a,len) ((void) 0)
5361
# define MEM_GET_VBITS(a,b,len) ((void) 0)
5462
# define MEM_SET_VBITS(a,b,len) ((void) 0)
5563
# define REDZONE_SIZE 8
56-
#elif __has_feature(memory_sanitizer)
57-
# include <sanitizer/msan_interface.h>
58-
# define HAVE_valgrind_or_MSAN
59-
# define MEM_UNDEFINED(a,len) __msan_allocated_memory(a,len)
60-
# define MEM_MAKE_DEFINED(a,len) __msan_unpoison(a,len)
61-
# define MEM_NOACCESS(a,len) ((void) 0)
62-
# define MEM_CHECK_ADDRESSABLE(a,len) ((void) 0)
63-
# define MEM_CHECK_DEFINED(a,len) __msan_check_mem_is_initialized(a,len)
64-
# define MEM_GET_VBITS(a,b,len) __msan_copy_shadow(b,a,len)
65-
# define MEM_SET_VBITS(a,b,len) __msan_copy_shadow(a,b,len)
66-
# define REDZONE_SIZE 8
6764
#else
68-
# define MEM_UNDEFINED(a,len) ((void) (a), (void) (len))
65+
# define MEM_UNDEFINED(a,len) ((void) 0)
66+
# define MEM_MAKE_ADDRESSABLE(a,len) ((void) 0)
6967
# define MEM_MAKE_DEFINED(a,len) ((void) 0)
7068
# define MEM_NOACCESS(a,len) ((void) 0)
7169
# define MEM_CHECK_ADDRESSABLE(a,len) ((void) 0)
7270
# define MEM_CHECK_DEFINED(a,len) ((void) 0)
7371
# define MEM_GET_VBITS(a,b,len) ((void) 0)
7472
# define MEM_SET_VBITS(a,b,len) ((void) 0)
7573
# define REDZONE_SIZE 0
76-
#endif /* HAVE_VALGRIND_MEMCHECK_H */
74+
#endif /* __has_feature(memory_sanitizer) */
75+
76+
#ifdef HAVE_valgrind
77+
#define IF_VALGRIND(A,B) A
78+
#else
79+
#define IF_VALGRIND(A,B) B
80+
#endif
7781

7882
#ifdef TRASH_FREED_MEMORY
7983
/*
80-
TRASH_FILL() has to call MEM_UNDEFINED() to cancel any effect of TRASH_FREE().
84+
_TRASH_FILL() has to call MEM_MAKE_ADDRESSABLE() to cancel any effect of
85+
TRASH_FREE().
8186
This can happen in the case one does
8287
TRASH_ALLOC(A,B) ; TRASH_FREE(A,B) ; TRASH_ALLOC(A,B)
8388
to reuse the same memory in an internal memory allocator like MEM_ROOT.
84-
For my_malloc() and safemalloc() the extra MEM_UNDEFINED is bit of an
85-
overkill.
86-
TRASH_FILL() is an internal function and should not be used externally.
89+
_TRASH_FILL() is an internal function and should not be used externally.
8790
*/
88-
#define TRASH_FILL(A,B,C) do { const size_t trash_tmp= (B); MEM_UNDEFINED(A, trash_tmp); memset(A, C, trash_tmp); } while (0)
91+
#define _TRASH_FILL(A,B,C) do { const size_t trash_tmp= (B); MEM_MAKE_ADDRESSABLE(A, trash_tmp); memset(A, C, trash_tmp); } while (0)
8992
#else
90-
#define TRASH_FILL(A,B,C) do { MEM_UNDEFINED((A), (B)); } while (0)
93+
#define _TRASH_FILL(A,B,C) do { MEM_UNDEFINED((A), (B)); } while (0)
9194
#endif
92-
/** Note that some memory became allocated or uninitialized. */
93-
#define TRASH_ALLOC(A,B) do { TRASH_FILL(A,B,0xA5); MEM_UNDEFINED(A,B); } while(0)
95+
/** Note that some memory became allocated and/or uninitialized. */
96+
#define TRASH_ALLOC(A,B) do { _TRASH_FILL(A,B,0xA5); MEM_MAKE_ADDRESSABLE(A,B); } while(0)
9497
/** Note that some memory became freed. (Prohibit further access to it.) */
95-
#define TRASH_FREE(A,B) do { TRASH_FILL(A,B,0x8F); MEM_NOACCESS(A,B); } while(0)
98+
#define TRASH_FREE(A,B) do { _TRASH_FILL(A,B,0x8F); MEM_NOACCESS(A,B); } while(0)
9699

97100
#endif /* MY_VALGRIND_INCLUDED */

libmysqld/libmysql.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,6 +1164,7 @@ my_bool STDCALL mysql_embedded(void)
11641164
void my_net_local_init(NET *net)
11651165
{
11661166
net->max_packet= (uint) net_buffer_length;
1167+
net->read_timeout= net->write_timeout= 0;
11671168
my_net_set_read_timeout(net, CLIENT_NET_READ_TIMEOUT);
11681169
my_net_set_write_timeout(net, CLIENT_NET_WRITE_TIMEOUT);
11691170
net->retry_count= 1;

mysql-test/main/mysql_upgrade.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ let $MYSQLD_DATADIR= `select @@datadir`;
1717
file_exists $MYSQLD_DATADIR/mysql_upgrade_info;
1818

1919
--echo Run it again - should say already completed
20-
--replace_result $MYSQL_SERVER_VERSION VERSION
20+
--replace_regex /upgraded to .*, use/upgraded to VERSION, use/
2121
--exec $MYSQL_UPGRADE 2>&1
2222

2323
# It should have created a file in the MySQL Servers datadir

mysql-test/main/type_temporal_innodb.result

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ ERROR 22007: Truncated incorrect datetime value: '0000-00-00 00:00:00'
173173
DROP TABLE t1,t2;
174174
SET sql_mode=DEFAULT;
175175
#
176+
# End of 10.3 tests
177+
#
178+
#
176179
# MDEV-19166 Assertion `!is_zero_datetime()' failed in Timestamp_or_zero_datetime::tv
177180
#
178181
CREATE TABLE t1 (f TIMESTAMP DEFAULT 0) ENGINE=InnoDB;

mysql-test/main/type_temporal_innodb.test

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ CREATE TABLE tbl SELECT * FROM t1 WHERE t1.c1 = (SELECT c2 FROM t2 WHERE pk = 6)
8282
DROP TABLE t1,t2;
8383
SET sql_mode=DEFAULT;
8484

85+
--echo #
86+
--echo # End of 10.3 tests
87+
--echo #
8588

8689
--echo #
8790
--echo # MDEV-19166 Assertion `!is_zero_datetime()' failed in Timestamp_or_zero_datetime::tv
@@ -92,7 +95,6 @@ INSERT INTO t1 VALUES ('2024-02-29');
9295
SELECT * FROM t1 WHERE SUBSTR(1 FROM BIT_LENGTH(f) FOR DEFAULT(f));
9396
DROP TABLE t1;
9497

95-
9698
--echo #
9799
--echo # End of 10.4 tests
98100
--echo #

mysql-test/suite/csv/read_only.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
--source include/not_as_root.inc
12
#
23
# MDEV-11883 MariaDB crashes with out-of-memory when query information_schema
34
#
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
connection node_2;
2+
connection node_1;
3+
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
4+
START TRANSACTION;
5+
INSERT INTO t1 VALUES (1);
6+
LOCK TABLES t2 READ;
7+
ERROR 42S02: Table 'test.t2' doesn't exist
8+
START TRANSACTION;
9+
INSERT INTO t1 VALUES (1);
10+
LOCK TABLES t1 READ;
11+
UNLOCK TABLES;
12+
DROP TABLE t1;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#
2+
# Check `LOCK TABLES` command with or without existing table in database.
3+
# Test case for MDEV-22222 / MDEV-22223
4+
#
5+
6+
--source include/galera_cluster.inc
7+
--source include/have_innodb.inc
8+
9+
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
10+
11+
START TRANSACTION;
12+
INSERT INTO t1 VALUES (1);
13+
--error ER_NO_SUCH_TABLE
14+
LOCK TABLES t2 READ;
15+
16+
START TRANSACTION;
17+
INSERT INTO t1 VALUES (1);
18+
LOCK TABLES t1 READ;
19+
UNLOCK TABLES;
20+
21+
DROP TABLE t1;

mysys/my_alloc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ void *alloc_root(MEM_ROOT *mem_root, size_t length)
205205
uchar* point;
206206
reg1 USED_MEM *next= 0;
207207
reg2 USED_MEM **prev;
208-
size_t original_length = length;
208+
size_t original_length __attribute__((unused)) = length;
209209
DBUG_ENTER("alloc_root");
210210
DBUG_PRINT("enter",("root: %p name: %s", mem_root, root_name(mem_root)));
211211
DBUG_ASSERT(alloc_root_inited(mem_root));

sql/field.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7698,7 +7698,7 @@ my_decimal *Field_varstring::val_decimal(my_decimal *decimal_value)
76987698
}
76997699

77007700

7701-
#ifdef HAVE_valgrind_or_MSAN
7701+
#ifdef HAVE_valgrind
77027702
void Field_varstring::mark_unused_memory_as_defined()
77037703
{
77047704
uint used_length= get_length();

0 commit comments

Comments
 (0)