fix(build): verify Math constants in runtime snapshot - #726
Open
da1suk8 wants to merge 1 commit into
Open
Conversation
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
Follow-up to #723 — this prevents recurrence; it does not by itself fix the already-published amd64 images. V8 computes
Math.E,Math.LN10,Math.LN2,Math.LOG10E, andMath.LOG2Eat snapshot-creation time, andcrates/base/build.rsfreezes those values into the startup snapshot that every worker boots from — so a build environment that corrupts the computation ships wrong constants to every user, and nothing in the pipeline could catch it. That is exactly what happened with the linux/amd64 v1.74.2/v1.74.3 images.This PR passes a warmup script to
create_snapshot(its second parameter — deno_core's built-in path that boots a snapshotting-mode runtime from the freshly created snapshot, runs the script, and re-serializes). The script compares all eightMathconstants bit-for-bit against their IEEE-754 representations and throws on any mismatch, which failscreate_snapshot— and the build — before the snapshot is ever written to disk. A corrupted snapshot can no longer reach a cache or a release silently; the failure mode becomes a loud build error:Notes on the approach:
JsRuntimeaftercreate_snapshot) keeps the whole process in V8's snapshotting mode, respecting deno_core's one-initialization-mode-per-process contract, and lets deno_core derive the ops-only extension set itself (Extension::for_warmup) — no duplicated extension list.build.rs, which forces one fresh snapshot build on the release lane, flushing any currently cached artifact.Limitations
Mathconstants, not a checksum of the whole blob — it detects the observed corruption class, not arbitrary snapshot damage.Validation
cargo check -p base/ full build: the verification runs on every build and passes.WARNING: v8::OwnedIsolate for snapshot was leakedon the error path.)EdgeRuntime.userWorkersserves requests normally, with no errors logged.