chakra-core / ChakraCore

ChakraCore is an open source Javascript engine with a C API.
MIT License
9.13k stars 1.2k forks source link

Assertion Failure: Inconsistency in Helper label annotations in ChakraCore/lib/Backend/DbCheckPostLower.cpp, line 81 #6907

Open JimWongM opened 1 year ago

JimWongM commented 1 year ago

Version

commit id: c3ead3f8a6e0bb8e32e043adc091c68cba5935e9

Platform

Ubuntu 20.04.5 LTS (Linux 5.4.0-144-generic x86_64)

Build

./build.sh --debug --static

PoC

function opt(arg) {
    do {} while (arg !== arg);
}
for (let i = 0; i < 100; i++) {
    opt();
}

Execution steps & Output

./ch --maxinterpretcount:10 --maxsimplejitruncount:100 -bgjit- poc.js
ASSERTION 388027: (/home/wjm/ChakraCore/lib/Backend/DbCheckPostLower.cpp, line 81) Inconsistency in Helper label annotations
 Failure: (prevInstr && prevInstr->IsLabelInstr() && !prevInstr->AsLabelInstr()->isOpHelper)
Signal: SIGILL (Illegal instruction)

Backtrace

(lldb) bt
* thread #1, name = 'ch', stop reason = signal SIGILL: illegal instruction operand
  * frame #0: 0x0000555556d657ad ch`DbCheckPostLower::Check(this=0x00007fffffff7200) at DbCheckPostLower.cpp:81:25
    frame #1: 0x0000555556b2976d ch`Func::EndPhase(this=0x00007fffffff8370, tag=LowererPhase, dump=true) at Func.cpp:1364:17
    frame #2: 0x000055555686e827 ch`AutoCodeGenPhase::~AutoCodeGenPhase(this=0x00007fffffff7b70) at Func.h:1143:19
    frame #3: 0x0000555556b263a3 ch`Func::TryCodegen(this=0x00007fffffff8370) at Func.cpp:476:9
    frame #4: 0x0000555556b25ae0 ch`Func::Codegen(alloc=0x00007fffffff8930, workItem=0x00007ff7e7bf4030, threadContextInfo=0x0000555557eb6fc8, scriptContextInfo=0x0000555557ee8f48, outputData=0x00007fffffff8d70, epInfo=0x00007ff7e7c64180, runtimeInfo=0x0000000000000000, polymorphicInlineCacheInfo=0x00007ff7e7c3f3a0, codeGenAllocators=0x0000555557ef58a8, codeGenProfiler=0x0000000000000000, isBackgroundJIT=false) at Func.cpp:325:18
    frame #5: 0x000055555690ef90 ch`NativeCodeGenerator::CodeGen(this=0x0000555557eea718, pageAllocator=0x0000555557eb7350, workItemData=0x0000555557efdbf0, jitWriteData=0x00007fffffff8d70, foreground=true, epInfo=0x00007ff7e7c64180) at NativeCodeGenerator.cpp:890:9
    frame #6: 0x0000555556910c28 ch`NativeCodeGenerator::CodeGen(this=0x0000555557eea718, pageAllocator=0x0000555557eb7350, workItem=0x0000555557efdbc8, foreground=true) at NativeCodeGenerator.cpp:1007:5
    frame #7: 0x00005555569139a7 ch`NativeCodeGenerator::Process(this=0x0000555557eea718, job=0x0000555557efdbd0, threadData=0x0000000000000000) at NativeCodeGenerator.cpp:1895:13
    frame #8: 0x00005555569b83d4 ch`JsUtil::ForegroundJobProcessor::Process(job=0x0000555557efdbd0) at Jobs.cpp:426:36
    frame #9: 0x0000555556922bc3 ch`void JsUtil::ForegroundJobProcessor::PrioritizeJobAndWait<NativeCodeGenerator, Js::EntryPointInfo*>(this=0x0000555557ea2ce8, manager=0x0000555557eea718, holder=0x00007ff7e7c64180, function=0x0000000000000000) at Jobs.inl:207:36
    frame #10: 0x0000555556918804 ch`void JsUtil::JobProcessor::PrioritizeJobAndWait<NativeCodeGenerator, Js::EntryPointInfo*>(this=0x0000555557ea2ce8, manager=0x0000555557eea718, holder=0x00007ff7e7c64180, function=0x0000000000000000) at Jobs.inl:81:58
    frame #11: 0x000055555690d4fc ch`NativeCodeGenerator::GenerateLoopBody(this=0x0000555557eea718, fn=0x00007ff7e7c471f0, loopHeader=0x00007ff7e7c71db0, entryPoint=0x00007ff7e7c64180, localCount=3, localSlots=0x00007fffffffa5b0) at NativeCodeGenerator.cpp:711:22
    frame #12: 0x00005555568157dd ch`GenerateLoopBody(nativeCodeGen=0x0000555557eea718, fn=0x00007ff7e7c471f0, loopHeader=0x00007ff7e7c71db0, info=0x00007ff7e7c64180, localCount=3, localSlots=0x00007fffffffa5b0) at BackendApi.cpp:88:20
    frame #13: 0x0000555555fb220b ch`Js::InterpreterStackFrame::DoLoopBodyStart(this=0x00007fffffffa450, loopNumber=0, layoutSize=SmallLayout, doProfileLoopCheck=false, isFirstIteration=false) at InterpreterStackFrame.cpp:6277:17
    frame #14: 0x0000555555fb57ee ch`void Js::InterpreterStackFrame::ProfiledLoopBodyStart<false, true>(this=0x00007fffffffa450, loopNumber=0, layoutSize=SmallLayout, isFirstIteration=false) at InterpreterStackFrame.cpp:5930:41
    frame #15: 0x0000555555ff8a0a ch`unsigned char const* Js::InterpreterStackFrame::OP_ProfiledLoopBodyStart<(Js::LayoutSize)0, true>(this=0x00007fffffffa450, loopId=0) at InterpreterStackFrame.cpp:5902:9
    frame #16: 0x0000555555fc6a96 ch`unsigned char const* Js::InterpreterStackFrame::OP_ProfiledLoopBodyStart<(Js::LayoutSize)0, true>(this=0x00007fffffffa450, ip="\U00000015\xf9\xff\U00000002\U00000002\t") at InterpreterStackFrame.cpp:5774:16
    frame #17: 0x0000555555eaae91 ch`Js::InterpreterStackFrame::ProcessProfiled(this=0x00007fffffffa450) at InterpreterHandler.inl:52:3
    frame #18: 0x0000555555e52112 ch`Js::InterpreterStackFrame::Process(this=0x00007fffffffa450) at InterpreterStackFrame.cpp:3472:20
    frame #19: 0x000055555681d6c8 ch`BailOutRecord::BailOutHelper(layout=0x00007fffffffae40, functionRef=0x00007fffffffae40, args=0x00007fffffffaaa0, isInlinee=false, bailOutRecord=0x0000555557ef5d78, bailOutOffset=2, returnAddress=0x00007ff7e7bb0197, bailOutKind=BailOnSimpleJitToFullJitLoopBody, registerSaves=0x00007fffffffab50, bailOutReturnValue=0x0000000000000000, pArgumentsObject=0x00007fffffffae28, branchValue=0x0000000000000000, argoutRestoreAddress=0x0000000000000000) at BailOut.cpp:1785:78
    frame #20: 0x000055555681bf20 ch`BailOutRecord::BailOutCommonNoCodeGen(layout=0x00007fffffffae40, bailOutRecord=0x0000555557ef5d78, bailOutOffset=2, returnAddress=0x00007ff7e7bb0197, bailOutKind=BailOnSimpleJitToFullJitLoopBody, branchValue=0x0000000000000000, registerSaves=0x00007fffffffab50, bailOutReturnValue=0x0000000000000000, argoutRestoreAddress=0x0000000000000000) at BailOut.cpp:1153:22
    frame #21: 0x000055555681b853 ch`BailOutRecord::BailOutCommon(layout=0x00007fffffffae40, bailOutRecord=0x0000555557ef5d78, bailOutOffset=2, returnAddress=0x00007ff7e7bb0197, bailOutKind=BailOnSimpleJitToFullJitLoopBody, savedImplicitCallFlags=ImplicitCall_None, branchValue=0x0000000000000000, bailOutReturnValue=0x0000000000000000, argoutRestoreAddress=0x0000000000000000) at BailOut.cpp:1176:22
    frame #22: 0x000055555681b6a3 ch`BailOutRecord::BailOutFromFunction(layout=0x00007fffffffae40, bailOutRecord=0x0000555557ef5d78, returnAddress=0x00007ff7e7bb0197, argoutRestoreAddress=0x0000000000000000, savedImplicitCallFlags=ImplicitCall_None) at BailOut.cpp:1127:12
    frame #23: 0x000055555681b341 ch`BailOutRecord::BailOut(bailOutRecord=0x0000555557ef5d78) at BailOut.cpp:1112:12
    frame #24: 0x00007ff7e7bb0197
    frame #25: 0x00005555564a37de ch`amd64_CallFunction at JavascriptFunctionA.S:100
    frame #26: 0x00005555561d7a4b ch`void* Js::JavascriptFunction::CallFunction<true>(function=0x00007ff7e7c76730, entryPoint=0x00007ff7e7bb0000, args=Arguments @ 0x00007fffffffaf70, useLargeArgCount=false)(Js::RecyclableObject*, Js::CallInfo, ...), Js::Arguments, bool) at JavascriptFunction.cpp:1364:16
    frame #27: 0x0000555555ffc5fe ch`void Js::InterpreterStackFrame::OP_CallCommon<Js::OpLayoutDynamicProfile<Js::OpLayoutT_CallIWithICIndex<Js::LayoutSizePolicy<(Js::LayoutSize)0> > > __unaligned>(this=0x00007fffffffc010, playout=0x00007ff7e84cd491, function=0x00007ff7e7c76730, flags=16, spreadIndices=0x0000000000000000)0> > > __unaligned const __unaligned*, Js::RecyclableObject*, unsigned int, Js::AuxArray<unsigned int> const*) at InterpreterStackFrame.cpp:3973:21
    frame #28: 0x0000555555fcdb05 ch`void Js::InterpreterStackFrame::OP_CallI<Js::OpLayoutDynamicProfile<Js::OpLayoutT_CallIWithICIndex<Js::LayoutSizePolicy<(Js::LayoutSize)0> > > __unaligned>(this=0x00007fffffffc010, playout=0x00007ff7e84cd491)0> > > __unaligned const __unaligned*) at InterpreterStackFrame.h:510:72
    frame #29: 0x0000555555e71df3 ch`Js::InterpreterStackFrame::ProcessUnprofiled(this=0x00007fffffffc010) at InterpreterHandler.inl:91:3
    frame #30: 0x0000555555e522be ch`Js::InterpreterStackFrame::Process(this=0x00007fffffffc010) at InterpreterStackFrame.cpp:3495:22
    frame #31: 0x0000555555e50dd3 ch`Js::InterpreterStackFrame::InterpreterHelper(function=0x00007ff7e7c766e0, args=ArgumentReader @ 0x00007fffffffc530, returnAddress=0x00007ff7e7bd0fa2, addressOfReturnAddress=0x00007fffffffc578, asmJsReturn=0x0000000000000000) at InterpreterStackFrame.cpp:2153:40
    frame #32: 0x0000555555e4feb0 ch`Js::InterpreterStackFrame::InterpreterThunk(layout=0x00007fffffffc590) at InterpreterStackFrame.cpp:1833:16
    frame #33: 0x00007ff7e7bd0fa2
    frame #34: 0x00005555564a37de ch`amd64_CallFunction at JavascriptFunctionA.S:100
    frame #35: 0x00005555561d7a4b ch`void* Js::JavascriptFunction::CallFunction<true>(function=0x00007ff7e7c766e0, entryPoint=(ch`NativeCodeGenerator::CheckCodeGenThunk(Js::RecyclableObject*, Js::CallInfo, ...)), args=Arguments @ 0x00007fffffffc798, useLargeArgCount=false)(Js::RecyclableObject*, Js::CallInfo, ...), Js::Arguments, bool) at JavascriptFunction.cpp:1364:16
    frame #36: 0x00005555561cf2f4 ch`Js::JavascriptFunction::CallRootFunctionInternal(obj=0x00007ff7e7c766e0, args=Arguments @ 0x00007fffffffc810, scriptContext=0x0000555557ee8f48, inScript=true) at JavascriptFunction.cpp:772:24
    frame #37: 0x00005555561cf10c ch`Js::JavascriptFunction::CallRootFunction(obj=0x00007ff7e7c766e0, args=<unavailable>, scriptContext=0x0000555557ee8f48, inScript=true) at JavascriptFunction.cpp:717:15
    frame #38: 0x00005555561cf0b1 ch`Js::JavascriptFunction::CallRootFunction(this=0x00007ff7e7c766e0, args=<unavailable>, scriptContext=0x0000555557ee8f48, inScript=true) at JavascriptFunction.cpp:832:16
    frame #39: 0x0000555555894a8e ch`RunScriptCore(this=0x00007fffffffcbe0, scriptContext=0x0000555557ee8f48, _actionEntryPopper=0x00007fffffffcbc0)::$_85::operator()(Js::ScriptContext*, TTD::TTDJsRTActionResultAutoRecorder&) const at Jsrt.cpp:3705:49
    frame #40: 0x0000555555894624 ch`_JsErrorCode ContextAPIWrapper<false, RunScriptCore(void*, unsigned char const*, unsigned long, LoadScriptFlag, unsigned long, char16_t const*, bool, _JsParseScriptAttributes, bool, void**)::$_85>(this=0x00007fffffffcb78, scriptContext=0x0000555557ee8f48)::$_85)::'lambda'(Js::ScriptContext*)::operator()(Js::ScriptContext*) const at JsrtInternal.h:237:16
    frame #41: 0x0000555555893fc4 ch`_JsErrorCode ContextAPIWrapper_Core<false, _JsErrorCode ContextAPIWrapper<false, RunScriptCore(void*, unsigned char const*, unsigned long, LoadScriptFlag, unsigned long, char16_t const*, bool, _JsParseScriptAttributes, bool, void**)::$_85>(RunScriptCore(void*, unsigned char const*, unsigned long, LoadScriptFlag, unsigned long, char16_t const*, bool, _JsParseScriptAttributes, bool, void**)::$_85)::'lambda'(Js::ScriptContext*)>(fn=(anonymous class) @ 0x00007fffffffcb78)::$_85) at JsrtInternal.h:192:23
    frame #42: 0x00005555558608f6 ch`_JsErrorCode ContextAPIWrapper<false, RunScriptCore(void*, unsigned char const*, unsigned long, LoadScriptFlag, unsigned long, char16_t const*, bool, _JsParseScriptAttributes, bool, void**)::$_85>(fn=(anonymous class) @ 0x00007fffffffcbe0)::$_85) at JsrtInternal.h:235:27
    frame #43: 0x00005555558607fb ch`RunScriptCore(scriptSource=0x00007ff7e7c44000, script="function opt(arg) {\n    do {} while (arg !== arg);\n}\nfor (let i = 0; i < 100; i++) {\n    opt();\n}\n// CRASH INFO\n// ==========\n// TERMSIG: 4\n// STDERR:\n// ASSERTION 3590041: (/home/wjm/ChakraCore/lib/Backend/DbCheckPostLower.cpp, line 81) Inconsistency in Helper label annotations\n//  Failure: (prevInstr && prevInstr->IsLabelInstr() && !prevInstr->AsLabelInstr()->isOpHelper)\n// STDOUT:\n// ARGS: /home/wjm/ChakraCore/out/Debug/ch --maxinterpretcount:10 --maxsimplejitruncount:100 -bgjit- -reprl fuzzcode.js\n// EXECUTION TIME: 18 ms\n\n\n/*\n\nTitle: \n\n## Version\ncommit id: c3ead3f8a6e0bb8e32e043adc091c68cba5935e9\n\n## Platform\nUbuntu 20.04.5 LTS (Linux 5.4.0-144-generic x86_64)\n\n## Build\n- Debug Mode\n\n```\n./build.sh --debug --static\n```\n\n## PoC\n```\n\n```\n\n## Execution steps & Output\n```\n./ch --maxinterpretcount:10 --maxsimplejitruncount:100 -bgjit- poc.js\nAborted (core dumped)\n```\n## Backtrace\n```\n\n\n```\n\n*\/", cb=907, loadScriptFlag=LoadScriptFlag_Utf8Source | LoadScriptFlag_ExternalArrayBuffer, sourceContext=0, sourceUrl=u"/home/wjm/DiTing-pocs/chakra/bug15_label.js", parseOnly=false, parseAttributes=JsParseScriptAttributeNone, isSourceModule=false, result=0x0000000000000000) at Jsrt.cpp:3656:12
    frame #44: 0x0000555555862f6e ch`::JsRun(JsValueRef, JsSourceContext, JsValueRef, JsParseScriptAttributes, JsValueRef *) [inlined] CompileRun(scriptVal=0x00007ff7e7c44000, sourceContext=0, sourceUrl=0x00007ff7e7c71cf0, parseAttributes=JsParseScriptAttributeNone, result=0x0000000000000000, parseOnly=false) at Jsrt.cpp:5019:12
    frame #45: 0x0000555555862db9 ch`::JsRun(scriptVal=0x00007ff7e7c44000, sourceContext=0, sourceUrl=0x00007ff7e7c71cf0, parseAttributes=JsParseScriptAttributeNone, result=0x0000000000000000) at Jsrt.cpp:5041
    frame #46: 0x0000555555787293 ch`ChakraRTInterface::JsRun(script=0x00007ff7e7c44000, sourceContext=0, sourceUrl=0x00007ff7e7c71cf0, parseAttributes=JsParseScriptAttributeNone, result=0x0000000000000000) at ChakraRtInterface.h:487:179
    frame #47: 0x0000555555784924 ch`RunScript(fileName="bug15_label.js", fileContents="function opt(arg) {\n    do {} while (arg !== arg);\n}\nfor (let i = 0; i < 100; i++) {\n    opt();\n}\n// CRASH INFO\n// ==========\n// TERMSIG: 4\n// STDERR:\n// ASSERTION 3590041: (/home/wjm/ChakraCore/lib/Backend/DbCheckPostLower.cpp, line 81) Inconsistency in Helper label annotations\n//  Failure: (prevInstr && prevInstr->IsLabelInstr() && !prevInstr->AsLabelInstr()->isOpHelper)\n// STDOUT:\n// ARGS: /home/wjm/ChakraCore/out/Debug/ch --maxinterpretcount:10 --maxsimplejitruncount:100 -bgjit- -reprl fuzzcode.js\n// EXECUTION TIME: 18 ms\n\n\n/*\n\nTitle: \n\n## Version\ncommit id: c3ead3f8a6e0bb8e32e043adc091c68cba5935e9\n\n## Platform\nUbuntu 20.04.5 LTS (Linux 5.4.0-144-generic x86_64)\n\n## Build\n- Debug Mode\n\n```\n./build.sh --debug --static\n```\n\n## PoC\n```\n\n```\n\n## Execution steps & Output\n```\n./ch --maxinterpretcount:10 --maxsimplejitruncount:100 -bgjit- poc.js\nAborted (core dumped)\n```\n## Backtrace\n```\n\n\n```\n\n*\/", fileLength=907, fileContentsFinalizeCallback=(ch`WScriptJsrt::FinalizeFree(void*) at WScriptJsrt.cpp:217), bufferValue=0x0000000000000000, fullPath="/home/wjm/DiTing-pocs/chakra/bug15_label.js", parserStateCache=0x0000000000000000)(void*), void*, char*, void*) at ch.cpp:451:25
    frame #48: 0x00005555557863f0 ch`ExecuteTest(fileName="bug15_label.js") at ch.cpp:917:13
    frame #49: 0x00005555557864ac ch`ExecuteTestWithMemoryCheck(fileName="bug15_label.js") at ch.cpp:967:10
    frame #50: 0x0000555555786d7a ch`main(argc=5, c_argv=0x00007fffffffd648) at ch.cpp:1274:20
    frame #51: 0x00007ffff778d1e2 libc.so.6`__libc_start_main + 242
    frame #52: 0x0000555555783b7e ch`_start + 46