Skip to content

Commit 6a6bcc5

Browse files
committed
Merge 10.2 into 10.3
2 parents 3eadb13 + ff66d65 commit 6a6bcc5

File tree

24 files changed

+135
-285
lines changed

24 files changed

+135
-285
lines changed

client/mysqltest.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -587,9 +587,10 @@ ATTRIBUTE_NORETURN
587587
static void cleanup_and_exit(int exit_code);
588588

589589
ATTRIBUTE_NORETURN
590-
void really_die(const char *msg);
590+
static void really_die(const char *msg);
591591
void report_or_die(const char *fmt, ...);
592-
void die(const char *fmt, ...);
592+
ATTRIBUTE_NORETURN
593+
static void die(const char *fmt, ...);
593594
static void make_error_message(char *buf, size_t len, const char *fmt, va_list args);
594595
ATTRIBUTE_NORETURN ATTRIBUTE_FORMAT(printf, 1, 2)
595596
void abort_not_supported_test(const char *fmt, ...);
@@ -1555,7 +1556,7 @@ static void make_error_message(char *buf, size_t len, const char *fmt, va_list a
15551556
s+= my_snprintf(s, end -s, "\n");
15561557
}
15571558

1558-
void die(const char *fmt, ...)
1559+
static void die(const char *fmt, ...)
15591560
{
15601561
char buff[DIE_BUFF_SIZE];
15611562
va_list args;
@@ -1564,7 +1565,7 @@ void die(const char *fmt, ...)
15641565
really_die(buff);
15651566
}
15661567

1567-
void really_die(const char *msg)
1568+
static void really_die(const char *msg)
15681569
{
15691570
static int dying= 0;
15701571
fflush(stdout);

include/my_valgrind.h

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (C) 2010, 2019, MariaDB Corporation.
1+
/* Copyright (C) 2010, 2020, MariaDB Corporation.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -32,7 +32,9 @@
3232

3333
#if defined(HAVE_VALGRIND_MEMCHECK_H) && defined(HAVE_valgrind)
3434
# include <valgrind/memcheck.h>
35+
# define HAVE_valgrind_or_MSAN
3536
# define MEM_UNDEFINED(a,len) VALGRIND_MAKE_MEM_UNDEFINED(a,len)
37+
# define MEM_MAKE_DEFINED(a,len) VALGRIND_MAKE_MEM_DEFINED(a,len)
3638
# define MEM_NOACCESS(a,len) VALGRIND_MAKE_MEM_NOACCESS(a,len)
3739
# define MEM_CHECK_ADDRESSABLE(a,len) VALGRIND_CHECK_MEM_IS_ADDRESSABLE(a,len)
3840
# define MEM_CHECK_DEFINED(a,len) VALGRIND_CHECK_MEM_IS_DEFINED(a,len)
@@ -42,28 +44,42 @@
4244
/* How to do manual poisoning:
4345
https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning */
4446
# define MEM_UNDEFINED(a,len) ASAN_UNPOISON_MEMORY_REGION(a,len)
47+
# define MEM_MAKE_DEFINED(a,len) ((void) 0)
4548
# define MEM_NOACCESS(a,len) ASAN_POISON_MEMORY_REGION(a,len)
4649
# define MEM_CHECK_ADDRESSABLE(a,len) ((void) 0)
4750
# define MEM_CHECK_DEFINED(a,len) ((void) 0)
4851
# define REDZONE_SIZE 8
52+
#elif __has_feature(memory_sanitizer)
53+
# include <sanitizer/msan_interface.h>
54+
# define HAVE_valgrind_or_MSAN
55+
# define MEM_UNDEFINED(a,len) __msan_allocated_memory(a,len)
56+
# define MEM_MAKE_DEFINED(a,len) __msan_unpoison(a,len)
57+
# define MEM_NOACCESS(a,len) ((void) 0)
58+
# define MEM_CHECK_ADDRESSABLE(a,len) ((void) 0)
59+
# define MEM_CHECK_DEFINED(a,len) __msan_check_mem_is_initialized(a,len)
60+
# define REDZONE_SIZE 8
4961
#else
5062
# define MEM_UNDEFINED(a,len) ((void) (a), (void) (len))
63+
# define MEM_MAKE_DEFINED(a,len) ((void) 0)
5164
# define MEM_NOACCESS(a,len) ((void) 0)
5265
# define MEM_CHECK_ADDRESSABLE(a,len) ((void) 0)
5366
# define MEM_CHECK_DEFINED(a,len) ((void) 0)
5467
# define REDZONE_SIZE 0
5568
#endif /* HAVE_VALGRIND_MEMCHECK_H */
5669

57-
#if defined(TRASH_FREED_MEMORY)
58-
/* NOTE: Do not invoke TRASH_FILL directly! Use TRASH_ALLOC or TRASH_FREE.
59-
60-
The MEM_UNDEFINED() call before memset() is for canceling the effect
61-
of any previous MEM_NOACCESS(). We must invoke MEM_UNDEFINED() after
62-
writing the dummy pattern, unless MEM_NOACCESS() is going to be invoked.
63-
On AddressSanitizer, the MEM_UNDEFINED() in TRASH_ALLOC() has no effect. */
70+
#ifdef TRASH_FREED_MEMORY
71+
/*
72+
TRASH_FILL() has to call MEM_UNDEFINED() to cancel any effect of TRASH_FREE().
73+
This can happen in the case one does
74+
TRASH_ALLOC(A,B) ; TRASH_FREE(A,B) ; TRASH_ALLOC(A,B)
75+
to reuse the same memory in an internal memory allocator like MEM_ROOT.
76+
For my_malloc() and safemalloc() the extra MEM_UNDEFINED is bit of an
77+
overkill.
78+
TRASH_FILL() is an internal function and should not be used externally.
79+
*/
6480
#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)
6581
#else
66-
#define TRASH_FILL(A,B,C) while (0)
82+
#define TRASH_FILL(A,B,C) do { MEM_UNDEFINED((A), (B)); } while (0)
6783
#endif
6884
/** Note that some memory became allocated or uninitialized. */
6985
#define TRASH_ALLOC(A,B) do { TRASH_FILL(A,B,0xA5); MEM_UNDEFINED(A,B); } while(0)

include/span.h

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,33 @@ this program; if not, write to the Free Software Foundation, Inc.,
2424
namespace st_
2525
{
2626

27+
namespace detail
28+
{
29+
30+
template <class T> struct remove_cv
31+
{
32+
typedef T type;
33+
};
34+
template <class T> struct remove_cv<const T>
35+
{
36+
typedef T type;
37+
};
38+
template <class T> struct remove_cv<volatile T>
39+
{
40+
typedef T type;
41+
};
42+
template <class T> struct remove_cv<const volatile T>
43+
{
44+
typedef T type;
45+
};
46+
47+
} // namespace detail
48+
2749
template <class ElementType> class span
2850
{
2951
public:
3052
typedef ElementType element_type;
31-
typedef ElementType value_type;
53+
typedef typename detail::remove_cv<ElementType>::type value_type;
3254
typedef size_t size_type;
3355
typedef ptrdiff_t difference_type;
3456
typedef element_type *pointer;
@@ -38,7 +60,6 @@ template <class ElementType> class span
3860
typedef pointer iterator;
3961
typedef const_pointer const_iterator;
4062
typedef std::reverse_iterator<iterator> reverse_iterator;
41-
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
4263

4364
span() : data_(NULL), size_(0) {}
4465

@@ -64,73 +85,72 @@ template <class ElementType> class span
6485

6586
span &operator=(const span &other)
6687
{
67-
data_= other.data_;
68-
size_= other.size_;
88+
data_= other.data();
89+
size_= other.size();
6990
return *this;
7091
}
7192

7293
template <size_t Count> span<element_type> first() const
7394
{
7495
assert(!empty());
75-
return span(data_, 1);
96+
return span(data(), 1);
7697
}
7798
template <size_t Count> span<element_type> last() const
7899
{
79100
assert(!empty());
80-
return span(data_ + size() - 1, 1);
101+
return span(data() + size() - 1, 1);
81102
}
82103

83104
span<element_type> first(size_type count) const
84105
{
85106
assert(!empty());
86-
return span(data_, 1);
107+
return span(data(), 1);
87108
}
88109
span<element_type> last(size_type count) const
89110
{
90111
assert(!empty());
91-
return span(data_ + size() - 1, 1);
112+
return span(data() + size() - 1, 1);
92113
}
93114
span<element_type> subspan(size_type offset, size_type count) const
94115
{
95116
assert(!empty());
96117
assert(size() >= offset + count);
97-
return span(data_ + offset, count);
118+
return span(data() + offset, count);
98119
}
99120

100121
size_type size() const { return size_; }
101-
size_type size_bytes() const { return size_ * sizeof(ElementType); }
102-
bool empty() const __attribute__((warn_unused_result)) { return size_ == 0; }
122+
size_type size_bytes() const { return size() * sizeof(ElementType); }
123+
bool empty() const __attribute__((warn_unused_result))
124+
{
125+
return size() == 0;
126+
}
103127

104128
reference operator[](size_type idx) const
105129
{
106130
assert(size() > idx);
107-
return data_[idx];
131+
return data()[idx];
108132
}
109133
reference front() const
110134
{
111135
assert(!empty());
112-
return data_[0];
136+
return data()[0];
113137
}
114138
reference back() const
115139
{
116140
assert(!empty());
117-
return data_[size() - 1];
118-
}
119-
pointer data() const
120-
{
121-
assert(!empty());
122-
return data_;
141+
return data()[size() - 1];
123142
}
143+
pointer data() const { return data_; }
124144

125145
iterator begin() const { return data_; }
126146
iterator end() const { return data_ + size_; }
127147
reverse_iterator rbegin() const
128148
{
129-
return std::reverse_iterator<iterator>(std::advance(end(), -1));
149+
return std::reverse_iterator<iterator>(end());
130150
}
131151
reverse_iterator rend() const
132152
{
133-
return std::reverse_iterator<iterator>(std::advance(begin(), -1));
153+
return std::reverse_iterator<iterator>(begin());
134154
}
135155

136156
private:

libmariadb

mysql-test/suite/encryption/t/innodb_encryption_tables.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
-- source include/have_innodb.inc
22
-- source include/have_example_key_management_plugin.inc
33
-- source include/not_embedded.inc
4+
# We can't run this test under valgrind as it 'takes forever'
5+
-- source include/not_valgrind.inc
46

57
create table innodb_normal(c1 bigint not null, b char(200)) engine=innodb;
68
create table innodb_compact(c1 bigint not null, b char(200)) engine=innodb row_format=compact;

mysql-test/suite/gcol/r/innodb_virtual_debug_purge.result

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -234,48 +234,3 @@ set global debug_dbug= @saved_dbug;
234234
drop table t1;
235235
set debug_sync=reset;
236236
SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;
237-
#
238-
# MDEV-18546 ASAN heap-use-after-free
239-
# in innobase_get_computed_value / row_purge
240-
#
241-
CREATE TABLE t1 (
242-
pk INT AUTO_INCREMENT,
243-
b BIT(15),
244-
v BIT(15) AS (b) VIRTUAL,
245-
PRIMARY KEY(pk),
246-
UNIQUE(v)
247-
) ENGINE=InnoDB;
248-
INSERT IGNORE INTO t1 (b) VALUES
249-
(NULL),(b'011'),(b'000110100'),
250-
(b'01101101010'),(b'01111001001011'),(NULL);
251-
SET GLOBAL innodb_debug_sync = "ib_clust_v_col_before_row_allocated "
252-
"SIGNAL before_row_allocated "
253-
"WAIT_FOR flush_unlock";
254-
SET GLOBAL innodb_debug_sync = "ib_open_after_dict_open "
255-
"SIGNAL purge_open "
256-
"WAIT_FOR select_open";
257-
SET @saved_dbug= @@GLOBAL.debug_dbug;
258-
set global debug_dbug= "d,ib_purge_virtual_index_callback";
259-
connect purge_waiter,localhost,root;
260-
SET debug_sync= "now WAIT_FOR before_row_allocated";
261-
connection default;
262-
REPLACE INTO t1 (pk, b) SELECT pk, b FROM t1;
263-
connection purge_waiter;
264-
connection default;
265-
disconnect purge_waiter;
266-
FLUSH TABLES;
267-
SET GLOBAL innodb_debug_sync = reset;
268-
SET debug_sync= "now SIGNAL flush_unlock WAIT_FOR purge_open";
269-
SET GLOBAL innodb_debug_sync = reset;
270-
SET debug_sync= "ib_open_after_dict_open SIGNAL select_open";
271-
SELECT * FROM t1;
272-
pk b v
273-
1 NULL NULL
274-
2  
275-
3 4 4
276-
4 j j
277-
5 K K
278-
6 NULL NULL
279-
DROP TABLE t1;
280-
SET debug_sync= reset;
281-
set global debug_dbug= @saved_dbug;

mysql-test/suite/gcol/t/innodb_virtual_debug_purge.test

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -311,67 +311,3 @@ drop table t1;
311311
--source include/wait_until_count_sessions.inc
312312
set debug_sync=reset;
313313
SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;
314-
315-
--echo #
316-
--echo # MDEV-18546 ASAN heap-use-after-free
317-
--echo # in innobase_get_computed_value / row_purge
318-
--echo #
319-
320-
CREATE TABLE t1 (
321-
pk INT AUTO_INCREMENT,
322-
b BIT(15),
323-
v BIT(15) AS (b) VIRTUAL,
324-
PRIMARY KEY(pk),
325-
UNIQUE(v)
326-
) ENGINE=InnoDB;
327-
INSERT IGNORE INTO t1 (b) VALUES
328-
(NULL),(b'011'),(b'000110100'),
329-
(b'01101101010'),(b'01111001001011'),(NULL);
330-
331-
SET GLOBAL innodb_debug_sync = "ib_clust_v_col_before_row_allocated "
332-
"SIGNAL before_row_allocated "
333-
"WAIT_FOR flush_unlock";
334-
SET GLOBAL innodb_debug_sync = "ib_open_after_dict_open "
335-
"SIGNAL purge_open "
336-
"WAIT_FOR select_open";
337-
338-
# In 10.2 trx_undo_roll_ptr_is_insert(t_roll_ptr) condition never pass in purge,
339-
# so this condition is forced to pass in row_vers_old_has_index_entry
340-
SET @saved_dbug= @@GLOBAL.debug_dbug;
341-
set global debug_dbug= "d,ib_purge_virtual_index_callback";
342-
343-
# The purge starts from REPLACE command. To avoid possible race, separate
344-
# connection is used.
345-
--connect(purge_waiter,localhost,root)
346-
--send
347-
SET debug_sync= "now WAIT_FOR before_row_allocated";
348-
349-
--connection default
350-
REPLACE INTO t1 (pk, b) SELECT pk, b FROM t1;
351-
352-
--connection purge_waiter
353-
# Now we will definitely catch ib_clust_v_col_before_row_allocated
354-
--reap
355-
--connection default
356-
--disconnect purge_waiter
357-
358-
# purge hangs on the sync point. table is purged, ref_count is set to 0
359-
FLUSH TABLES;
360-
361-
# Avoid hang on repeating purge.
362-
# Reset Will be applied after first record is purged
363-
SET GLOBAL innodb_debug_sync = reset;
364-
365-
SET debug_sync= "now SIGNAL flush_unlock WAIT_FOR purge_open";
366-
367-
# Avoid hang on repeating purge
368-
SET GLOBAL innodb_debug_sync = reset;
369-
370-
# select unblocks purge thread
371-
SET debug_sync= "ib_open_after_dict_open SIGNAL select_open";
372-
SELECT * FROM t1;
373-
374-
# Cleanup
375-
DROP TABLE t1;
376-
SET debug_sync= reset;
377-
set global debug_dbug= @saved_dbug;
Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,16 @@
1-
CREATE PROCEDURE populate_t1()
2-
BEGIN
3-
DECLARE i int DEFAULT 1;
4-
START TRANSACTION;
5-
WHILE (i <= 1000000) DO
6-
INSERT INTO t1 VALUES (i, i, CONCAT('a', i));
7-
SET i = i + 1;
8-
END WHILE;
9-
COMMIT;
10-
END|
1+
set use_stat_tables='preferably';
112
CREATE TABLE t1(
123
class INT,
134
id INT,
145
title VARCHAR(100)
156
) ENGINE=InnoDB;
7+
insert into t1 select seq, seq, concat('a', seq) from seq_1_to_500;
168
SELECT COUNT(*) FROM t1;
179
COUNT(*)
18-
1000000
19-
SET GLOBAL innodb_stats_persistent_sample_pages=2000;
10+
500
11+
set @@max_heap_table_size=16384;
2012
ANALYZE TABLE t1;
2113
Table Op Msg_type Msg_text
14+
test.t1 analyze status Engine-independent statistics collected
2215
test.t1 analyze status OK
2316
DROP TABLE t1;
24-
DROP PROCEDURE populate_t1;
25-
SET GLOBAL innodb_stats_persistent_sample_pages=default;

0 commit comments

Comments
 (0)