Repository navigation
Validate irt_backslot on index root pages #9241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Pyolar
wants to merge
5
commits into
FirebirdSQL:master
Choose a base branch
from
Pyolar:fix/irt-backslot-validation
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+128
−6
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0f75dde
Validate irt_backslot against the index slot count
Pyolar 4e348ee
Require the irt_migrate state in getBackSlot()
Pyolar d356e5d
Deduplicate the getBackSlot overloads
Pyolar 1ca65a7
Release the index root page on bugcheck
Pyolar 7a570b0
Unwind the cache on the corrupted backslot paths
Pyolar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| #include "firebird.h" | ||
| #include "boost/test/unit_test.hpp" | ||
| #include "../jrd/ods.h" | ||
|
|
||
| using namespace Firebird; | ||
| using namespace Jrd; | ||
| using namespace Ods; | ||
|
|
||
| BOOST_AUTO_TEST_SUITE(EngineSuite) | ||
| BOOST_AUTO_TEST_SUITE(IndexRootPageSuite) | ||
|
|
||
|
|
||
| BOOST_AUTO_TEST_SUITE(BackSlotTests) | ||
|
|
||
| // Index root page image with room for 16 slots | ||
| union RootPageImage | ||
| { | ||
| index_root_page page; | ||
| UCHAR bytes[sizeof(index_root_page) + 15 * sizeof(index_root_page::irt_repeat)]; | ||
| }; | ||
|
|
||
| // Zero-filled image, so every test case starts from a clean page | ||
| static index_root_page* makeRootPage(unsigned count) | ||
| { | ||
| static RootPageImage image; | ||
|
|
||
| memset(&image, 0, sizeof(image)); | ||
| image.page.irt_relation = 1; | ||
| image.page.irt_count = count; | ||
| return &image.page; | ||
| } | ||
|
|
||
| // Bring a slot into the irt_migrate state through the regular state | ||
| // transitions, ending with the given backing slot number | ||
| static index_root_page::irt_repeat* makeMigratedSlot(index_root_page::irt_repeat* slot, USHORT backSlot) | ||
| { | ||
| slot->setInProgress(12); | ||
| slot->setInProgress(PageNumber(1, 77), 12); | ||
| slot->setKill(); | ||
| slot->setRollback(12); | ||
| slot->setMigrate(PageNumber(1, 99), 12, backSlot); | ||
| return slot; | ||
| } | ||
|
|
||
| BOOST_AUTO_TEST_CASE(BackSlotInRange) | ||
| { | ||
| auto root = makeRootPage(4); | ||
|
|
||
| makeMigratedSlot(&root->irt_rpt[1], 2); | ||
| BOOST_TEST(root->getBackSlot(&root->irt_rpt[1]) == &root->irt_rpt[2]); | ||
|
|
||
| root->irt_rpt[1].setMigrate(PageNumber(1, 99), 12, 3); // last valid slot | ||
| BOOST_TEST(root->getBackSlot(&root->irt_rpt[1]) == &root->irt_rpt[3]); | ||
| } | ||
|
|
||
| BOOST_AUTO_TEST_CASE(BackSlotOutOfRange) | ||
| { | ||
| auto root = makeRootPage(4); | ||
|
|
||
| makeMigratedSlot(&root->irt_rpt[0], 4); // == irt_count | ||
| BOOST_TEST(root->getBackSlot(&root->irt_rpt[0]) == nullptr); | ||
|
|
||
| root->irt_rpt[0].setMigrate(PageNumber(1, 99), 12, 0xFFFF); | ||
| BOOST_TEST(root->getBackSlot(&root->irt_rpt[0]) == nullptr); | ||
|
|
||
| root->irt_count = 0; // no slot may resolve anymore | ||
| BOOST_TEST(root->getBackSlot(&root->irt_rpt[0]) == nullptr); | ||
| } | ||
|
|
||
| BOOST_AUTO_TEST_CASE(BackSlotNotMigrating) | ||
| { | ||
| auto root = makeRootPage(4); | ||
|
|
||
| // slot in the regular working state: the backing slot number is | ||
| // meaningless and must not resolve even when in range | ||
| auto slot = &root->irt_rpt[1]; | ||
| slot->setInProgress(12); | ||
| slot->setInProgress(PageNumber(1, 77), 12); | ||
| slot->setKill(); | ||
| slot->setRollback(12); | ||
| slot->setNormal(); | ||
| slot->irt_backslot = 2; | ||
|
|
||
| BOOST_TEST(root->getBackSlot(slot) == nullptr); | ||
| } | ||
|
|
||
| BOOST_AUTO_TEST_SUITE_END() // BackSlotTests | ||
|
|
||
|
|
||
| BOOST_AUTO_TEST_SUITE_END() // IndexRootPageSuite | ||
| BOOST_AUTO_TEST_SUITE_END() // EngineSuite |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.