chakra-core / chakra-core/ChakraCore
memory leak from ChakraCore/lib/Common/Memory/HeapAllocator.cpp
- Dominant language
- JavaScript
- Stars
- 9.3k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
Following code can trigger memory leak bug.
```
typeof new Promise(Intl.DateTimeFormat,null);
typeof new Promise(Intl.DateTimeFormat,null);
typeof new Promise(Intl.DateTimeFormat,null);
typeof new Promise(Intl.DateTimeFormat,null);
typeof new Promise(Intl.DateTimeFormat,null);
typeof new Promise(Intl.DateTimeFormat,null);
typeof new Promise(Intl.DateTimeFormat,null);
typeof new Promise(Intl.DateTimeFormat,null);
typeof Intl.DateTimeFormat();
```
ASAN report:
```
=================================================================
==41022==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 32 byte(s) in 4 object(s) allocated from:
#0 0x55bf22ed9b30 in malloc (ChakraCore/out/Test/ch+0x47ab30)
#1 0x55bf231a2788 in char* Memory::HeapAllocator::AllocT(unsigned long) ChakraCore/lib/Common/Memory/HeapAllocator.cpp:86:30
#2 0x55bf244b119c in Memory::HeapAllocator::Alloc(unsigned long) ChakraCore/lib/Common/Memory/HeapAllocator.h:153:16
#3 0x55bf244b119c in Memory::HeapAllocator::AllocZero(unsigned long) ChakraCore/lib/Common/Memory/HeapAllocator.h:171
#4 0x55bf244b119c in void* operator new(unsigned long, Memory::HeapAllocator*, char* (Memory::HeapAllocator::*)(unsigned long)) ChakraCore/lib/Common/DataStructures/../Memory/Allocator.h:486
#5 0x55bf244b119c in NativeCodeGenerator::CodeGen(Memory::PageAllocatorBase, Memory::PageSegmentBase >*, CodeGenWorkItem*, bool) ChakraCore/lib/Backend/NativeCodeGenerator.cpp:1137
#6 0x55bf244b3d4d in NativeCodeGenerator::Process(JsUtil::Job*, JsUtil::ParallelThreadData*) ChakraCore/lib/Backend/NativeCodeGenerator.cpp:1867:30
#7 0x55bf244ef74b in JsUtil::BackgroundJobProcessor::Process(JsUtil::Job*, JsUtil::ParallelThreadData*) ChakraCore/lib/Common/Common/Jobs.cpp:1037:36
#8 0x55bf244efb50 in JsUtil::BackgroundJobProcessor::Run(JsUtil::ParallelThreadData*) ChakraCore/lib/Common/Common/Jobs.cpp:1135:44
#9 0x55bf244eb761 in JsUtil::BackgroundJobProcessor::StaticThreadProc(void*) ChakraCore/lib/Common/Common/Jobs.cpp:1319:20
#10 0x55bf22ffcae8 in CorUnix::CPalThread::ThreadEntry(void*) ChakraCore/pal/src/thread/pal_thread.cpp:1605:16
#11 0x55bf22ee775e in __asan::AsanThread::ThreadStart(unsigned long, __sanitizer::atomic_uintptr_t*) (ChakraCore/out/Test/ch+0x48875e)
SUMMARY: AddressSanitizer: 32 byte(s) leaked in 4 allocation(s).
```
OS: Ubuntu 18.04.1 LTS
Arch: x86_64
Options: --static --test-build --sanitize=address
Contributor guide
Assessment
This issue has not been assessed yet.