Skip to content

Reject a prebuilt addon whose ABI does not match at load time (#62) - #63

Merged
anxuanng merged 1 commit into
mainfrom
62-addon-abi-check
Nov 17, 2026
Merged

anxuanng merged 1 commit into
mainfrom
62-addon-abi-check

Conversation

@anxuanng

Copy link
Copy Markdown
Contributor

Closes #62

loadNativeAddon() now rejects a prebuilt addon that does not match the package, at load time, instead of letting a trace fail deep in the kernel with "KernelParamsV2 must be 320 bytes, got 336".

  • The addon's addonBuildInfo() also reports kernelParamsBytes, taken from the KERNEL_PARAMS_V2_BYTES constant the kernel checks.
  • compareAddonBuildInfo compares version, pack revision and KernelParamsV2 size with the JS side (PACK_REVISION, STRUCT_STRIDES_V2.kernelParams).
  • An addon without the export (the v0.1.0 and v0.1.1 prebuilts) used to give a one-time warning. It is now an error, because that is exactly the stale case.

How I checked it

  • node --test: 181 pass, 0 fail.
  • Reverted the check (verifyAddonBuildInfo never throws): 5 of the 8 tests in tests/addon-handshake.test.mjs fail (missing export, size mismatch, unreported size, version mismatch, revision mismatch). Restored: all pass.
  • Fake addons in engine.test.mjs and js-surface-validation.test.mjs now export a matching addonBuildInfo (tests/support/fake-addon.mjs).
  • The Rust change is a new field and a pub(crate) constant. cargo check cannot run on this Windows machine (napi-build needs libnode.dll), so the Rust build and tools/check-addon-build-info.mjs run in CI.

Evidence

Before, with a v0.1.1 addon: no error at load, then mid-trace KernelParamsV2 must be 320 bytes, got 336.

After:

The Cook addon at "<path>" does not match this package: the addon does not export addonBuildInfo, so it was built before this package. Run `npx cook fetch-addon` after a release, or rebuild with `npm run build` (node build.mjs).

An addon with another size: the addon reads KernelParamsV2 blocks of 320 bytes and the package writes 336 bytes.

addonBuildInfo() now also reports the KernelParamsV2 size the kernel reads.
loadNativeAddon() throws when the addon lacks the export (v0.1.0 and v0.1.1
prebuilts), or when its version, pack revision or KernelParamsV2 size differs
from the package, instead of warning and failing deep inside a trace.
@anxuanng
anxuanng merged commit 964c98f into main Nov 17, 2026
4 of 5 checks passed
@anxuanng
anxuanng deleted the 62-addon-abi-check branch November 17, 2026 00:32
@anxuanng anxuanng mentioned this pull request Nov 17, 2026
anxuanng added a commit to codepawl/crucible that referenced this pull request Nov 17, 2026
55f2448d is the v0.2.0 tag commit. It contains 9fd3f722 (the session
geometry update this PR needs) and codepawl/cook#63, which rejects a
stale prebuilt addon at load time.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reject a prebuilt addon whose pack revision or KernelParamsV2 size does not match the JS at load time

1 participant