Samsung/escargot

`RELEASE_ASSERT at src/interpreter/ByteCodeGenerator.h (233)`

langston-barrett opened this issue · 2 comments

Escargot (please complete the following information):

  • OS: Ubuntu Docker container
  • rev: e0fbe20

Describe the bug
Assertion failure.

Test case

From the ChakraCore test suite:

//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------

let limit = (1 << 16) - 4;
function test0() {
    return arguments[limit - 1];
}
while (true) {
    try {
        const txt = `test0(${Array(limit).fill(0).map((_, i) => i).join(",")})`;
        var val1 = eval(txt);
        console.log(`arguments[${limit - 1}] == ${val1}`);
        break;
    } catch (e) {
        console.log(e)
        console.log(`${limit} is too many arguments`);
        limit--;
    }
}
console.log(`Arguments limit: ${limit}`);

Backtrace

#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=140211524425536)
    at ./nptl/pthread_kill.c:44
#1  __pthread_kill_internal (signo=6, threadid=140211524425536) at ./nptl/pthread_kill.c:78
#2  __GI___pthread_kill (threadid=140211524425536, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3  0x00007f858a1fc476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4  0x00007f858a1e27f3 in __GI_abort () at ./stdlib/abort.c:79
#5  0x000055f1a1171d51 in Escargot::ByteCodeGenerateContext::getRegister (this=<optimized out>)
    at src/interpreter/ByteCodeGenerator.h:233
#6  Escargot::CallExpressionNode::generateArguments (this=this@entry=0x7f8589f3c158,
    codeBlock=codeBlock@entry=0x7adc0, context=context@entry=0x7ffc35b8a3b0,
    clearInCallingExpressionScope=clearInCallingExpressionScope@entry=true)
    at src/parser/ast/CallExpressionNode.h:96
#7  0x000055f1a119be8c in Escargot::CallExpressionNode::generateExpressionByteCode (
    this=<optimized out>, codeBlock=0x7adc0, context=0x7ffc35b8a3b0, dstRegister=<optimized out>)
    at src/parser/ast/CallExpressionNode.h:258
#8  0x000055f1a1171691 in Escargot::ExpressionStatementNode::generateStatementByteCode (
    context=0x7ffc35b8a3b0, codeBlock=0x7adc0, this=<optimized out>)
    at /usr/include/c++/10/bits/stl_iterator.h:978
#9  Escargot::ExpressionStatementNode::generateStatementByteCode (this=<optimized out>,
    codeBlock=0x7adc0, context=0x7ffc35b8a3b0) at src/parser/ast/ExpressionStatementNode.h:38
#10 0x000055f1a117e84f in Escargot::StatementContainer::generateStatementByteCode (
    context=0x7ffc35b8a3b0, codeBlock=0x7adc0, this=<optimized out>)
    at src/parser/ast/StatementNode.h:107
#11 Escargot::ProgramNode::generateStatementByteCode (this=0x7f8589f3c1b0, codeBlock=0x7adc0,
    context=0x7ffc35b8a3b0) at src/parser/ast/ProgramNode.h:51
#12 0x000055f1a10fa2a2 in Escargot::ByteCodeGenerator::generateByteCode (context=<optimized out>,
    codeBlock=codeBlock@entry=0x79c30, ast=ast@entry=0x7f8589f3c1b0,
    inWithFromRuntime=inWithFromRuntime@entry=false, cacheByteCode=cacheByteCode@entry=false)
    at src/interpreter/ByteCodeGenerator.cpp:221
#13 0x000055f1a1163b1b in Escargot::ScriptParser::initializeScript (this=this@entry=0x7ffc35b8a6b8,
    originSource=originSource@entry=0x0, originLineOffset=originLineOffset@entry=0,
    source=<optimized out>, srcName=0x81e00, parentCodeBlock=0x79ea0, isModule=false, isEvalMode=true,
    isEvalCodeInFunction=false, inWithOperation=false, strictFromOutside=false, allowSuperCall=false,
    allowSuperProperty=false, allowNewTarget=false, needByteCodeGeneration=true,
    stackSizeRemain=3143928) at src/parser/ScriptParser.cpp:495
#14 0x000055f1a1214b7d in Escargot::GlobalObject::evalLocal (this=<optimized out>, state=..., arg=...,
    thisValue=..., parentCodeBlock=0x79ea0, inWithOperation=<optimized out>)
    at src/runtime/GlobalObject.cpp:232
#15 0x000055f1a1106a6c in Escargot::ByteCodeInterpreter::callFunctionComplexCase (state=...,
    code=0x55f1a3343358, registerFile=0x7ffc35b8ab90, byteCodeBlock=0x7af00)
    at src/interpreter/ByteCodeInterpreter.cpp:3502
#16 0x000055f1a110bb5f in Escargot::ByteCodeInterpreter::interpret (state=0x7ffc35b8a8d0,
    byteCodeBlock=0x7af00, programCounter=94496313586520, registerFile=0x7ffc35b8ab90)
    at src/interpreter/ByteCodeInterpreter.cpp:1271
#17 0x000055f1a110f63d in Escargot::ByteCodeInterpreter::blockOperation (
    state=@0x7ffc35b8a9c8: 0x7ffc35b8aa30, code=0x55f1a3343190, programCounter=<optimized out>,
    byteCodeBlock=<optimized out>, registerFile=0x7ffc35b8ab90)
    at src/interpreter/ByteCodeInterpreter.cpp:3299
#18 0x000055f1a110b827 in Escargot::ByteCodeInterpreter::interpret (state=0x7ffc35b8aa30,
    byteCodeBlock=0x7af00, programCounter=94496313586064, registerFile=0x7ffc35b8ab90)
    at src/interpreter/ByteCodeInterpreter.cpp:1343
#19 0x000055f1a110e3b5 in Escargot::ByteCodeInterpreter::tryOperation (
    state=@0x7ffc35b8ab28: 0x7ffc35b8ac10, programCounter=@0x7ffc35b8ab20: 94496313586024,
    byteCodeBlock=0x7af00, registerFile=0x7ffc35b8ab90) at src/interpreter/ByteCodeInterpreter.cpp:2772
#20 0x000055f1a110bf95 in Escargot::ByteCodeInterpreter::interpret (state=0x7ffc35b8ac10,
    byteCodeBlock=0x7af00, programCounter=94496313586024, registerFile=0x7ffc35b8ab90)
    at src/interpreter/ByteCodeInterpreter.cpp:1101
#21 0x000055f1a1162704 in Escargot::Script::execute (this=0x78fc0, state=...,
    isExecuteOnEvalFunction=isExecuteOnEvalFunction@entry=false, inStrictMode=inStrictMode@entry=false)
    at src/parser/Script.cpp:494
#22 0x000055f1a1078342 in Escargot::ScriptRef::execute (this=<optimized out>, state=<optimized out>)
    at src/api/EscargotPublic.cpp:4418
#23 0x000055f1a1076f91 in operator() (__closure=0x0, data=<optimized out>, state=...)
    at src/api/EscargotPublic.cpp:1078
#24 _FUN () at src/api/EscargotPublic.cpp:1079
#25 0x000055f1a124e473 in Escargot::SandBox::run (this=this@entry=0x7ffc35b8ae70,
    scriptRunner=scriptRunner@entry=0x55f1a1076f80 <_FUN(Escargot::ExecutionState&, void*)>,
    data=data@entry=0x7ffc35b8ae20) at src/runtime/SandBox.cpp:110
#26 0x000055f1a10786c1 in Escargot::Evaluator::executeFunction (ctx=ctx@entry=0x73a80,
    runner=runner@entry=0x55f1a127f760 <Escargot::Evaluator::executeImpl<Escargot::ScriptRef*>(Escargot::ContextRef*, Escargot::ValueRef* (*)(Escargot::ExecutionStateRef*, Escargot::ScriptRef*), Escargot::ScriptRef*)::{lambda(Escargot::ExecutionStateRef*, void*, void*)#1}::_FUN(Escargot::ExecutionStateRef*, void*, void*)>, data=data@entry=0x7ffc35b8af50,
    data2=data2@entry=0x55f1a127f8f0 <_FUN(Escargot::ExecutionStateRef*, Escargot::ScriptRef*)>)
    at src/api/EscargotPublic.cpp:1075
#27 0x000055f1a127ff81 in Escargot::Evaluator::executeImpl<Escargot::ScriptRef*> (
    fn=0x55f1a127f8f0 <_FUN(Escargot::ExecutionStateRef*, Escargot::ScriptRef*)>, ctx=0x73a80)
    at src/api/EscargotPublic.h:597
#28 Escargot::Evaluator::execute<Escargot::ScriptRef*, evalScript(Escargot::ContextRef*, Escargot::StringRef*, Escargot::StringRef*, bool, bool)::<lambda(Escargot::ExecutionStateRef*, Escargot::ScriptRef*)> > (closure=..., ctx=0x73a80) at src/api/EscargotPublic.h:584
#29 evalScript (context=0x73a80, source=0x7ef60, srcName=<optimized out>,
    shouldPrintScriptResult=false, isModule=<optimized out>) at src/shell/Shell.cpp:738
#30 0x000055f1a107592f in main (argc=2, argv=0x7ffc35b8b198) at src/api/EscargotPublic.h:240

Additional context

Let me know if you would like me to post more assertion failures and similar problems!

@langston-barrett Thanks for reporting this!
But sadly, this assertion is an intended failure. Escargot engine is designed as an lightweight JS engine, so it's memory consumption is strictly limited. Regarding this, we only allow a few number of parameters for each function to allocate acceptable memory space for parameters. So, this policy is the reason of the failure.

BTW do you really need to run this test?

@clover2123 Thanks for the clarification!

BTW do you really need to run this test?

Nope, I am stress testing a few JS engines.