diff options
author | Jan Lindström <jan.lindstrom@mariadb.com> | 2015-09-15 09:35:38 +0300 |
---|---|---|
committer | Jan Lindström <jan.lindstrom@mariadb.com> | 2015-09-15 09:40:04 +0300 |
commit | 9e6f3df51a1f53f336c8c02b85c3ce0de42ce5d7 (patch) | |
tree | 4324c1a4fe4a0335ea7f83daa762cdc5ca4f320e | |
parent | 3a0df3cf3c0e7ab4c2532668df2a7bd003388527 (diff) | |
download | mariadb-git-9e6f3df51a1f53f336c8c02b85c3ce0de42ce5d7.tar.gz |
MDEV-8799: Server crashes in btr_defragment_add_index, encryption.innodb-bad-key-change5 and alike fail in buildbot
Problem was unsafe access to NULL pointer. Added additional checks to avoid
access to NULL pointer.
-rw-r--r-- | storage/innobase/btr/btr0cur.cc | 19 | ||||
-rw-r--r-- | storage/innobase/btr/btr0defragment.cc | 8 | ||||
-rw-r--r-- | storage/innobase/btr/btr0scrub.cc | 17 | ||||
-rw-r--r-- | storage/xtradb/btr/btr0cur.cc | 19 | ||||
-rw-r--r-- | storage/xtradb/btr/btr0defragment.cc | 8 | ||||
-rw-r--r-- | storage/xtradb/btr/btr0scrub.cc | 17 |
6 files changed, 66 insertions, 22 deletions
diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc index 5dbae5d291d..db23b75edf1 100644 --- a/storage/innobase/btr/btr0cur.cc +++ b/storage/innobase/btr/btr0cur.cc @@ -1671,15 +1671,24 @@ btr_cur_pessimistic_insert( btr_cur_get_page_zip(cursor), thr_get_trx(thr)->id, mtr); } - if (!page_rec_is_infimum(btr_cur_get_rec(cursor)) - || btr_page_get_prev( - buf_block_get_frame( - btr_cur_get_block(cursor)), mtr) - == FIL_NULL) { + + if (!page_rec_is_infimum(btr_cur_get_rec(cursor))) { /* split and inserted need to call lock_update_insert() always. */ inherit = TRUE; } + + buf_block_t* block = btr_cur_get_block(cursor); + buf_frame_t* frame = NULL; + + if (block) { + frame = buf_block_get_frame(block); + } + /* split and inserted need to call + lock_update_insert() always. */ + if (frame && btr_page_get_prev(frame, mtr) == FIL_NULL) { + inherit = TRUE; + } } #ifdef BTR_CUR_ADAPT diff --git a/storage/innobase/btr/btr0defragment.cc b/storage/innobase/btr/btr0defragment.cc index 30b3a467183..26bab936de5 100644 --- a/storage/innobase/btr/btr0defragment.cc +++ b/storage/innobase/btr/btr0defragment.cc @@ -220,8 +220,12 @@ btr_defragment_add_index( mtr_start(&mtr); // Load index rood page. - page_t* page = btr_page_get(space, zip_size, page_no, - RW_NO_LATCH, index, &mtr); + buf_block_t* block = btr_block_get(space, zip_size, page_no, RW_NO_LATCH, index, &mtr); + page_t* page = NULL; + + if (block) { + page = buf_block_get_frame(block); + } if (page == NULL && index->table->is_encrypted) { mtr_commit(&mtr); diff --git a/storage/innobase/btr/btr0scrub.cc b/storage/innobase/btr/btr0scrub.cc index d53b478e429..e6acb7802f1 100644 --- a/storage/innobase/btr/btr0scrub.cc +++ b/storage/innobase/btr/btr0scrub.cc @@ -750,9 +750,13 @@ btr_scrub_page( mtr_t* mtr) /*!< in: mtr */ { /* recheck if page needs scrubbing (knowing allocation status) */ - int needs_scrubbing = btr_page_needs_scrubbing( - scrub_data, block, allocated); - if (needs_scrubbing != BTR_SCRUB_PAGE) { + int needs_scrubbing = BTR_SCRUB_SKIP_PAGE_AND_CLOSE_TABLE; + + if (block) { + btr_page_needs_scrubbing(scrub_data, block, allocated); + } + + if (!block || needs_scrubbing != BTR_SCRUB_PAGE) { mtr_commit(mtr); return needs_scrubbing; } @@ -784,7 +788,12 @@ btr_scrub_page( return BTR_SCRUB_SKIP_PAGE_AND_CLOSE_TABLE; } - if (btr_page_get_index_id(buf_block_get_frame(block)) != + buf_frame_t* frame = NULL; + + if (block) { + frame = buf_block_get_frame(block); + } + if (!frame || btr_page_get_index_id(frame) != scrub_data->current_index->id) { /* page has been reallocated to new index */ mtr_commit(mtr); diff --git a/storage/xtradb/btr/btr0cur.cc b/storage/xtradb/btr/btr0cur.cc index 728d14e6309..44b0e50fa0f 100644 --- a/storage/xtradb/btr/btr0cur.cc +++ b/storage/xtradb/btr/btr0cur.cc @@ -1795,15 +1795,24 @@ btr_cur_pessimistic_insert( btr_cur_get_page_zip(cursor), thr_get_trx(thr)->id, mtr); } - if (!page_rec_is_infimum(btr_cur_get_rec(cursor)) - || btr_page_get_prev( - buf_block_get_frame( - btr_cur_get_block(cursor)), mtr) - == FIL_NULL) { + + if (!page_rec_is_infimum(btr_cur_get_rec(cursor))) { /* split and inserted need to call lock_update_insert() always. */ inherit = TRUE; } + + buf_block_t* block = btr_cur_get_block(cursor); + buf_frame_t* frame = NULL; + + if (block) { + frame = buf_block_get_frame(block); + } + /* split and inserted need to call + lock_update_insert() always. */ + if (frame && btr_page_get_prev(frame, mtr) == FIL_NULL) { + inherit = TRUE; + } } #ifdef BTR_CUR_ADAPT diff --git a/storage/xtradb/btr/btr0defragment.cc b/storage/xtradb/btr/btr0defragment.cc index 7f502eb5084..6e7a3fd2411 100644 --- a/storage/xtradb/btr/btr0defragment.cc +++ b/storage/xtradb/btr/btr0defragment.cc @@ -220,8 +220,12 @@ btr_defragment_add_index( mtr_start(&mtr); // Load index rood page. - page_t* page = btr_page_get(space, zip_size, page_no, - RW_NO_LATCH, index, &mtr); + buf_block_t* block = btr_block_get(space, zip_size, page_no, RW_NO_LATCH, index, &mtr); + page_t* page = NULL; + + if (block) { + page = buf_block_get_frame(block); + } if (page == NULL && index->table->is_encrypted) { mtr_commit(&mtr); diff --git a/storage/xtradb/btr/btr0scrub.cc b/storage/xtradb/btr/btr0scrub.cc index d53b478e429..e6acb7802f1 100644 --- a/storage/xtradb/btr/btr0scrub.cc +++ b/storage/xtradb/btr/btr0scrub.cc @@ -750,9 +750,13 @@ btr_scrub_page( mtr_t* mtr) /*!< in: mtr */ { /* recheck if page needs scrubbing (knowing allocation status) */ - int needs_scrubbing = btr_page_needs_scrubbing( - scrub_data, block, allocated); - if (needs_scrubbing != BTR_SCRUB_PAGE) { + int needs_scrubbing = BTR_SCRUB_SKIP_PAGE_AND_CLOSE_TABLE; + + if (block) { + btr_page_needs_scrubbing(scrub_data, block, allocated); + } + + if (!block || needs_scrubbing != BTR_SCRUB_PAGE) { mtr_commit(mtr); return needs_scrubbing; } @@ -784,7 +788,12 @@ btr_scrub_page( return BTR_SCRUB_SKIP_PAGE_AND_CLOSE_TABLE; } - if (btr_page_get_index_id(buf_block_get_frame(block)) != + buf_frame_t* frame = NULL; + + if (block) { + frame = buf_block_get_frame(block); + } + if (!frame || btr_page_get_index_id(frame) != scrub_data->current_index->id) { /* page has been reallocated to new index */ mtr_commit(mtr); |