Skip to content

Commit 2c1553e

Browse files
author
Jan Lindström
committed
MDEV-8774: Test innodb.innodb_bug53290 failures on buildbot
Fixed unsafe reference to null pointer.
1 parent de269f2 commit 2c1553e

File tree

4 files changed

+32
-30
lines changed

4 files changed

+32
-30
lines changed

storage/innobase/include/row0merge.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,5 +457,5 @@ row_merge_read_rec(
457457
fil_space_crypt_t* crypt_data,/*!< in: table crypt data */
458458
row_merge_block_t* crypt_block, /*!< in: crypt buf or NULL */
459459
ulint space) /*!< in: space id */
460-
__attribute__((nonnull, warn_unused_result));
460+
__attribute__((nonnull(1,2,3,4,6,7,8), warn_unused_result));
461461
#endif /* row0merge.h */

storage/innobase/row/row0merge.cc

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2131,7 +2131,7 @@ row_merge_read_clustered_index(
21312131
of->fd, &of->offset, \
21322132
mrec##N, offsets##N, \
21332133
crypt_data, \
2134-
&crypt_block[2 * srv_sort_buf_size], \
2134+
crypt_block ? &crypt_block[2 * srv_sort_buf_size] : NULL , \
21352135
space); \
21362136
if (UNIV_UNLIKELY(!b2 || ++of->n_rec > file->n_rec)) { \
21372137
goto corrupt; \
@@ -2141,7 +2141,7 @@ row_merge_read_clustered_index(
21412141
file->fd, foffs##N, \
21422142
&mrec##N, offsets##N, \
21432143
crypt_data, \
2144-
&crypt_block[N * srv_sort_buf_size], \
2144+
crypt_block ? &crypt_block[N * srv_sort_buf_size] : NULL, \
21452145
space); \
21462146
\
21472147
if (UNIV_UNLIKELY(!b##N)) { \
@@ -2155,7 +2155,7 @@ row_merge_read_clustered_index(
21552155
/*************************************************************//**
21562156
Merge two blocks of records on disk and write a bigger block.
21572157
@return DB_SUCCESS or error code */
2158-
static __attribute__((nonnull, warn_unused_result))
2158+
static __attribute__((nonnull(1,2,3,4,5,6), warn_unused_result))
21592159
dberr_t
21602160
row_merge_blocks(
21612161
/*=============*/
@@ -2204,9 +2204,9 @@ row_merge_blocks(
22042204
file in two halves, which can be merged on the following pass. */
22052205

22062206
if (!row_merge_read(file->fd, *foffs0, &block[0],
2207-
crypt_data, &crypt_block[0], space)
2207+
crypt_data, crypt_block ? &crypt_block[0] : NULL, space)
22082208
|| !row_merge_read(file->fd, *foffs1, &block[srv_sort_buf_size],
2209-
crypt_data, &crypt_block[srv_sort_buf_size], space)) {
2209+
crypt_data, crypt_block ? &crypt_block[srv_sort_buf_size] : NULL, space)) {
22102210
corrupt:
22112211
mem_heap_free(heap);
22122212
return(DB_CORRUPTION);
@@ -2219,13 +2219,13 @@ row_merge_blocks(
22192219
b0 = row_merge_read_rec(
22202220
&block[0], &buf[0], b0, dup->index,
22212221
file->fd, foffs0, &mrec0, offsets0,
2222-
crypt_data, &crypt_block[0], space);
2222+
crypt_data, crypt_block ? &crypt_block[0] : NULL, space);
22232223

22242224
b1 = row_merge_read_rec(
22252225
&block[srv_sort_buf_size],
22262226
&buf[srv_sort_buf_size], b1, dup->index,
22272227
file->fd, foffs1, &mrec1, offsets1,
2228-
crypt_data, &crypt_block[srv_sort_buf_size], space);
2228+
crypt_data, crypt_block ? &crypt_block[srv_sort_buf_size] : NULL, space);
22292229

22302230
if (UNIV_UNLIKELY(!b0 && mrec0)
22312231
|| UNIV_UNLIKELY(!b1 && mrec1)) {
@@ -2271,15 +2271,15 @@ row_merge_blocks(
22712271

22722272
b2 = row_merge_write_eof(&block[2 * srv_sort_buf_size],
22732273
b2, of->fd, &of->offset,
2274-
crypt_data, &crypt_block[2 * srv_sort_buf_size], space);
2274+
crypt_data, crypt_block ? &crypt_block[2 * srv_sort_buf_size] : NULL, space);
22752275

22762276
return(b2 ? DB_SUCCESS : DB_CORRUPTION);
22772277
}
22782278

22792279
/*************************************************************//**
22802280
Copy a block of index entries.
22812281
@return TRUE on success, FALSE on failure */
2282-
static __attribute__((nonnull, warn_unused_result))
2282+
static __attribute__((nonnull(1,2,3,4,5), warn_unused_result))
22832283
ibool
22842284
row_merge_blocks_copy(
22852285
/*==================*/
@@ -2318,7 +2318,7 @@ row_merge_blocks_copy(
23182318
file in two halves, which can be merged on the following pass. */
23192319

23202320
if (!row_merge_read(file->fd, *foffs0, &block[0],
2321-
crypt_data, &crypt_block[0], space)) {
2321+
crypt_data, crypt_block ? &crypt_block[0] : NULL, space)) {
23222322
corrupt:
23232323
mem_heap_free(heap);
23242324
return(FALSE);
@@ -2330,7 +2330,7 @@ row_merge_blocks_copy(
23302330

23312331
b0 = row_merge_read_rec(&block[0], &buf[0], b0, index,
23322332
file->fd, foffs0, &mrec0, offsets0,
2333-
crypt_data, &crypt_block[0], space);
2333+
crypt_data, crypt_block ? &crypt_block[0] : NULL, space);
23342334

23352335
if (UNIV_UNLIKELY(!b0 && mrec0)) {
23362336

@@ -2353,14 +2353,15 @@ row_merge_blocks_copy(
23532353

23542354
return(row_merge_write_eof(&block[2 * srv_sort_buf_size],
23552355
b2, of->fd, &of->offset,
2356-
crypt_data, &crypt_block[2 * srv_sort_buf_size], space)
2356+
crypt_data,
2357+
crypt_block ? &crypt_block[2 * srv_sort_buf_size] : NULL, space)
23572358
!= NULL);
23582359
}
23592360

23602361
/*************************************************************//**
23612362
Merge disk files.
23622363
@return DB_SUCCESS or error code */
2363-
static __attribute__((nonnull))
2364+
static __attribute__((nonnull(1,2,3,4,5,6,7)))
23642365
dberr_t
23652366
row_merge(
23662367
/*======*/
@@ -2648,7 +2649,7 @@ row_merge_copy_blobs(
26482649
Read sorted file containing index data tuples and insert these data
26492650
tuples to the index
26502651
@return DB_SUCCESS or error number */
2651-
static __attribute__((nonnull, warn_unused_result))
2652+
static __attribute__((nonnull(2,3,5), warn_unused_result))
26522653
dberr_t
26532654
row_merge_insert_index_tuples(
26542655
/*==========================*/

storage/xtradb/include/row0merge.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,5 +457,5 @@ row_merge_read_rec(
457457
fil_space_crypt_t* crypt_data,/*!< in: table crypt data */
458458
row_merge_block_t* crypt_block, /*!< in: crypt buf or NULL */
459459
ulint space) /*!< in: space id */
460-
__attribute__((nonnull, warn_unused_result));
460+
__attribute__((nonnull(1,2,3,4,6,7,8), warn_unused_result));
461461
#endif /* row0merge.h */

storage/xtradb/row/row0merge.cc

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2139,7 +2139,7 @@ row_merge_read_clustered_index(
21392139
of->fd, &of->offset, \
21402140
mrec##N, offsets##N, \
21412141
crypt_data, \
2142-
&crypt_block[2 * srv_sort_buf_size], \
2142+
crypt_block ? &crypt_block[2 * srv_sort_buf_size] : NULL , \
21432143
space); \
21442144
if (UNIV_UNLIKELY(!b2 || ++of->n_rec > file->n_rec)) { \
21452145
goto corrupt; \
@@ -2149,7 +2149,7 @@ row_merge_read_clustered_index(
21492149
file->fd, foffs##N, \
21502150
&mrec##N, offsets##N, \
21512151
crypt_data, \
2152-
&crypt_block[N * srv_sort_buf_size], \
2152+
crypt_block ? &crypt_block[N * srv_sort_buf_size] : NULL, \
21532153
space); \
21542154
\
21552155
if (UNIV_UNLIKELY(!b##N)) { \
@@ -2163,7 +2163,7 @@ row_merge_read_clustered_index(
21632163
/*************************************************************//**
21642164
Merge two blocks of records on disk and write a bigger block.
21652165
@return DB_SUCCESS or error code */
2166-
static __attribute__((nonnull, warn_unused_result))
2166+
static __attribute__((nonnull(1,2,3,4,5,6), warn_unused_result))
21672167
dberr_t
21682168
row_merge_blocks(
21692169
/*=============*/
@@ -2212,9 +2212,9 @@ row_merge_blocks(
22122212
file in two halves, which can be merged on the following pass. */
22132213

22142214
if (!row_merge_read(file->fd, *foffs0, &block[0],
2215-
crypt_data, &crypt_block[0], space)
2215+
crypt_data, crypt_block ? &crypt_block[0] : NULL, space)
22162216
|| !row_merge_read(file->fd, *foffs1, &block[srv_sort_buf_size],
2217-
crypt_data, &crypt_block[srv_sort_buf_size], space)) {
2217+
crypt_data, crypt_block ? &crypt_block[srv_sort_buf_size] : NULL, space)) {
22182218
corrupt:
22192219
mem_heap_free(heap);
22202220
return(DB_CORRUPTION);
@@ -2227,13 +2227,13 @@ row_merge_blocks(
22272227
b0 = row_merge_read_rec(
22282228
&block[0], &buf[0], b0, dup->index,
22292229
file->fd, foffs0, &mrec0, offsets0,
2230-
crypt_data, &crypt_block[0], space);
2230+
crypt_data, crypt_block ? &crypt_block[0] : NULL, space);
22312231

22322232
b1 = row_merge_read_rec(
22332233
&block[srv_sort_buf_size],
22342234
&buf[srv_sort_buf_size], b1, dup->index,
22352235
file->fd, foffs1, &mrec1, offsets1,
2236-
crypt_data, &crypt_block[srv_sort_buf_size], space);
2236+
crypt_data, crypt_block ? &crypt_block[srv_sort_buf_size] : NULL, space);
22372237

22382238
if (UNIV_UNLIKELY(!b0 && mrec0)
22392239
|| UNIV_UNLIKELY(!b1 && mrec1)) {
@@ -2279,15 +2279,15 @@ row_merge_blocks(
22792279

22802280
b2 = row_merge_write_eof(&block[2 * srv_sort_buf_size],
22812281
b2, of->fd, &of->offset,
2282-
crypt_data, &crypt_block[2 * srv_sort_buf_size], space);
2282+
crypt_data, crypt_block ? &crypt_block[2 * srv_sort_buf_size] : NULL, space);
22832283

22842284
return(b2 ? DB_SUCCESS : DB_CORRUPTION);
22852285
}
22862286

22872287
/*************************************************************//**
22882288
Copy a block of index entries.
22892289
@return TRUE on success, FALSE on failure */
2290-
static __attribute__((nonnull, warn_unused_result))
2290+
static __attribute__((nonnull(1,2,3,4,5), warn_unused_result))
22912291
ibool
22922292
row_merge_blocks_copy(
22932293
/*==================*/
@@ -2326,7 +2326,7 @@ row_merge_blocks_copy(
23262326
file in two halves, which can be merged on the following pass. */
23272327

23282328
if (!row_merge_read(file->fd, *foffs0, &block[0],
2329-
crypt_data, &crypt_block[0], space)) {
2329+
crypt_data, crypt_block ? &crypt_block[0] : NULL, space)) {
23302330
corrupt:
23312331
mem_heap_free(heap);
23322332
return(FALSE);
@@ -2338,7 +2338,7 @@ row_merge_blocks_copy(
23382338

23392339
b0 = row_merge_read_rec(&block[0], &buf[0], b0, index,
23402340
file->fd, foffs0, &mrec0, offsets0,
2341-
crypt_data, &crypt_block[0], space);
2341+
crypt_data, crypt_block ? &crypt_block[0] : NULL, space);
23422342

23432343
if (UNIV_UNLIKELY(!b0 && mrec0)) {
23442344

@@ -2361,14 +2361,15 @@ row_merge_blocks_copy(
23612361

23622362
return(row_merge_write_eof(&block[2 * srv_sort_buf_size],
23632363
b2, of->fd, &of->offset,
2364-
crypt_data, &crypt_block[2 * srv_sort_buf_size], space)
2364+
crypt_data,
2365+
crypt_block ? &crypt_block[2 * srv_sort_buf_size] : NULL, space)
23652366
!= NULL);
23662367
}
23672368

23682369
/*************************************************************//**
23692370
Merge disk files.
23702371
@return DB_SUCCESS or error code */
2371-
static __attribute__((nonnull))
2372+
static __attribute__((nonnull(1,2,3,4,5,6,7)))
23722373
dberr_t
23732374
row_merge(
23742375
/*======*/
@@ -2656,7 +2657,7 @@ row_merge_copy_blobs(
26562657
Read sorted file containing index data tuples and insert these data
26572658
tuples to the index
26582659
@return DB_SUCCESS or error number */
2659-
static __attribute__((nonnull, warn_unused_result))
2660+
static __attribute__((nonnull(2,3,5), warn_unused_result))
26602661
dberr_t
26612662
row_merge_insert_index_tuples(
26622663
/*==========================*/

0 commit comments

Comments
 (0)