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: (info->IsNoCache() || object->GetPropertyIndex(propertyId) == Constants::NoSlot) in ChakraCore/lib/Runtime/Language/CacheOperators.cpp, line 178 #6915

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

for (const i in RegExp) { // RegExp should not be iterated by for-in
    Object.defineProperty(RegExp, i, { value: i });
    RegExp[i] = 2
}

Execution steps & Output

./ch poc.js
ASSERTION 435069: (/home/wjm/ChakraCore/lib/Runtime/Language/CacheOperators.cpp, line 178) Missed updating PropertyValueInfo?
 Failure: (info->IsNoCache() || object->GetPropertyIndex(propertyId) == Constants::NoSlot)
Signal: SIGILL (Illegal instruction)

Backtrace

(lldb) bt
* thread #1, name = 'ch', stop reason = signal SIGILL: illegal instruction operand
  * frame #0: 0x0000555556a6319f ch`Js::CacheOperators::CachePropertyWrite(object=0x00007ff7e6c51000, isRoot=false, typeWithoutProperty=0x00007ff7e6c50440, propertyId=475, info=0x00007fffffffadc0, requestContext=0x0000555557ee9048) at CacheOperators.cpp:178:17
    frame #1: 0x00005555560658f2 ch`int Js::JavascriptOperators::SetPropertyWPCache<int>(receiver=0x00007ff7e6c51000, object=0x00007ff7e6c51000, propertyKey=475, newValue=0x0001000000000002, requestContext=0x0000555557ee9048, propertyOperationFlags=PropertyOperation_None, info=0x00007fffffffadc0) at JavascriptOperators.cpp:2555:21
    frame #2: 0x0000555556065c10 ch`bool Js::JavascriptOperators::SetElementIWithCache<true>(receiver=0x00007ff7e6c51000, object=0x00007ff7e6c51000, index=0x00007ff7e6c5a6c0, value=0x0001000000000002, propertyRecordUsageCache=0x00007ff7e6c5a6e0, scriptContext=0x0000555557ee9048, flags=PropertyOperation_None, operationInfo=0x00007fffffffae88) at JavascriptOperators.cpp:4137:16
    frame #3: 0x00005555560a12f1 ch`Js::ProfilingHelpers::ProfiledStElem(base=0x00007ff7e6c51000, varIndex=0x00007ff7e6c5a6c0, value=0x0001000000000002, functionBody=0x00007ff7e6c37000, profileId=0, flags=PropertyOperation_None, didArrayAccessHelperCall=false, bailedOutOnArraySpecialization=false) at ProfilingHelpers.cpp:373:13
    frame #4: 0x0000555555fc939c ch`void Js::InterpreterStackFrame::OP_ProfiledSetElementI<Js::OpLayoutT_ElementI<Js::LayoutSizePolicy<(Js::LayoutSize)0> > >(this=0x00007fffffffbfd0, playout=0x00007ff7e6be5062, flags=PropertyOperation_None)0> > > const __unaligned*, Js::PropertyOperationFlags) at InterpreterStackFrame.cpp:5273:9
    frame #5: 0x0000555555eb2ed3 ch`Js::InterpreterStackFrame::ProcessProfiled(this=0x00007fffffffbfd0) at InterpreterHandler.inl:288:3
    frame #6: 0x0000555555e52112 ch`Js::InterpreterStackFrame::Process(this=0x00007fffffffbfd0) at InterpreterStackFrame.cpp:3472:20
    frame #7: 0x0000555555e50dd3 ch`Js::InterpreterStackFrame::InterpreterHelper(function=0x00007ff7e7c766e0, args=ArgumentReader @ 0x00007fffffffc570, returnAddress=0x00007ff7e6bc0fa2, addressOfReturnAddress=0x00007fffffffc5b8, asmJsReturn=0x0000000000000000) at InterpreterStackFrame.cpp:2153:40
    frame #8: 0x0000555555e4feb0 ch`Js::InterpreterStackFrame::InterpreterThunk(layout=0x00007fffffffc5d0) at InterpreterStackFrame.cpp:1833:16
    frame #9: 0x00007ff7e6bc0fa2
    frame #10: 0x00005555564a37de ch`amd64_CallFunction at JavascriptFunctionA.S:100
    frame #11: 0x00005555561d7a4b ch`void* Js::JavascriptFunction::CallFunction<true>(function=0x00007ff7e7c766e0, entryPoint=(ch`NativeCodeGenerator::CheckCodeGenThunk(Js::RecyclableObject*, Js::CallInfo, ...)), args=Arguments @ 0x00007fffffffc7d8, useLargeArgCount=false)(Js::RecyclableObject*, Js::CallInfo, ...), Js::Arguments, bool) at JavascriptFunction.cpp:1364:16
    frame #12: 0x00005555561cf2f4 ch`Js::JavascriptFunction::CallRootFunctionInternal(obj=0x00007ff7e7c766e0, args=Arguments @ 0x00007fffffffc850, scriptContext=0x0000555557ee9048, inScript=true) at JavascriptFunction.cpp:772:24
    frame #13: 0x00005555561cf10c ch`Js::JavascriptFunction::CallRootFunction(obj=0x00007ff7e7c766e0, args=<unavailable>, scriptContext=0x0000555557ee9048, inScript=true) at JavascriptFunction.cpp:717:15
    frame #14: 0x00005555561cf0b1 ch`Js::JavascriptFunction::CallRootFunction(this=0x00007ff7e7c766e0, args=<unavailable>, scriptContext=0x0000555557ee9048, inScript=true) at JavascriptFunction.cpp:832:16
    frame #15: 0x0000555555894a8e ch`RunScriptCore(this=0x00007fffffffcc20, scriptContext=0x0000555557ee9048, _actionEntryPopper=0x00007fffffffcc00)::$_85::operator()(Js::ScriptContext*, TTD::TTDJsRTActionResultAutoRecorder&) const at Jsrt.cpp:3705:49
    frame #16: 0x0000555555894624 ch`_JsErrorCode ContextAPIWrapper<false, RunScriptCore(void*, unsigned char const*, unsigned long, LoadScriptFlag, unsigned long, char16_t const*, bool, _JsParseScriptAttributes, bool, void**)::$_85>(this=0x00007fffffffcbb8, scriptContext=0x0000555557ee9048)::$_85)::'lambda'(Js::ScriptContext*)::operator()(Js::ScriptContext*) const at JsrtInternal.h:237:16
    frame #17: 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) @ 0x00007fffffffcbb8)::$_85) at JsrtInternal.h:192:23
    frame #18: 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) @ 0x00007fffffffcc20)::$_85) at JsrtInternal.h:235:27
    frame #19: 0x00005555558607fb ch`RunScriptCore(scriptSource=0x00007ff7e6c34000, script="for (const i in RegExp) {\n    Object.defineProperty(RegExp, i, { value: i });\n    RegExp[i] = 2\n}\n// CRASH INFO\n// ==========\n// TERMSIG: 4\n// STDERR:\n// ASSERTION 3346583: (/home/wjm/ChakraCore/lib/Runtime/Language/CacheOperators.cpp, line 178) Missed updating PropertyValueInfo?\n//  Failure: (info->IsNoCache() || object->GetPropertyIndex(propertyId) == Constants::NoSlot)\n// STDOUT:\n// ARGS: /home/wjm/ChakraCore/out/Debug/ch --maxinterpretcount:10 --maxsimplejitruncount:100 -bgjit- -reprl fuzzcode.js\n// EXECUTION TIME: 13 ms\n\n\n/*\n\nTitle: Assertion Failure: (info->IsNoCache() || object->GetPropertyIndex(propertyId) == Constants::NoSlot) in ChakraCore/lib/Runtime/Language/CacheOperators.cpp, line 178\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```\nfor (const i in RegExp) {\n    Object.defineProperty(RegExp, i, { value: i });\n    RegExp[i] = 2\n}\n```\n\n## Execution"..., cb=1341, loadScriptFlag=LoadScriptFlag_Utf8Source | LoadScriptFlag_ExternalArrayBuffer, sourceContext=0, sourceUrl=u"/home/wjm/DiTing-pocs/chakra/bug30_nocache.js", parseOnly=false, parseAttributes=JsParseScriptAttributeNone, isSourceModule=false, result=0x0000000000000000) at Jsrt.cpp:3656:12
    frame #20: 0x0000555555862f6e ch`::JsRun(JsValueRef, JsSourceContext, JsValueRef, JsParseScriptAttributes, JsValueRef *) [inlined] CompileRun(scriptVal=0x00007ff7e6c34000, sourceContext=0, sourceUrl=0x00007ff7e7c71cf0, parseAttributes=JsParseScriptAttributeNone, result=0x0000000000000000, parseOnly=false) at Jsrt.cpp:5019:12
    frame #21: 0x0000555555862db9 ch`::JsRun(scriptVal=0x00007ff7e6c34000, sourceContext=0, sourceUrl=0x00007ff7e7c71cf0, parseAttributes=JsParseScriptAttributeNone, result=0x0000000000000000) at Jsrt.cpp:5041
    frame #22: 0x0000555555787293 ch`ChakraRTInterface::JsRun(script=0x00007ff7e6c34000, sourceContext=0, sourceUrl=0x00007ff7e7c71cf0, parseAttributes=JsParseScriptAttributeNone, result=0x0000000000000000) at ChakraRtInterface.h:487:179
    frame #23: 0x0000555555784924 ch`RunScript(fileName="bug30_nocache.js", fileContents="for (const i in RegExp) {\n    Object.defineProperty(RegExp, i, { value: i });\n    RegExp[i] = 2\n}\n// CRASH INFO\n// ==========\n// TERMSIG: 4\n// STDERR:\n// ASSERTION 3346583: (/home/wjm/ChakraCore/lib/Runtime/Language/CacheOperators.cpp, line 178) Missed updating PropertyValueInfo?\n//  Failure: (info->IsNoCache() || object->GetPropertyIndex(propertyId) == Constants::NoSlot)\n// STDOUT:\n// ARGS: /home/wjm/ChakraCore/out/Debug/ch --maxinterpretcount:10 --maxsimplejitruncount:100 -bgjit- -reprl fuzzcode.js\n// EXECUTION TIME: 13 ms\n\n\n/*\n\nTitle: Assertion Failure: (info->IsNoCache() || object->GetPropertyIndex(propertyId) == Constants::NoSlot) in ChakraCore/lib/Runtime/Language/CacheOperators.cpp, line 178\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```\nfor (const i in RegExp) {\n    Object.defineProperty(RegExp, i, { value: i });\n    RegExp[i] = 2\n}\n```\n\n## Execution"..., fileLength=1341, fileContentsFinalizeCallback=(ch`WScriptJsrt::FinalizeFree(void*) at WScriptJsrt.cpp:217), bufferValue=0x0000000000000000, fullPath="/home/wjm/DiTing-pocs/chakra/bug30_nocache.js", parserStateCache=0x0000000000000000)(void*), void*, char*, void*) at ch.cpp:451:25
    frame #24: 0x00005555557863f0 ch`ExecuteTest(fileName="bug30_nocache.js") at ch.cpp:917:13
    frame #25: 0x00005555557864ac ch`ExecuteTestWithMemoryCheck(fileName="bug30_nocache.js") at ch.cpp:967:10
    frame #26: 0x0000555555786d7a ch`main(argc=2, c_argv=0x00007fffffffd688) at ch.cpp:1274:20
    frame #27: 0x00007ffff778d1e2 libc.so.6`__libc_start_main + 242
    frame #28: 0x0000555555783b7e ch`_start + 46