Skip to content

Let the deadline cover reading the result - #10

Merged
noha merged 1 commit into
mainfrom
deadline-covers-conversion
Oct 29, 2026
Merged

noha merged 1 commit into
mainfrom
deadline-covers-conversion

Conversation

@noha

@noha noha commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

The deadline ended with the evaluation, but Pharo reads the result afterwards and reading runs JS too: a getter on the result, a script that replaced Object.keys, or a looping toString on a thrown error ran without any deadline and held the VM for good. Reading plain data runs no JS at all, so a cyclic object or a few hundred bytes of shared arrays (a = [a, a], forty times) kept Pharo busy without end as well.

  • The deadline outlives the evaluation until the next one sets a new one, so JS run while reading stops once it has passed.
  • qjs_object_keys takes the keys through JS_GetOwnPropertyNames instead of the global Object.keys.
  • qjs_array_length answers -1 with the exception pending instead of 0.
  • qjs_runtime_deadline_passed lets Pharo ask in between; QJSContext checks it for every element it reads and refuses values nested deeper than 1000 levels.
  • QJSSandboxTest pins down what a script can reach: the globals against a fixed list, no std, os, print or require, no import, no blocking Atomics.wait, recursion ends at the stack limit.

The deadline ended with the evaluation, but Pharo reads the result
afterwards and reading runs JS too: a getter on the result, a script that
replaced Object.keys, or a looping toString on a thrown error ran without
any deadline and held the VM for good. Reading plain data runs no JS at
all, so a cyclic object or a few hundred bytes of shared arrays
(a = [a, a], forty times) kept Pharo busy without end as well.

- The deadline outlives the evaluation until the next one sets a new one,
  so JS run while reading stops once it has passed.
- qjs_object_keys takes the keys through JS_GetOwnPropertyNames instead
  of the global Object.keys.
- qjs_array_length answers -1 with the exception pending instead of 0.
- qjs_runtime_deadline_passed lets Pharo ask in between; QJSContext checks
  it for every element it reads and refuses values nested deeper than
  1000 levels.
- QJSSandboxTest pins down what a script can reach: the globals against a
  fixed list, no std, os, print or require, no import, no blocking
  Atomics.wait, recursion ends at the stack limit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@noha
noha merged commit 759cd59 into main Oct 29, 2026
4 checks passed
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