ChakraCore icon indicating copy to clipboard operation
ChakraCore copied to clipboard

Assertion Failure: objectWithProperty->IsWritable(propertyId) in Js::JavaScriptOperators::SetProperty

Open JimWongM opened this issue 2 years ago • 0 comments

Version

commit id: c3ead3f8a6e0bb8e32e043adc091c68cba5935e9

Platform

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

Build

  • Debug Mode
./build.sh --debug --static

PoC

function opt() {
    function f(a13) {
        opt = a13;
    }
    new Promise(f);
    opt.__proto__ = Reflect;
    return opt;
}
const a = opt();
a[opt] = 2;
a.length = 2;

Execution steps & Output

./ch --maxinterpretcount:10 --maxsimplejitruncount:100 -bgjit- poc.js
ASSERTION 419477: (/home/wjm/ChakraCore/lib/Runtime/./Language/CacheOperators.inl, line 367) objectWithProperty->IsWritable(propertyId) || (isRoot && VarTo<RootObjectBase>(objectWithProperty)->IsLetConstGlobal(propertyId)) || JavascriptFunction::IsBuiltinProperty(objectWithProperty, propertyId)
 Failure: (objectWithProperty->IsWritable(propertyId) || (isRoot && VarTo<RootObjectBase>(objectWithProperty)->IsLetConstGlobal(propertyId)) || JavascriptFunction::IsBuiltinProperty(objectWithProperty, propertyId))
Signal: SIGILL (Illegal instruction)

Backtrace

(lldb) bt
* thread #1, name = 'ch', stop reason = signal SIGILL: illegal instruction operand
  * frame #0: 0x0000555556a65f48 ch`void Js::CacheOperators::Cache<false, false, true>(isProto=false, objectWithProperty=0x00007ff7e7c62300, isRoot=false, type=0x00007ff7e7c4b7c0, typeWithoutProperty=0x0000000000000000, propertyId=209, propertyIndex=0, isInlineSlot=false, isMissing=false, requiredAuxSlotCapacity=0, info=0x00007fffffffae40, requestContext=0x0000555557ee90e8) at CacheOperators.inl:364:13
    frame #1: 0x0000555556a63d88 ch`Js::CacheOperators::CachePropertyWrite(object=0x00007ff7e7c62300, isRoot=false, typeWithoutProperty=0x0000000000000000, propertyId=209, info=0x00007fffffffae40, requestContext=0x0000555557ee90e8) at CacheOperators.cpp:284:13
    frame #2: 0x000055555605114f ch`int Js::JavascriptOperators::SetProperty_Internal<false>(receiver=0x00007ff7e7c62300, object=0x00007ff7e7c62300, isRoot=false, propertyId=209, newValue=0x0001000000000002, info=0x00007fffffffae40, requestContext=0x0000555557ee90e8, propertyOperationFlags=PropertyOperation_None) at JavascriptOperators.cpp:2847:21
    frame #3: 0x000055555602ee9a ch`Js::JavascriptOperators::SetProperty(receiver=0x00007ff7e7c62300, object=0x00007ff7e7c62300, propertyId=209, newValue=0x0001000000000002, info=0x00007fffffffae40, requestContext=0x0000555557ee90e8, propertyOperationFlags=PropertyOperation_None) at JavascriptOperators.cpp:2675:16
    frame #4: 0x000055555602fbfd ch`Js::JavascriptOperators::OP_SetProperty(instance=0x00007ff7e7c62300, propertyId=209, newValue=0x0001000000000002, scriptContext=0x0000555557ee90e8, info=0x00007fffffffae40, flags=PropertyOperation_None, thisInstance=0x00007ff7e7c62300) at JavascriptOperators.cpp:2932:20
    frame #5: 0x0000555556070ed6 ch`void Js::JavascriptOperators::PatchPutValueWithThisPtrNoLocalFastPath<false, Js::InlineCache>(functionBody=0x00007ff7e7c47000, inlineCache=0x00007ff7e84caf10, inlineCacheIndex=0, instance=0x00007ff7e7c62300, propertyId=209, newValue=0x0001000000000002, thisInstance=0x00007ff7e7c62300, flags=PropertyOperation_None) at JavascriptOperators.cpp:8712:14
    frame #6: 0x0000555556070d12 ch`void Js::JavascriptOperators::PatchPutValueNoLocalFastPath<false, Js::InlineCache>(functionBody=0x00007ff7e7c47000, inlineCache=0x00007ff7e84caf10, inlineCacheIndex=0, instance=0x00007ff7e7c62300, propertyId=209, newValue=0x0001000000000002, flags=PropertyOperation_None) at JavascriptOperators.cpp:8660:9
    frame #7: 0x0000555555fff52d ch`void Js::InterpreterStackFrame::DoSetProperty_NoFastPath<Js::OpLayoutT_ElementCP<Js::LayoutSizePolicy<(Js::LayoutSize)0> > const __unaligned>(this=0x00007fffffffc030, playout=0x00007ff7e7bf016e, instance=0x00007ff7e7c62300, flags=PropertyOperation_None)0> > const __unaligned __unaligned*, void*, Js::PropertyOperationFlags) at InterpreterStackFrame.cpp:4642:9
    frame #8: 0x0000555555fff319 ch`void Js::InterpreterStackFrame::DoSetProperty<Js::OpLayoutT_ElementCP<Js::LayoutSizePolicy<(Js::LayoutSize)0> > const __unaligned>(this=0x00007fffffffc030, playout=0x00007ff7e7bf016e, instance=0x00007ff7e7c62300, flags=PropertyOperation_None)0> > const __unaligned __unaligned*, void*, Js::PropertyOperationFlags) at InterpreterStackFrame.cpp:4620:9
    frame #9: 0x0000555555fc8364 ch`void Js::InterpreterStackFrame::OP_SetProperty<Js::OpLayoutT_ElementCP<Js::LayoutSizePolicy<(Js::LayoutSize)0> > const __unaligned>(this=0x00007fffffffc030, playout=0x00007ff7e7bf016e)0> > const __unaligned __unaligned*) at InterpreterStackFrame.cpp:4728:9
    frame #10: 0x0000555555e767cb ch`Js::InterpreterStackFrame::ProcessUnprofiled(this=0x00007fffffffc030) at InterpreterHandler.inl:202:3
    frame #11: 0x0000555555e522be ch`Js::InterpreterStackFrame::Process(this=0x00007fffffffc030) at InterpreterStackFrame.cpp:3495:22
    frame #12: 0x0000555555e50dd3 ch`Js::InterpreterStackFrame::InterpreterHelper(function=0x00007ff7e7c76730, args=ArgumentReader @ 0x00007fffffffc530, returnAddress=0x00007ff7e7bd0fa2, addressOfReturnAddress=0x00007fffffffc578, asmJsReturn=0x0000000000000000) at InterpreterStackFrame.cpp:2153:40
    frame #13: 0x0000555555e4feb0 ch`Js::InterpreterStackFrame::InterpreterThunk(layout=0x00007fffffffc590) at InterpreterStackFrame.cpp:1833:16
    frame #14: 0x00007ff7e7bd0fa2
    frame #15: 0x00005555564a37de ch`amd64_CallFunction at JavascriptFunctionA.S:100
    frame #16: 0x00005555561d7a4b ch`void* Js::JavascriptFunction::CallFunction<true>(function=0x00007ff7e7c76730, 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 #17: 0x00005555561cf2f4 ch`Js::JavascriptFunction::CallRootFunctionInternal(obj=0x00007ff7e7c76730, args=Arguments @ 0x00007fffffffc810, scriptContext=0x0000555557ee90e8, inScript=true) at JavascriptFunction.cpp:772:24
    frame #18: 0x00005555561cf10c ch`Js::JavascriptFunction::CallRootFunction(obj=0x00007ff7e7c76730, args=<unavailable>, scriptContext=0x0000555557ee90e8, inScript=true) at JavascriptFunction.cpp:717:15
    frame #19: 0x00005555561cf0b1 ch`Js::JavascriptFunction::CallRootFunction(this=0x00007ff7e7c76730, args=<unavailable>, scriptContext=0x0000555557ee90e8, inScript=true) at JavascriptFunction.cpp:832:16
    frame #20: 0x0000555555894a8e ch`RunScriptCore(this=0x00007fffffffcbe0, scriptContext=0x0000555557ee90e8, _actionEntryPopper=0x00007fffffffcbc0)::$_85::operator()(Js::ScriptContext*, TTD::TTDJsRTActionResultAutoRecorder&) const at Jsrt.cpp:3705:49
    frame #21: 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=0x0000555557ee90e8)::$_85)::'lambda'(Js::ScriptContext*)::operator()(Js::ScriptContext*) const at JsrtInternal.h:237:16
    frame #22: 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 #23: 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 #24: 0x00005555558607fb ch`RunScriptCore(scriptSource=0x00007ff7e7c44000, script="function opt() {\n    function f(a13) {\n        opt = a13;\n    }\n    new Promise(f);\n    opt.__proto__ = Reflect;\n    return opt;\n}\nconst a = opt();\na[opt] = 2;\na.length = 2;\n\n// ASSERTION 1327990: (/home/wjm/ChakraCore/lib/Runtime/./Language/CacheOperators.inl, line 367) objectWithProperty->IsWritable(propertyId) || (isRoot && VarTo<RootObjectBase>(objectWithProperty)->IsLetConstGlobal(propertyId)) || JavascriptFunction::IsBuiltinProperty(objectWithProperty, propertyId)\n//  Failure: (objectWithProperty->IsWritable(propertyId) || (isRoot && VarTo<RootObjectBase>(objectWithProperty)->IsLetConstGlobal(propertyId)) || JavascriptFunction::IsBuiltinProperty(objectWithProperty, propertyId))\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: objectWithProperty->IsWritable(propertyId) in ChakraCore/lib/Runtime/./Language/CacheOperators.inl, line 367\n\n## Version\ncommit id: c3ead3f8a6e"..., cb=1330, loadScriptFlag=LoadScriptFlag_Utf8Source | LoadScriptFlag_ExternalArrayBuffer, sourceContext=0, sourceUrl=u"/home/wjm/DiTing-pocs/chakra/bug25_promise.js", parseOnly=false, parseAttributes=JsParseScriptAttributeNone, isSourceModule=false, result=0x0000000000000000) at Jsrt.cpp:3656:12
    frame #25: 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 #26: 0x0000555555862db9 ch`::JsRun(scriptVal=0x00007ff7e7c44000, sourceContext=0, sourceUrl=0x00007ff7e7c71cf0, parseAttributes=JsParseScriptAttributeNone, result=0x0000000000000000) at Jsrt.cpp:5041
    frame #27: 0x0000555555787293 ch`ChakraRTInterface::JsRun(script=0x00007ff7e7c44000, sourceContext=0, sourceUrl=0x00007ff7e7c71cf0, parseAttributes=JsParseScriptAttributeNone, result=0x0000000000000000) at ChakraRtInterface.h:487:179
    frame #28: 0x0000555555784924 ch`RunScript(fileName="bug25_promise.js", fileContents="function opt() {\n    function f(a13) {\n        opt = a13;\n    }\n    new Promise(f);\n    opt.__proto__ = Reflect;\n    return opt;\n}\nconst a = opt();\na[opt] = 2;\na.length = 2;\n\n// ASSERTION 1327990: (/home/wjm/ChakraCore/lib/Runtime/./Language/CacheOperators.inl, line 367) objectWithProperty->IsWritable(propertyId) || (isRoot && VarTo<RootObjectBase>(objectWithProperty)->IsLetConstGlobal(propertyId)) || JavascriptFunction::IsBuiltinProperty(objectWithProperty, propertyId)\n//  Failure: (objectWithProperty->IsWritable(propertyId) || (isRoot && VarTo<RootObjectBase>(objectWithProperty)->IsLetConstGlobal(propertyId)) || JavascriptFunction::IsBuiltinProperty(objectWithProperty, propertyId))\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: objectWithProperty->IsWritable(propertyId) in ChakraCore/lib/Runtime/./Language/CacheOperators.inl, line 367\n\n## Version\ncommit id: c3ead3f8a6e"..., fileLength=1330, fileContentsFinalizeCallback=(ch`WScriptJsrt::FinalizeFree(void*) at WScriptJsrt.cpp:217), bufferValue=0x0000000000000000, fullPath="/home/wjm/DiTing-pocs/chakra/bug25_promise.js", parserStateCache=0x0000000000000000)(void*), void*, char*, void*) at ch.cpp:451:25
    frame #29: 0x00005555557863f0 ch`ExecuteTest(fileName="bug25_promise.js") at ch.cpp:917:13
    frame #30: 0x00005555557864ac ch`ExecuteTestWithMemoryCheck(fileName="bug25_promise.js") at ch.cpp:967:10
    frame #31: 0x0000555555786d7a ch`main(argc=5, c_argv=0x00007fffffffd648) at ch.cpp:1274:20
    frame #32: 0x00007ffff778d1e2 libc.so.6`__libc_start_main + 242
    frame #33: 0x0000555555783b7e ch`_start + 46

JimWongM avatar May 13 '23 04:05 JimWongM