Skip to content

fix(runtime): preserve negative integers in messages - #92

Merged
mremond merged 1 commit into
mainfrom
infinitary-batch/7279ca66
Nov 25, 2026
Merged

mremond merged 1 commit into
mainfrom
infinitary-batch/7279ca66

Conversation

@mremond

@mremond mremond commented Nov 25, 2026

Copy link
Copy Markdown
Member

Why

Native programs could receive a large positive number when they sent a negative one.

What changed

  • Native messages preserve negative integers, whether a process sends to itself or another process.
  • Unused table data is freed sooner as it builds up, without repeatedly cleaning up for one unchanged value.

Before and after

Before: Six of eight native sends disagreed with standard Erlang: one sent `{-3}` but delivered `{1152921504606846973}`.

After: All eight sends delivered the same values as standard Erlang, including `{-3}` and a spawned process’s `-7`.

The change affects what programs receive, not what appears on screen.

Checked

Live validation: Demonstrated for this version. 2 of 2 scenarios driven live in the product.

Scenario Result Evidence
Send negative integers ✅ Passed live Native Nera matched standard Erlang on all eight outputs, with both the default scheduler count and one scheduler.
Free unused table data safely ✅ Passed live Eight reads of one 2 MiB entry did not trigger repeat cleanup. Adding another snapshot triggered cleanup without losing live data.
  • Shared regression: The original native version failed. The fix passed 10 of 10 runs on standard Erlang and on each native configuration.
  • Review: protect live table data: Collection keeps table data and binary contents while a process still uses them. This preserves existing behavior.
  • Review: test the optimized send: A spawned sender now exercises the optimized route without changing what the test expects.
  • Review: document ownership and test hibernation: The design notes describe current behavior, and the hibernation test detects lost table storage before reading it.
  • Review note: duplicate checks: Kept the duplicate checks because removing them was optional and unrelated to the fix.
  • Full Linux gate: The build and lint passed; 2,263 Rust tests and 548 end-to-end tests passed.
How it was checked

Compared exact stdout with BEAM OTP 27 on Linux x86-64, using default Nera schedulers and NERA_SCHEDULERS=1.

Ran cargo build --release --locked and cargo clippy --workspace --all-targets --locked -- -D warnings, plus allocator and stacktrace-order regressions.

Ran cargo test --workspace --locked --no-fail-fast under umask 0022 and all three native end-to-end shards. One Rust test was ignored; two native tests require external modules.

Seven targeted Rust regressions rejected broken behavior and passed ten consecutive runs on the fix.

Risk

Risk above low: Blast radius, high — The shared native runtime copies messages and collects memory for every process.; Behavior, high — Accumulating retained table data can trigger a full collection sooner by default.; Novelty, medium — New snapshot accounting sits beside the existing generational collector.

Full risk assessment
Dimension Level Why
Blast radius high The shared native runtime copies messages and collects memory for every process.
Behavior high Accumulating retained table data can trigger a full collection sooner by default.
Undo low Revert the change; there are no stored format changes or migrations.
Evidence low Exact native results matched standard Erlang, and the full Linux gate passed.
Sensitivity low No credentials, configuration, or persistent user data are involved.
Novelty medium New snapshot accounting sits beside the existing generational collector.
Dependencies low No dependencies changed.
Not done

The batch still needs to run the selected macOS integration and cross-target checks.

Native messages preserve negative integers, whether a process sends to itself or another process.

Unused table data is freed sooner as it builds up, without repeatedly cleaning up for one unchanged value.
@mremond
mremond merged commit fb21d04 into main Nov 25, 2026
2 checks passed
@mremond
mremond deleted the infinitary-batch/7279ca66 branch November 25, 2026 10:14
@github-actions github-actions Bot added this to the 0.1.1 milestone Nov 25, 2026
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.

1 participant