fix(shorebird): let the createForSnapshots tests supply region lengths - #170
Open
nickshorebird wants to merge 1 commit into
Open
nickshorebird wants to merge 1 commit into
nickshorebird wants to merge 1 commit into
Conversation
The three CreateForSnapshots tests have crashed since they were added. createForSnapshots asks the VM for each region's length, and the tests hand it 4 byte strings, so the parser reads a header out of arbitrary bytes and dereferences it. Production cannot use the mapping's own size instead, because an AOT snapshot's regions arrive as fml::SymbolMapping, whose GetSize() is 0 for a dlsym'd symbol address that carries no extent. Only the snapshot header knows. So the lookup becomes a parameter, defaulted to the Dart API, and the tests pass their own. Production keeps calling Dart_SnapshotDataSize and Dart_SnapshotInstrSize through the default overload, which is what the single caller uses.
easymac
approved these changes
Sep 21, 2026
| // Production has to ask the Dart VM. An AOT snapshot's regions arrive as | ||
| // fml::SymbolMapping, whose GetSize() is 0 because a dlsym'd symbol address | ||
| // carries no extent. Only the snapshot header knows where the region ends. | ||
| using RegionSizer = std::function<size_t(const uint8_t* region)>; |
There was a problem hiding this comment.
Consider passing the size directly here; I think it may be simpler for callers to use something like createForSnapshots(*snapshot, data.size(), instructions.size())
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
The three CreateForSnapshots tests have crashed since they were added, so the blob ordering they guard has never been checked. They hand
createForSnapshots4 byte strings, and it asks the VM to parse a snapshot header out of them. Production cannot use the mapping's own size instead, because AOT regions arrive asfml::SymbolMapping, whoseGetSize()is 0 for a dlsym'd address that carries no extent. So the length lookup became a parameter, defaulted to the Dart API, rather than production getting weaker to suit a test.Testing
shorebird_unittests41 of 41, the three crashing cases passing by name. This suite has no CI lane, so I built and ran it by hand against arm64 debug unopt.