Commit graph

2,421 commits

Author SHA1 Message Date
Seonghyun Kim
bab3a57975 Fix RELEASE_ASSERT_NOT_REACHED on CoverInitializedName used as a value
A CoverInitializedName such as `{ a = 0 }` (object shorthand with default) is
only valid when the enclosing object literal is refined into a destructuring
pattern. When such an object literal is instead consumed as a real value -- the
base of a member access, call, computed access, or tagged template, e.g.
`( {... { a = 0 }. b = 1 } )` -- the pending CoverInitializedName error was
discarded by a later assignment, so no SyntaxError was raised and the
AssignmentPattern property value reached bytecode generation, hitting
RELEASE_ASSERT_NOT_REACHED in Node::generateExpressionByteCode.

Report the pending CoverInitializedName as an early SyntaxError in the two
LeftHandSideExpression member-access loops the moment the base is consumed as a
value, since it can no longer be refined into a pattern.

Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-06-18 19:02:02 +09:00
Seonghyun Kim
181019c0c3 Reject object binding pattern rest followed by a binding pattern (Issue #1334)
BindingRestProperty in an object binding pattern only accepts a
BindingIdentifier, unlike BindingRestElement in an array binding pattern
which also accepts a BindingPattern. Throw a SyntaxError when `...` is
followed by `{` or `[` in a declaration context.

Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-06-18 16:09:00 +09:00
Seonghyun Kim
c37e2b4851 A class definition is always strict mode
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-06-18 10:05:18 +09:00
Seonghyun Kim
2dee22f5c7 Update test/vendortest with Issue #1577 regression tests
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-06-17 10:06:57 +09:00
Seonghyun Kim
5e3b91b052 Fix using declaration in a switch case clobbering its disposable record (Issue #1577 Crash #2)
A `using` declaration in a switch case preceded by another statement
aborted with Assertion `isDisposableResourceRecord()' failed / SEGV in
finalizeDisposable.

The switch releases its discriminant register before generating the
case bodies, but pushLexicalBlock had allocated the disposable-record
register on top of it. The early giveUpRegister therefore freed the
disposable register instead, and a statement in the case body (e.g.
`o.k = 1`) reused that register slot, clobbering the record;
Initialize/FinalizeDisposable then dereferenced a non-pointer value.

When the switch block contains a `using` declaration, defer releasing
the discriminant temporaries until after finalizeLexicalBlock has
popped the disposable register (preserving LIFO order). Switches
without `using` are unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-06-17 10:06:57 +09:00
Seonghyun Kim
e7221f4211 Fix labeled continue targeting a for-of loop (Issue #1577 Crash #1)
`L: for (const v of [...]) { continue L; }` aborted with
Assertion `!v.isEmpty()' failed, and `continue OUTER` from a nested
loop silently terminated the script.

A `continue <label>` whose label targets a for-of loop was left to be
resolved by LabelledStatementNode after the loop body, by which point
the for-of iterator-cleanup try block had registered the jump as a
complex case. It was then morphed into a JumpComplexCase that unwound
the try block, wrongly closing the iterator and leaving an empty Value
in the result register.

A previous per-loop attempt (8fd141b2) was reverted (60b1202a) because
a single m_currentLoopLabel leaked into nested loops and broke test262.

Track all labels directly targeting a loop (m_currentLoopLabels), clear
the list when entering each loop body so nested loops never inherit it,
and let for-of/for-in resolve continues for its own labels to
continuePosition (a plain jump, identical to an unlabeled continue)
before the try block is registered as a complex case.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-06-17 10:06:57 +09:00
Seonghyun Kim
b30b63fc63 Fix continue/break at first instruction of env-allocating block (Issue #1571)
A continue/break that is the first instruction inside a lexical block which
allocates an environment (e.g. `for(;c;){ continue; eval(); const x=1; }`) was
emitted as a plain Jump, skipping the block's CloseLexicalEnvironment. The
leaked environment then caused a subsequent outer-scope `const` to initialize
in the wrong environment, producing a spurious
`ReferenceError: Cannot access '...' before initialization`.

registerJumpPositionsToComplexCase compared jump positions against frontlimit
(= lexicalBlockStartPosition, the first body instruction) with strict `>`, so a
jump located exactly at the first body instruction was never morphed into a
JumpComplexCase and the block environment was left un-popped. Use `>=` for
break/continue/labelledBreak/labelledContinue.

With the environment now unwound correctly, the hasBinding guard band-aid in
InterpreterSlowPath::initializeByName is no longer needed and is removed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-06-16 15:35:01 +09:00
Seonghyun Kim
60b1202a72 Fix labeled continue regression in test262 tests
Remove the conditional labeled continue processing from loop statements.
The LabelledStatementNode correctly handles all labeled continues after the
labeled statement completes. Loops should only handle their own regular
(unlabeled) continues.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-06-16 15:35:01 +09:00
Seonghyun Kim
0a2fcaaf5e Add missing m_currentLoopLabel field and fix Crashes #1-2
- Add m_currentLoopLabel to ByteCodeGenerateContext for tracking labeled loop labels (Issue #1571)
- Fix Crash #1: Add bounds checking in inline cache proto traverse with std::min clamping
- Fix Crash #2: Check hasBinding before initializeBinding to prevent assertion on unreachable code paths

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-06-16 15:35:01 +09:00
Seonghyun Kim
09f0a10bba Fix DoWhileStatementNode labeled continue handling (Issue #1571)
Issue #1571: Labeled continue in do-while loops with allocated blocks
- Proper morphing for labeled continues crossing block boundaries
- Fixes environment record consistency in labeled loops
- Completes fix pattern across all loop statement types

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-06-16 15:35:01 +09:00
Seonghyun Kim
7e2b3292fd Fix WhileStatementNode labeled continue handling (Issue #1571)
Issue #1571: Labeled continue in while loops with allocated blocks
- Proper morphing for labeled continues crossing block boundaries
- Fixes environment record consistency in labeled loops
- Applies fix pattern to all loop statement types

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-06-16 15:35:01 +09:00
Seonghyun Kim
8fd141b29c Fix ForInOfStatementNode labeled continue handling (Issues #1571 Crashes #3-4)
Issue #1571 Crash #3: Labeled continue in for-of loop
- Iterator value issue when labeled continue triggered early
- Proper sequencing of iterator cleanup vs control flow

Issue #1571 Crash #4: With statement + labeled for-of
- Environment unwinding coordination with iterator cleanup
- CloseLexicalEnvironment called at correct time

Solution: Consume labeled continues with proper morphing
- Ensures iterator cleanup finalizer runs before unwinding
- Control flow record management stays consistent
- Both for-in and for-of (and for-await-of) properly handled

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-06-16 15:35:01 +09:00
Seonghyun Kim
c80623fc00 Fix ForStatementNode labeled continue handling (Issues #1571 Crashes #3-13)
Issue #1571 Crashes #3-4: Labeled continue in for loops
- Consume labeled continues targeting this loop with proper morphing
- Ensures iterator cleanup and environment unwinding work correctly

Issue #1571 Crashes #5-13: Environment record mismatch in labeled loops
- Proper morphing of labeled continues across allocated block boundaries
- Fixes crashes from scope-creating constructs in labeled loops
- Plain Jump path preserved for non-allocated blocks (zero overhead)

Solution: Call consumeLabelledContinuePositions with morphing enabled
- If no allocated block: plain Jump (fast path)
- If allocated block: JumpComplexCase with proper unwinding (correct path)
- Morphing is automatic via morphJumpPositionIntoComplexCase

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-06-16 15:35:01 +09:00
Seonghyun Kim
92ee65bc0c Update LabelledStatementNode to pass label to child loop
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-06-16 15:35:01 +09:00
Seonghyun Kim
07cdae7850 Update test cases
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-06-16 15:35:01 +09:00
Seonghyun Kim
ef525f337f Add programCount range check for edge case in blockOperation
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-06-15 11:50:30 +09:00
Ádám László Kulcsár
29fdbc741f Improve eval in devtools
Fix accidental deadlock possible inside the debugger and improve formatting when inspecting arrays.

Signed-off-by: Ádám László Kulcsár <adam.kulcsar@szteszoftver.hu>
2026-06-10 10:48:28 +09:00
Máté Tokodi
ebe3761308 Add support for scope variables and call stack in the Devtools Debugger
Signed-off-by: Máté Tokodi <mate.tokodi@szteszoftver.hu>
2026-06-10 10:44:10 +09:00
Ádám László Kulcsár
c423a4bfa0 Implement eval in Devtools debugger
Signed-off-by: Ádám László Kulcsár <adam.kulcsar@szteszoftver.hu>
2026-06-01 23:56:51 +09:00
epsilon
4b40f92aba Fix OOB read in string::rfind 2026-05-27 19:21:59 +09:00
Seonghyun Kim
779f6bedf5 Check stack overflow in ProxyObject::getPrototype, ProxyObject::getPrototypeObject
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-05-27 11:31:45 +09:00
Seonghyun Kim
d581b27af6 Check overflow when TypedArrayObject allocating for 32-bit systems
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-05-27 11:31:45 +09:00
Seonghyun Kim
3b43994a7d Don't assume spread element is fast mode
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-05-27 11:31:45 +09:00
Seonghyun Kim
299a7ff451 Fix crash in ArrayBuffer transfer
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-05-27 11:31:45 +09:00
Seonghyun Kim
36f5fb5836 Add size checking on ArrayBuffer.prototype.transfer
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-05-21 16:15:10 +09:00
Ádám László Kulcsár
d6aae0777f Fix bug with Devtools filenames
Fix bug where filenames could contain memory garbage.

Signed-off-by: Ádám László Kulcsár <adam.kulcsar@szteszoftver.hu>
2026-05-14 19:57:40 +09:00
Seonghyun Kim
590345cc62 Update vendor test
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-05-14 13:33:33 +09:00
Seonghyun Kim
c02c6595be Handle oom explicitly
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-05-14 13:33:33 +09:00
Seonghyun Kim
166fa7c66b Disable GC on c++ catch block w/ASAN
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-05-14 13:33:33 +09:00
Seonghyun Kim
3cf7d60b43 Fix memory error when FinalizationRegistry cleanup callback throws
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-05-14 13:33:33 +09:00
Seonghyun Kim
2bbd27caac Add stack overflow check in ProxyObject::ownPropertyKeys
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-05-14 13:33:33 +09:00
Seonghyun Kim
78e5e333b9 Compute ByteCodeLOC only !NDEBUG && ESCARGOT_DEBUGGER in ByteCodeBlock::pushCode
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-05-14 13:33:33 +09:00
Seonghyun Kim
22bedcec9e In Evaluator::EvaluatorResult::resultOrErrorToString error can be null even if the task was successful
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-05-14 13:33:33 +09:00
Seonghyun Kim
aa727d22a1 Use PointerFree allocatior for FunctionContextVarMap
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-05-14 13:33:33 +09:00
Seonghyun Kim
121d2fefca Fix StringObject::defineOwnProperty
* Check if this is an index property within the string length due to proxy object

Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-05-14 13:33:33 +09:00
Seonghyun Kim
2e9a6393b9 In InterpreterSlowPath::arrayDefineOwnPropertyBySpreadElementOperation,
setArrayLength can convert the array to non-fast mode when length exceeds thresholds

Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-05-14 13:33:33 +09:00
Seonghyun Kim
685a71c3d1 Check if the size exceeds the maximum allowed size for TypedArray construction
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-05-14 13:33:33 +09:00
Seonghyun Kim
78576a5af9 Update vendor test
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-05-14 13:33:33 +09:00
Seonghyun Kim
c8588c323c prevent stack overflow when parsing huge json array
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-05-14 13:33:33 +09:00
Seonghyun Kim
2cc649c97e Use correct index in DataViewObject::setViewValue
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-05-14 13:33:33 +09:00
Seonghyun Kim
98f54274d1 Fix buffer access bug in builtinTypedArrayCopyWithin
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-05-14 13:33:33 +09:00
SAY-5
0a79d6c1f7 Fix out-of-bounds read in lexer comment/hashbang skipping
skipSingleLine, skipSingleLineComment, and skipMultiLineComment incremented
the source index and then called peekCharWithoutEOF() without re-checking
eof(), causing a one-byte heap read past the source buffer when the input
ends with a bare \r or a trailing '*'. Guard each follow-up peek with eof().

Fixes #1568

Signed-off-by: SAY-5 <say.apm35@gmail.com>
2026-05-12 15:57:50 +09:00
Ádám László Kulcsár
634fe864d7 Add -Wno-maybe-uninitialized build option for GCC 16
Signed-off-by: Ádám László Kulcsár <adam.kulcsar@szteszoftver.hu>
2026-05-11 20:40:32 +09:00
Ádám László Kulcsár
475149426f Implement escargot debugger restart support
Implement restart in escargot and python debugger.
Also add debugger test.

Signed-off-by: Ádám László Kulcsár <adam.kulcsar@szteszoftver.hu>
2026-05-07 16:12:31 +09:00
Ádám László Kulcsár
7683468efb Add heap snapshots to devtools debugger
Signed-off-by: Ádám László Kulcsár <adam.kulcsar@szteszoftver.hu>
2026-04-29 09:37:05 +09:00
Máté Tokodi
48eb4b6af9 Add support for breakpoints in the Devtools Debugger
- Add, remove breakpoints
- Resume execution
- Step Into, Step Out, Step Over
- Deactivate/Reactivate all breakpoints

Signed-off-by: Máté Tokodi <mate.tokodi@szteszoftver.hu>
2026-04-28 16:43:39 +09:00
Ádám László Kulcsár
e9833cd791 Rework python debugger tester
Delete debugger_tester.sh script and rewrite it in python. Also add option to run individial tests.

Signed-off-by: Ádám László Kulcsár <adam.kulcsar@szteszoftver.hu>
2026-04-28 16:42:06 +09:00
Ádám László Kulcsár
769e86e32a Add ability to take heap snapshots with python debugger
Signed-off-by: Ádám László Kulcsár <adam.kulcsar@szteszoftver.hu>
2026-04-23 11:35:55 +09:00
Seonghyun Kim
ad3844437e Update ArrayBuffer::isDetachedBuffer check
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-04-23 11:35:23 +09:00
Ádám László Kulcsár
633fe63795 Add funcitonality to take heap snapshots
Signed-off-by: Ádám László Kulcsár <kuladam@inf.u-szeged.hu>
2026-04-16 15:42:23 +09:00