Skip to content

Robustness gaps found while probing #248: limits, bjson, dumpMemoryUsage, callFunction argc, and more #275

Open

Description

@jackkav

Stack: #248 → #276 → #277 → (#278 | #279 → #280 → #281 → #282). Each PR body has a link to review just its own diff.

Found while stress-testing #248. All items reproduce identically with and without #248 (published 0.32.0 wasm, local quickjs-emscripten-core). Several are C-side and I could not build wasm locally, so those fixes are proposals. TS-only items are addressed in the linked PR.

Addressed in #278 (stacked on #277, #276 and #248):

  • setMemoryLimit / setMaxStackSize silently wrap NaN, Infinity and values >= 2^32 in the 32-bit size_t (a wrapped value can make every allocation fail or remove the limit). Now RangeError. The max stack size error message said "memory limit".
  • Pointer arrays are Int32Array (see the old TODO): heap addresses >= 2 GiB would read as negative. Unreachable with the current 2 GiB cap, but now unsigned.
  • getWasmMemory().grow() called by users bricks the module (HEAPU8 is not refreshed). Documented.

Addressed in #279 (C, stacked on #277): dumpMemoryUsage truncation and the callFunction huge-argc crash (the two bullets below marked fixed in #279).

Addressed in #280 (C + TS, stacked on #279): NULL JSContext from newContext, NULL from jsvalue_to_heap, and the unchecked/oversized malloc in QTS_GetOwnPropertyNames.

Addressed in #281 (C, stacked on #280): bjson decode now accepts object references.

Not addressed (need C/build changes or a design decision):

Repro scripts for all of these are available; happy to share or turn any into tests.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions