ReviewOS

zig-utils/zig-js

Error stack: canonicalize stored message and source URL reads

#686
Closed chris opened this 9 days ago ·
9 days ago

Parent: #473

Problem

Error construction canonicalizes a JavaScript message before storing it, and callers may attach a string sourceURL plus startingLineNumber. Error.prototype.stack later materializes its first line and explicit eval location by reading those stored string Values through raw physical asStr bytes. With flat Latin-1 storage enabled, stack text can therefore depend on the StringData representation.

Scope

  • Read an own string message through the representation-aware WTF-8 boundary when materializing the stack first line.
  • Read an own string sourceURL through the same boundary before formatting the explicit eval location.
  • Preserve the non-reentrant own-slot behavior, structured frame capture, stackTraceLimit, setter semantics, and source line numbering.
  • Add one exact-coercion regression covering both message and sourceURL output under canonical and forced-flat storage.

This issue does not touch promises, jobs, queues, workers/threads, or Map/Set iterators.

Acceptance

  • A Latin-1 message round-trips exactly in Error.prototype.stack.
  • A Latin-1 explicit sourceURL round-trips exactly in the formatted eval location.
  • Message coercion occurs exactly once during construction; stack access does not re-coerce it.
  • Focused Debug, ReleaseSafe, and TSan tests pass, including forced-flat storage.
  • Full sharded units report zero failures and zero leaks.
  • The 35-file Test262 Error.prototype.stack subtree is measured before and after with exact flips.
9 days ago

Implemented and pushed in https://github.com/zig-utils/zig-js/commit/63bacccfe16a5b2eda80ac8983988ddd49878176.

Error.prototype.stack now reads an own string message and explicit sourceURL through representation-aware WTF-8 before composing the first line and eval location. The own-slot, non-reentrant behavior and line-number formatting are unchanged.

Validation: focused Debug, forced-flat storage, ReleaseSafe, and TSan 1/1 each; full units 1779 passed, 1 skipped, 0 failed, 0 leaked. Test262 Error.prototype.stack remained 35/35 before to 35/35 after; flips 0.

Sign in to comment on this issue.