Fixed a potential bug that could cause a segment fault when insert a large tuple. #716
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.
Statement
In the file
src/storage/page/table_page.cpp
, Here is aTablePage::GetNextTupleOffset
function.Since
tuple_offset
is unsigned long, tuple_offset will be greater than the value of offset_size after underflow occurs. Therefore, the condition ofif
clause is not satisfied, we will return an error tuple_offset(the value of tuple_offset exceeds the page size). When we insert a tuple at this position, a segment fault occurs.How to hack it
I reproduced this fault using BusTub Web Shell(Fall 2023).
First, create a table with larger schema.
Then, insert some tuples into it. In this example, I inserted$3$ tuples of $2500$ bytes long.
Then, You should be able to observe that the program has failed.