Samsung/escargot

Assertion `m_optionalChainingJumpPositionLists.size()' failed in Escargot::ByteCodeGenerateContext::addOptionalChainingJumpPosition

Ye0nny opened this issue · 1 comments

Escargot

  • OS: Ubuntu 20.04.5 LTS (Linux 5.4.0-144-generic x86_64)
  • Revision : bd95de3

Build Steps

cmake -DESCARGOT_MODE=debug -DESCARGOT_OUTPUT=shell -GNinja

Describe the bug
Assertion failure

Test case

testcase

var a = / a / ; 
a. a?. a [ Symbol. Symbol ] = 0.1 ; 
for ( var r in a ) r : { }

// poc.js
a?. a [ Symbol ] = 0.1 ;

Execution steps & Output

$ ./escargot poc.js
escargot: src/interpreter/ByteCodeGenerator.h:161: void Escargot::ByteCodeGenerateContext::addOptionalChainingJumpPosition(size_t): Assertion `m_optionalChainingJumpPositionLists.size()' failed.
Aborted

Backtrace

(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff7a70859 in __GI_abort () at abort.c:79
#2  0x00007ffff7a70729 in __assert_fail_base (fmt=0x7ffff7c06588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x555555b1b6b0 "m_optionalChainingJumpPositionLists.size()", file=0x555555b1b5f0 "src/interpreter/ByteCodeGenerator.h", line=161, function=<optimized out>) at assert.c:92
#3  0x00007ffff7a81fd6 in __GI___assert_fail (assertion=0x555555b1b6b0 "m_optionalChainingJumpPositionLists.size()", file=0x555555b1b5f0 "src/interpreter/ByteCodeGenerator.h", line=161, function=0x555555b1b660 "void Escargot::ByteCodeGenerateContext::addOptionalChainingJumpPosition(size_t)") at assert.c:101
#4  0x00005555557e96c2 in Escargot::ByteCodeGenerateContext::addOptionalChainingJumpPosition (this=0x7fffffffdb30, pos=48) at src/interpreter/ByteCodeGenerator.h:161
#5  0x00005555557f1b9a in Escargot::MemberExpressionNode::generateExpressionByteCode (this=0x555555d12ae8, codeBlock=0xc1f50, context=0x7fffffffdb30, dstIndex=1) at src/parser/ast/MemberExpressionNode.h:121
#6  0x00005555557f2d4e in Escargot::MemberExpressionNode::generateResolveAddressByteCode (this=0x555555d12b28, codeBlock=0xc1f50, context=0x7fffffffdb30) at src/parser/ast/MemberExpressionNode.h:243
#7  0x00005555557f837b in Escargot::AssignmentExpressionSimpleNode::generateExpressionByteCode (this=0x555555d12b68, codeBlock=0xc1f50, context=0x7fffffffdb30, dstRegister=0) at src/parser/ast/AssignmentExpressionSimpleNode.h:66
#8  0x00005555558051be in Escargot::ExpressionStatementNode::generateStatementByteCode (this=0x555555d12b88, codeBlock=0xc1f50, context=0x7fffffffdb30) at src/parser/ast/ExpressionStatementNode.h:53
#9  0x00005555557edef8 in Escargot::StatementContainer::generateStatementByteCode (this=0x555555d12ab0, codeBlock=0xc1f50, context=0x7fffffffdb30) at src/parser/ast/StatementNode.h:107
#10 0x000055555580e65d in Escargot::ProgramNode::generateStatementByteCode (this=0x555555d12ba8, codeBlock=0xc1f50, context=0x7fffffffdb30) at src/parser/ast/ProgramNode.h:48
#11 0x000055555570525c in Escargot::ByteCodeGenerator::generateByteCode (context=0xa3af0, codeBlock=0xbde30, ast=0x555555d12ba8, inWithFromRuntime=false, cacheByteCode=false) at src/interpreter/ByteCodeGenerator.cpp:272
#12 0x00005555557e5f8c in Escargot::ScriptParser::initializeScript (this=0x59f70, originSource=0x0, originLineOffset=0, source=0xabf70, srcName=0x7a390, parentCodeBlock=0x0, isModule=false, isEvalMode=false, isEvalCodeInFunction=false, inWithOperation=false, strictFromOutside=false, allowSuperCall=false,
    allowSuperProperty=false, allowNewTarget=false, needByteCodeGeneration=true) at src/parser/ScriptParser.cpp:455
#13 0x000055555563bec4 in Escargot::ScriptParser::initializeScript (this=0x59f70, source=0xabf70, srcName=0x7a390, isModule=false) at src/parser/ScriptParser.h:57
#14 0x000055555564333d in Escargot::ScriptParserRef::initializeScript (this=0x59f70, source=0xabf70, srcName=0x7a390, isModule=false) at src/api/EscargotPublic.cpp:4626
#15 0x00005555559a3d07 in evalScript (context=0xa3af0, source=0xabf70, srcName=0x7a390, shouldPrintScriptResult=false, isModule=false) at src/shell/Shell.cpp:751
#16 0x00005555559a52bd in main (argc=2, argv=0x7fffffffe358) at src/shell/Shell.cpp:1130

when executed in release mode

Output

Segmentation fault

Expected behavior

SyntaxError: Invalid left-hand side in assignment

Credits: @Ye0nny, @EJueon

Fixed by #1328 Thanks for your reporting!