Skip to content

feat(engine): stop running code through an interrupt flag - #5650

Open
bastienfaivre wants to merge 1 commit into
boa-dev:mainfrom
bastienfaivre:proposal/context-interrupt-flag
Open

bastienfaivre wants to merge 1 commit into
boa-dev:mainfrom
bastienfaivre:proposal/context-interrupt-flag

Conversation

@bastienfaivre

Copy link
Copy Markdown

This Pull Request closes #3442.

It changes the following:

  • Adds Context::set_interrupt_flag(Option<Arc<AtomicBool>>). While the flag is set, the next loop iteration or function call fails with the new EngineError::Interrupted, which scripts can't catch. The flag can be set from another thread.
  • Checks the flag next to the existing runtime limit checks (IncrementLoopIteration, check_runtime_limits).
  • Adds tests for loops, calls, try/catch, native functions that call back into JS, resetting or removing the flag, and setting it from another thread.

Discussion

  • The runtime limits can't stop these scripts: the loop count is kept per call frame, so a loop that calls a looping function, or recursion without loops, never reaches it.
  • A native function that doesn't call back into JS, such as a regex match (RegExp execution lacks backtracking limit, allowing ReDoS #4643), runs to completion.
  • Cost: one branch on an Option per check, plus a relaxed atomic load when a flag is set. Not benchmarked.
  • EngineError isn't #[non_exhaustive], so the new variant is a breaking change.

@bastienfaivre
bastienfaivre requested a review from a team as a code owner November 10, 2026 08:42
@github-actions github-actions Bot added the Waiting On Review Waiting on reviews from the maintainers label Nov 10, 2026
@github-actions github-actions Bot added this to the v0.23 milestone Nov 10, 2026
@github-actions github-actions Bot added C-Tests Issues and PRs related to the tests. C-FFI Foreign Function Interface, to be able to use Boa from a different language, such as C C-VM Issues and PRs related to the Boa Virtual Machine. labels Nov 10, 2026
@github-actions

Copy link
Copy Markdown

Test262 conformance changes

Test result main count PR count difference
Total 53,578 53,578 0
Passed 51,450 51,450 0
Ignored 1,648 1,648 0
Failed 480 480 0
Panics 0 0 0
Conformance 96.03% 96.03% 0.00%

Tested main commit: bfaa15a7d60d8c92370a423d4134ab19b1b1fae0
Tested PR commit: af87ffb5715146c3f1081f75e97f53e4725b16e5
Compare commits: bfaa15a...af87ffb

@codecov

codecov Bot commented Nov 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 63.15%. Comparing base (6ddc2b4) to head (af87ffb).
⚠️ Report is 1086 commits behind head on main.

Files with missing lines Patch % Lines
core/engine/src/vm/mod.rs 85.71% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #5650       +/-   ##
===========================================
+ Coverage   47.24%   63.15%   +15.91%     
===========================================
  Files         476      538       +62     
  Lines       46892    60620    +13728     
===========================================
+ Hits        22154    38285    +16131     
+ Misses      24738    22335     -2403     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-FFI Foreign Function Interface, to be able to use Boa from a different language, such as C C-Tests Issues and PRs related to the tests. C-VM Issues and PRs related to the Boa Virtual Machine. Waiting On Review Waiting on reviews from the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cancel/Interrupt active evaluation

1 participant