-
Notifications
You must be signed in to change notification settings - Fork 51
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
Fix snapshot mapping merge bug #230
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Key Issues
Critical issues include missing null checks for deserialized headers, potential division by zero and overflow errors in calculations, and incorrect conditions for handling overlapping segments, all of which could lead to application crashes or incorrect data processing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to make sure I understand it correctly BuildStorageOffset
corresponds to the data in the file right, which consists of only the changed blocks for that BuildId
, so based on BuildStorageOffset
you know where to read at that file.
I didn't check the visualizer. Thanks for tests! I think they are really helpful here. Maybe adding tests for BuildStorageOffset
would make sense as well.
Yes.
Maybe adding tests for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Key Issues
The code lacks validation for a non-zero blockSize
, which can lead to division errors and potential crashes. Additionally, it assumes mapping.Length
and mapping.Offset
are multiples of blockSize
, risking incorrect calculations and data loss if this assumption is violated.
// It is used for debugging and visualization. | ||
// | ||
// You can pass maps to visualize different groups of buildIds. | ||
func Visualize(mappings []*BuildMap, size, blockSize, cols uint64, bottomGroup, topGroup *map[uuid.UUID]struct{}) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐛 Possible Bug
The code assumes blockSize
is non-zero but there's no validation. A zero blockSize
will cause a panic in multiple divisions (size/blockSize
, mapping.Length/blockSize
, mapping.Offset/blockSize
).
func Visualize(mappings []*BuildMap, size, blockSize, cols uint64, bottomGroup, topGroup *map[uuid.UUID]struct{}) string { | |
func Visualize(mappings []*BuildMap, size, blockSize, cols uint64, bottomGroup, topGroup *map[uuid.UUID]struct{}) string { | |
if blockSize == 0 { | |
return "" | |
} |
} | ||
|
||
for _, mapping := range mappings { | ||
for block := uint64(0); block < mapping.Length/blockSize; block++ { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐛 Possible Bug
The code assumes mapping.Length
and mapping.Offset
are multiples of blockSize
, which if not true could lead to incorrect block calculations and potential data loss.
for block := uint64(0); block < mapping.Length/blockSize; block++ { | |
if mapping.Length%blockSize != 0 || mapping.Offset%blockSize != 0 { | |
continue | |
} | |
for block := uint64(0); block < mapping.Length/blockSize; block++ { |
There is a bug that sometimes happens during the sandbox pause. This PR fixed it. It will also include tests for the merged mapping.
✨
Description by Callstackai
This PR fixes a bug related to snapshot mapping merging during sandbox pause and includes tests for the merged mapping functionality.
Diagrams of code changes
Files Changed