Skip to content

Commit

Permalink
MDEV-8774: Test innodb.innodb_bug53290 failures on buildbot
Browse files Browse the repository at this point in the history
Fixed unsafe reference to null pointer.
  • Loading branch information
Jan Lindström committed Sep 8, 2015
1 parent de269f2 commit 2c1553e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 30 deletions.
2 changes: 1 addition & 1 deletion storage/innobase/include/row0merge.h
Original file line number Diff line number Diff line change
Expand Up @@ -457,5 +457,5 @@ row_merge_read_rec(
fil_space_crypt_t* crypt_data,/*!< in: table crypt data */
row_merge_block_t* crypt_block, /*!< in: crypt buf or NULL */
ulint space) /*!< in: space id */
__attribute__((nonnull, warn_unused_result));
__attribute__((nonnull(1,2,3,4,6,7,8), warn_unused_result));
#endif /* row0merge.h */
29 changes: 15 additions & 14 deletions storage/innobase/row/row0merge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2131,7 +2131,7 @@ row_merge_read_clustered_index(
of->fd, &of->offset, \
mrec##N, offsets##N, \
crypt_data, \
&crypt_block[2 * srv_sort_buf_size], \
crypt_block ? &crypt_block[2 * srv_sort_buf_size] : NULL , \
space); \
if (UNIV_UNLIKELY(!b2 || ++of->n_rec > file->n_rec)) { \
goto corrupt; \
Expand All @@ -2141,7 +2141,7 @@ row_merge_read_clustered_index(
file->fd, foffs##N, \
&mrec##N, offsets##N, \
crypt_data, \
&crypt_block[N * srv_sort_buf_size], \
crypt_block ? &crypt_block[N * srv_sort_buf_size] : NULL, \
space); \
\
if (UNIV_UNLIKELY(!b##N)) { \
Expand All @@ -2155,7 +2155,7 @@ row_merge_read_clustered_index(
/*************************************************************//**
Merge two blocks of records on disk and write a bigger block.
@return DB_SUCCESS or error code */
static __attribute__((nonnull, warn_unused_result))
static __attribute__((nonnull(1,2,3,4,5,6), warn_unused_result))
dberr_t
row_merge_blocks(
/*=============*/
Expand Down Expand Up @@ -2204,9 +2204,9 @@ row_merge_blocks(
file in two halves, which can be merged on the following pass. */

if (!row_merge_read(file->fd, *foffs0, &block[0],
crypt_data, &crypt_block[0], space)
crypt_data, crypt_block ? &crypt_block[0] : NULL, space)
|| !row_merge_read(file->fd, *foffs1, &block[srv_sort_buf_size],
crypt_data, &crypt_block[srv_sort_buf_size], space)) {
crypt_data, crypt_block ? &crypt_block[srv_sort_buf_size] : NULL, space)) {
corrupt:
mem_heap_free(heap);
return(DB_CORRUPTION);
Expand All @@ -2219,13 +2219,13 @@ row_merge_blocks(
b0 = row_merge_read_rec(
&block[0], &buf[0], b0, dup->index,
file->fd, foffs0, &mrec0, offsets0,
crypt_data, &crypt_block[0], space);
crypt_data, crypt_block ? &crypt_block[0] : NULL, space);

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

if (UNIV_UNLIKELY(!b0 && mrec0)
|| UNIV_UNLIKELY(!b1 && mrec1)) {
Expand Down Expand Up @@ -2271,15 +2271,15 @@ row_merge_blocks(

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

return(b2 ? DB_SUCCESS : DB_CORRUPTION);
}

/*************************************************************//**
Copy a block of index entries.
@return TRUE on success, FALSE on failure */
static __attribute__((nonnull, warn_unused_result))
static __attribute__((nonnull(1,2,3,4,5), warn_unused_result))
ibool
row_merge_blocks_copy(
/*==================*/
Expand Down Expand Up @@ -2318,7 +2318,7 @@ row_merge_blocks_copy(
file in two halves, which can be merged on the following pass. */

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

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

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

Expand All @@ -2353,14 +2353,15 @@ row_merge_blocks_copy(

return(row_merge_write_eof(&block[2 * srv_sort_buf_size],
b2, of->fd, &of->offset,
crypt_data, &crypt_block[2 * srv_sort_buf_size], space)
crypt_data,
crypt_block ? &crypt_block[2 * srv_sort_buf_size] : NULL, space)
!= NULL);
}

/*************************************************************//**
Merge disk files.
@return DB_SUCCESS or error code */
static __attribute__((nonnull))
static __attribute__((nonnull(1,2,3,4,5,6,7)))
dberr_t
row_merge(
/*======*/
Expand Down Expand Up @@ -2648,7 +2649,7 @@ row_merge_copy_blobs(
Read sorted file containing index data tuples and insert these data
tuples to the index
@return DB_SUCCESS or error number */
static __attribute__((nonnull, warn_unused_result))
static __attribute__((nonnull(2,3,5), warn_unused_result))
dberr_t
row_merge_insert_index_tuples(
/*==========================*/
Expand Down
2 changes: 1 addition & 1 deletion storage/xtradb/include/row0merge.h
Original file line number Diff line number Diff line change
Expand Up @@ -457,5 +457,5 @@ row_merge_read_rec(
fil_space_crypt_t* crypt_data,/*!< in: table crypt data */
row_merge_block_t* crypt_block, /*!< in: crypt buf or NULL */
ulint space) /*!< in: space id */
__attribute__((nonnull, warn_unused_result));
__attribute__((nonnull(1,2,3,4,6,7,8), warn_unused_result));
#endif /* row0merge.h */
29 changes: 15 additions & 14 deletions storage/xtradb/row/row0merge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2139,7 +2139,7 @@ row_merge_read_clustered_index(
of->fd, &of->offset, \
mrec##N, offsets##N, \
crypt_data, \
&crypt_block[2 * srv_sort_buf_size], \
crypt_block ? &crypt_block[2 * srv_sort_buf_size] : NULL , \
space); \
if (UNIV_UNLIKELY(!b2 || ++of->n_rec > file->n_rec)) { \
goto corrupt; \
Expand All @@ -2149,7 +2149,7 @@ row_merge_read_clustered_index(
file->fd, foffs##N, \
&mrec##N, offsets##N, \
crypt_data, \
&crypt_block[N * srv_sort_buf_size], \
crypt_block ? &crypt_block[N * srv_sort_buf_size] : NULL, \
space); \
\
if (UNIV_UNLIKELY(!b##N)) { \
Expand All @@ -2163,7 +2163,7 @@ row_merge_read_clustered_index(
/*************************************************************//**
Merge two blocks of records on disk and write a bigger block.
@return DB_SUCCESS or error code */
static __attribute__((nonnull, warn_unused_result))
static __attribute__((nonnull(1,2,3,4,5,6), warn_unused_result))
dberr_t
row_merge_blocks(
/*=============*/
Expand Down Expand Up @@ -2212,9 +2212,9 @@ row_merge_blocks(
file in two halves, which can be merged on the following pass. */

if (!row_merge_read(file->fd, *foffs0, &block[0],
crypt_data, &crypt_block[0], space)
crypt_data, crypt_block ? &crypt_block[0] : NULL, space)
|| !row_merge_read(file->fd, *foffs1, &block[srv_sort_buf_size],
crypt_data, &crypt_block[srv_sort_buf_size], space)) {
crypt_data, crypt_block ? &crypt_block[srv_sort_buf_size] : NULL, space)) {
corrupt:
mem_heap_free(heap);
return(DB_CORRUPTION);
Expand All @@ -2227,13 +2227,13 @@ row_merge_blocks(
b0 = row_merge_read_rec(
&block[0], &buf[0], b0, dup->index,
file->fd, foffs0, &mrec0, offsets0,
crypt_data, &crypt_block[0], space);
crypt_data, crypt_block ? &crypt_block[0] : NULL, space);

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

if (UNIV_UNLIKELY(!b0 && mrec0)
|| UNIV_UNLIKELY(!b1 && mrec1)) {
Expand Down Expand Up @@ -2279,15 +2279,15 @@ row_merge_blocks(

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

return(b2 ? DB_SUCCESS : DB_CORRUPTION);
}

/*************************************************************//**
Copy a block of index entries.
@return TRUE on success, FALSE on failure */
static __attribute__((nonnull, warn_unused_result))
static __attribute__((nonnull(1,2,3,4,5), warn_unused_result))
ibool
row_merge_blocks_copy(
/*==================*/
Expand Down Expand Up @@ -2326,7 +2326,7 @@ row_merge_blocks_copy(
file in two halves, which can be merged on the following pass. */

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

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

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

Expand All @@ -2361,14 +2361,15 @@ row_merge_blocks_copy(

return(row_merge_write_eof(&block[2 * srv_sort_buf_size],
b2, of->fd, &of->offset,
crypt_data, &crypt_block[2 * srv_sort_buf_size], space)
crypt_data,
crypt_block ? &crypt_block[2 * srv_sort_buf_size] : NULL, space)
!= NULL);
}

/*************************************************************//**
Merge disk files.
@return DB_SUCCESS or error code */
static __attribute__((nonnull))
static __attribute__((nonnull(1,2,3,4,5,6,7)))
dberr_t
row_merge(
/*======*/
Expand Down Expand Up @@ -2656,7 +2657,7 @@ row_merge_copy_blobs(
Read sorted file containing index data tuples and insert these data
tuples to the index
@return DB_SUCCESS or error number */
static __attribute__((nonnull, warn_unused_result))
static __attribute__((nonnull(2,3,5), warn_unused_result))
dberr_t
row_merge_insert_index_tuples(
/*==========================*/
Expand Down

0 comments on commit 2c1553e

Please sign in to comment.