chakra-core / chakra-core/ChakraCore

ASAN: We can leak ArrayBuffers in WASM code when failing module construction

Open
#4,417 0 comments 0 reactions 0 assignees View on GitHub
Bug Severity: 3
Dominant language
JavaScript
Stars
9.3k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

This may be an issue of needing to have the recycler properly clean everything up before closing ch.

```
[1910/1928 5.87] Failed -> wasm/params.js
/home/demorri/ChakraCore/out/Debug/ch -WERExceptionSupport -ExtendedErrorStackForTestHost -BaselineMode -maxInterpretCount:1 -maxSimpleJitRunCount:1 -bgjit- -dynamicprofilecache:profile.dpl.2712 -wasm -EnableFatalErrorOnOOM- -args 14000 -endargs /home/demorri/ChakraCore/test/wasm/params.js

Output:
----------------------------
Test(14000)
Module is invalid

=================================================================
==17313==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 258796 byte(s) in 1 object(s) allocated from:
#0 0x5576295570f8 in __interceptor_malloc (/home/demorri/ChakraCore/out/Debug/ch+0xcbc0f8)
#1 0x55762963b7e7 in CorUnix::InternalMalloc(unsigned long) /home/demorri/ChakraCore/pal/src/cruntime/malloc.cpp:114:20
#2 0x55762963b7b4 in PAL_malloc /home/demorri/ChakraCore/pal/src/cruntime/malloc.cpp:98:12
#3 0x55762b327133 in Js::ArrayBuffer::ArrayBuffer(unsigned int, Js::DynamicType*, void* (*)(unsigned long)) /home/demorri/ChakraCore/lib/Runtime/Library/ArrayBuffer.cpp:606:33
#4 0x55762b320f6f in Js::JavascriptArrayBuffer::JavascriptArrayBuffer(unsigned int, Js::DynamicType*) /home/demorri/ChakraCore/lib/Runtime/Library/ArrayBuffer.cpp:673:9
#5 0x55762b3212fb in Js::JavascriptArrayBuffer::Create(unsigned int, Js::DynamicType*) /home/demorri/ChakraCore/lib/Runtime/Library/ArrayBuffer.cpp:688:41
#6 0x55762b58f4c4 in Js::JavascriptLibrary::CreateArrayBuffer(unsigned int) /home/demorri/ChakraCore/lib/Runtime/Library/JavascriptLibrary.cpp:6489:28
#7 0x55762bb3fbaa in Js::CreateBuffer(unsigned char const*, unsigned int, void*) /home/demorri/ChakraCore/lib/Runtime/Library/WabtInterface.cpp:99:66
#8 0x55762c25e5eb in create_module(ChakraWabt::Context*, wabt::Module const*, bool) /home/demorri/ChakraCore/lib/wabt/chakra/wabtapi.cc:279:12
#9 0x55762c260be5 in ChakraWabt::ConvertWast2Wasm(ChakraWabt::ChakraContext&, char*, unsigned int, bool) /home/demorri/ChakraCore/lib/wabt/chakra/wabtapi.cc:510:16
#10 0x55762bb41182 in Js::WabtInterface::EntryConvertWast2Wasm(Js::RecyclableObject*, Js::CallInfo, ...) /home/demorri/ChakraCore/lib/Runtime/Library/WabtInterface.cpp:166:24
#11 0x55762bb41f8d in amd64_CallFunction /home/demorri/ChakraCore/lib/Runtime/Library/amd64/JavascriptFunctionA.S:100
#12 0x55762b53786f in void* Js::JavascriptFunction::CallFunction(Js::RecyclableObject*, void* (*)(Js::RecyclableObject*, Js::CallInfo, ...), Js::Arguments, bool) /home/demorri/ChakraCore/lib/Runtime/Library/JavascriptFunction.cpp:1310:16
#13 0x55762b06d07d in void Js::InterpreterStackFrame::OP_CallCommon > > >(Js::OpLayoutDynamicProfile > > const*, Js::RecyclableObject*, unsigned int, Js::AuxArray const*) /home/demorri/ChakraCore/lib/Runtime/Language/InterpreterStackFrame.cpp:3885:50
#14 0x55762b06c2e2 in void Js::InterpreterStackFrame::OP_ProfileCallCommon > > >(Js::OpLayoutDynamicProfile > > const*, Js::RecyclableObject*, unsigned int, unsigned short, unsigned int, Js::AuxArray const*) /home/demorri/ChakraCore/lib/Runtime/Language/InterpreterStackFrame.cpp:3909:9
#15 0x55762afbef61 in void Js::InterpreterStackFrame::OP_ProfiledCallIWithICIndex > >(Js::OpLayoutDynamicProfile > > const*) /home/demorri/ChakraCore/lib/Runtime/./Language/InterpreterStackFrame.h:499:115
#16 0x55762ab98f0b in Js::InterpreterStackFrame::ProcessProfiled() /home/demorri/ChakraCore/lib/Runtime/Language/InterpreterHandler.inl:87:3
#17 0x55762aa70c9b in Js::InterpreterStackFrame::Process() /home/demorri/ChakraCore/lib/Runtime/Language/InterpreterStackFrame.cpp:3384:20
#18 0x55762aa6ed8c in Js::InterpreterStackFrame::InterpreterHelper(Js::ScriptFunction*, Js::ArgumentReader, void*, void*, Js::InterpreterStackFrame::AsmJsReturnStruct*) /home/demorri/ChakraCore/lib/Runtime/Language/InterpreterStackFrame.cpp:2002:40
#19 0x55762aa6c383 in Js::InterpreterStackFrame::InterpreterThunk(Js::JavascriptCallStackLayout*) /home/demorri/ChakraCore/lib/Runtime/Language/InterpreterStackFrame.cpp:1733:16
#20 0x7f80fd400f99 ()
#21 0x55762bb41f8d in amd64_CallFunction /home/demorri/ChakraCore/lib/Runtime/Library/amd64/JavascriptFunctionA.S:100
#22 0x55762b53786f in void* Js::JavascriptFunction::CallFunction(Js::RecyclableObject*, void* (*)(Js::RecyclableObject*, Js::CallInfo, ...), Js::Arguments, bool) /home/demorri/ChakraCore/lib/Runtime/Library/JavascriptFunction.cpp:1310:16
#23 0x55762b06d07d in void Js::InterpreterStackFrame::OP_CallCommon > > >(Js::OpLayoutDynamicProfile > > const*, Js::RecyclableObject*, unsigned int, Js::AuxArray const*) /home/demorri/ChakraCore/lib/Runtime/Language/InterpreterStackFrame.cpp:3885:50
#24 0x55762b06c2e2 in void Js::InterpreterStackFrame::OP_ProfileCallCommon > > >(Js::OpLayoutDynamicProfile > > const*, Js::RecyclableObject*, unsigned int, unsigned short, unsigned int, Js::AuxArray const*) /home/demorri/ChakraCore/lib/Runtime/Language/InterpreterStackFrame.cpp:3909:9
#25 0x55762afbef61 in void Js::InterpreterStackFrame::OP_ProfiledCallIWithICIndex > >(Js::OpLayoutDynamicProfile > > const*) /home/demorri/ChakraCore/lib/Runtime/./Language/InterpreterStackFrame.h:499:115
#26 0x55762ab98f0b in Js::InterpreterStackFrame::ProcessProfiled() /home/demorri/ChakraCore/lib/Runtime/Language/InterpreterHandler.inl:87:3
#27 0x55762aa70c9b in Js::InterpreterStackFrame::Process() /home/demorri/ChakraCore/lib/Runtime/Language/InterpreterStackFrame.cpp:3384:20
#28 0x55762aa6ed8c in Js::InterpreterStackFrame::InterpreterHelper(Js::ScriptFunction*, Js::ArgumentReader, void*, void*, Js::InterpreterStackFrame::AsmJsReturnStruct*) /home/demorri/ChakraCore/lib/Runtime/Language/InterpreterStackFrame.cpp:2002:40
#29 0x55762aa6c383 in Js::InterpreterStackFrame::InterpreterThunk(Js::JavascriptCallStackLayout*) /home/demorri/ChakraCore/lib/Runtime/Language/InterpreterStackFrame.cpp:1733:16

SUMMARY: AddressSanitizer: 258796 byte(s) leaked in 1 allocation(s).

----------------------------
exit code: 1
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.