Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory Leak in VSG #1325

Open
rainergericke opened this issue Nov 9, 2024 · 4 comments
Open

Memory Leak in VSG #1325

rainergericke opened this issue Nov 9, 2024 · 4 comments

Comments

@rainergericke
Copy link
Contributor

Programs using VSG show a memory leak, when screenshots made repeatedly like you have in simulation software when you want to create a movie. This was first recognized on Windows 11 but also happens on macOS. The screenshot function is identical to the one in vsgscreenshot.

To Reproduce
The steadily increasing demand of memory can be seen using the top terminal command.
Better on macOS (use clang++ 19.3.1):
build vsg & Co. in debug mode with
-DCMAKE_CXX_FLAGS="-g -fsanitize=leak"

Expected behavior
Dynamicly allocated memory should be released.

Desktop:

  • OS: macOS 15.0.1, Windows 11

VSG examples show a leak problem when executed.
rainerge@RainersacStudio bin % vsgvolume
vsgvolume(22519,0x1f134f240) malloc: nano zone abandoned due to inability to reserve vm space.
LeakSanitizer: bad pointer 0x864b741d53be6962
LeakSanitizer: CHECK failed: sanitizer_allocator_secondary.h:177 "((IsAligned(reinterpret_cast(p), page_size
))) != (0)" (0x0, 0x0) (tid=127719)_
zsh: abort vsgvolume

rainerge@RainersacStudio bin % vsgscreenshot
_vsgscreenshot(22487,0x1f134f240) malloc: nano zone abandoned due to inability to reserve vm space.
Please specify a valid 3d model file on the command line.
LeakSanitizer:DEADLYSIGNAL
==22487==ERROR: LeakSanitizer: BUS on unknown address (pc 0x000105024dc0 bp 0x00016b6a2770 sp 0x00016b6a2750 T0)
==22487==The signal is caused by a READ memory access.
==22487==Hint: this fault was caused by a dereference of a high value address (see register values below). Disassemble the provided pc to learn which register was used.
#0 0x000105024dc0 in __sanitizer::LargeMmapAllocator<__sanitizer::NoOpMapUnmapCallback, __sanitizer::LargeMmapAllocatorPtrArrayDynamic, __sanitizer::LocalAddressSpaceView>::Deallocate(__sanitizer::AllocatorStats*, void*)+0x44 (libclang_rt.lsan_osx_dynamic.dylib:arm64+0x2cdc0)
#1 0x0001071fb1fc in vsg::IntrusiveAllocator::MemoryBlock::~MemoryBlock()+0x30 (libvsgd.1.1.8.dylib:arm64+0x71fc)
#2 0x0001071fb240 in vsg::IntrusiveAllocator::MemoryBlock::~MemoryBlock()+0x18 (libvsgd.1.1.8.dylib:arm64+0x7240)
#3 0x000107207b7c in std::__1::allocatorvsg::IntrusiveAllocator::MemoryBlock::destroyabi:ne180100+0x20 (libvsgd.1.1.8.dylib:arm64+0x13b7c)
#4 0x000107207b4c in void std::__1::allocator_traits<std::__1::allocatorvsg::IntrusiveAllocator::MemoryBlock>::destroy[abi:ne180100]<vsg::IntrusiveAllocator::MemoryBlock, void>(std::__1::allocatorvsg::IntrusiveAllocator::MemoryBlock&, vsg::IntrusiveAllocator::MemoryBlock*)+0x1c (libvsgd.1.1.8.dylib:arm64+0x13b4c)
#5 0x000107207b18 in void std::__1::__shared_ptr_emplace<vsg::IntrusiveAllocator::MemoryBlock, std::__1::allocatorvsg::IntrusiveAllocator::MemoryBlock>::__on_zero_shared_impl[abi:ne180100]<std::__1::allocatorvsg::IntrusiveAllocator::MemoryBlock, 0>()+0x2c (libvsgd.1.1.8.dylib:arm64+0x13b18)
#6 0x000107207914 in std::__1::__shared_ptr_emplace<vsg::IntrusiveAllocator::MemoryBlock, std::__1::allocatorvsg::IntrusiveAllocator::MemoryBlock>::__on_zero_shared()+0x14 (libvsgd.1.1.8.dylib:arm64+0x13914)
#7 0x000107206f58 in std::__1::__shared_count::__release_sharedabi:ne180100+0x38 (libvsgd.1.1.8.dylib:arm64+0x12f58)
#8 0x000107206efc in std::__1::__shared_weak_count::__release_sharedabi:ne180100+0x18 (libvsgd.1.1.8.dylib:arm64+0x12efc)
#9 0x000107206ecc in std::__1::shared_ptrvsg::IntrusiveAllocator::MemoryBlock::~shared_ptrabi:ne180100+0x34 (libvsgd.1.1.8.dylib:arm64+0x12ecc)
#10 0x0001071fe7e8 in std::__1::shared_ptrvsg::IntrusiveAllocator::MemoryBlock::~shared_ptrabi:ne180100+0x18 (libvsgd.1.1.8.dylib:arm64+0xa7e8)
#11 0x000107206db0 in std::__1::allocator<std::__1::shared_ptrvsg::IntrusiveAllocator::MemoryBlock>::destroyabi:ne180100+0x18 (libvsgd.1.1.8.dylib:arm64+0x12db0)
#12 0x000107206d74 in void std::__1::allocator_traits<std::__1::allocator<std::__1::shared_ptrvsg::IntrusiveAllocator::MemoryBlock>>::destroy[abi:ne180100]<std::__1::shared_ptrvsg::IntrusiveAllocator::MemoryBlock, void>(std::__1::allocator<std::__1::shared_ptrvsg::IntrusiveAllocator::MemoryBlock>&, std::__1::shared_ptrvsg::IntrusiveAllocator::MemoryBlock)+0x1c (libvsgd.1.1.8.dylib:arm64+0x12d74)
#13 0x000107206d30 in std::__1::vector<std::__1::shared_ptrvsg::IntrusiveAllocator::MemoryBlock, std::__1::allocator<std::__1::shared_ptrvsg::IntrusiveAllocator::MemoryBlock>>::__base_destruct_at_endabi:ne180100+0x60 (libvsgd.1.1.8.dylib:arm64+0x12d30)
#14 0x000107206c14 in std::__1::vector<std::__1::shared_ptrvsg::IntrusiveAllocator::MemoryBlock, std::__1::allocator<std::__1::shared_ptrvsg::IntrusiveAllocator::MemoryBlock>>::__clearabi:ne180100+0x18 (libvsgd.1.1.8.dylib:arm64+0x12c14)
#15 0x000107206b84 in std::__1::vector<std::__1::shared_ptrvsg::IntrusiveAllocator::MemoryBlock, std::__1::allocator<std::__1::shared_ptrvsg::IntrusiveAllocator::MemoryBlock>>::__destroy_vector::operator()abi:ne180100+0x30 (libvsgd.1.1.8.dylib:arm64+0x12b84)
#16 0x000107206b04 in std::__1::vector<std::__1::shared_ptrvsg::IntrusiveAllocator::MemoryBlock, std::__1::allocator<std::__1::shared_ptrvsg::IntrusiveAllocator::MemoryBlock>>::~vectorabi:ne180100+0x28 (libvsgd.1.1.8.dylib:arm64+0x12b04)
#17 0x0001071fe814 in std::__1::vector<std::__1::shared_ptrvsg::IntrusiveAllocator::MemoryBlock, std::__1::allocator<std::__1::shared_ptrvsg::IntrusiveAllocator::MemoryBlock>>::~vectorabi:ne180100+0x18 (libvsgd.1.1.8.dylib:arm64+0xa814)
#18 0x0001071fe7b0 in vsg::IntrusiveAllocator::MemoryBlocks::~MemoryBlocks()+0x38 (libvsgd.1.1.8.dylib:arm64+0xa7b0)
#19 0x0001071fe840 in vsg::IntrusiveAllocator::MemoryBlocks::~MemoryBlocks()+0x18 (libvsgd.1.1.8.dylib:arm64+0xa840)
#20 0x0001071fe86c in vsg::IntrusiveAllocator::MemoryBlocks::~MemoryBlocks()+0x18 (libvsgd.1.1.8.dylib:arm64+0xa86c)
#21 0x00010720ca9c in std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks::operator()abi:ne180100 const+0x30 (libvsgd.1.1.8.dylib:arm64+0x18a9c)
#22 0x0001071ffa4c in std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>::resetabi:ne180100+0x5c (libvsgd.1.1.8.dylib:arm64+0xba4c)
#23 0x00010720acb8 in std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>::~unique_ptrabi:ne180100+0x1c (libvsgd.1.1.8.dylib:arm64+0x16cb8)
#24 0x00010720ac88 in std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>::~unique_ptrabi:ne180100+0x18 (libvsgd.1.1.8.dylib:arm64+0x16c88)
#25 0x00010720ac60 in std::__1::allocator<std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>>::destroy[abi:ne180100](std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>
)+0x18 (libvsgd.1.1.8.dylib:arm64+0x16c60)
#26 0x00010720ac24 in void std::__1::allocator_traits<std::__1::allocator<std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>>>::destroy[abi:ne180100]<std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>, void>(std::__1::allocator<std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>>&, std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>)+0x1c (libvsgd.1.1.8.dylib:arm64+0x16c24)
#27 0x00010720abe0 in std::__1::vector<std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>, std::__1::allocator<std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>>>::__base_destruct_at_end[abi:ne180100](std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>
)+0x60 (libvsgd.1.1.8.dylib:arm64+0x16be0)
#28 0x00010720aac4 in std::__1::vector<std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>, std::__1::allocator<std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>>>::__clearabi:ne180100+0x18 (libvsgd.1.1.8.dylib:arm64+0x16ac4)
#29 0x00010720aa34 in std::__1::vector<std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>, std::__1::allocator<std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>>>::__destroy_vector::operator()abi:ne180100+0x30 (libvsgd.1.1.8.dylib:arm64+0x16a34)
#30 0x00010720a9b4 in std::__1::vector<std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>, std::__1::allocator<std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>>>::~vectorabi:ne180100+0x28 (libvsgd.1.1.8.dylib:arm64+0x169b4)
#31 0x0001071ffb04 in std::__1::vector<std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>, std::__1::allocator<std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>>>::~vectorabi:ne180100+0x18 (libvsgd.1.1.8.dylib:arm64+0xbb04)
#32 0x000107200160 in vsg::IntrusiveAllocator::~IntrusiveAllocator()+0x44 (libvsgd.1.1.8.dylib:arm64+0xc160)
#33 0x000107200194 in vsg::IntrusiveAllocator::~IntrusiveAllocator()+0x18 (libvsgd.1.1.8.dylib:arm64+0xc194)
#34 0x0001072001c0 in vsg::IntrusiveAllocator::~IntrusiveAllocator()+0x18 (libvsgd.1.1.8.dylib:arm64+0xc1c0)
#35 0x0001071faa80 in std::__1::default_deletevsg::Allocator::operator()abi:ne180100 const+0x30 (libvsgd.1.1.8.dylib:arm64+0x6a80)
#36 0x0001071fa9f4 in std::__1::unique_ptr<vsg::Allocator, std::__1::default_deletevsg::Allocator>::resetabi:ne180100+0x5c (libvsgd.1.1.8.dylib:arm64+0x69f4)
#37 0x0001071fa984 in std::__1::unique_ptr<vsg::Allocator, std::__1::default_deletevsg::Allocator>::~unique_ptrabi:ne180100+0x1c (libvsgd.1.1.8.dylib:arm64+0x6984)
#38 0x0001071fa8b4 in std::__1::unique_ptr<vsg::Allocator, std::__1::default_deletevsg::Allocator>::~unique_ptrabi:ne180100+0x18 (libvsgd.1.1.8.dylib:arm64+0x68b4)
#39 0x00018caca994 in __cxa_finalize_ranges+0x1d8 (libsystem_c.dylib:arm64+0x28994)
#40 0x00018caca758 in exit+0x28 (libsystem_c.dylib:arm64+0x28758)
#41 0x00018cc32948 in dyld4::LibSystemHelpers::exit(int) const+0x10 (libdyld.dylib:arm64+0x1d948)
#42 0x00018c88c2c4 ()

==22487==Register values:
x[0] = 0x000000010598b990 x[1] = 0x000000010598b998 x[2] = 0x0000000120008000 x[3] = 0x0000000000000000
x[4] = 0x0000000105f01a80 x[5] = 0x0000000000000080 x[6] = 0x000000000000000a x[7] = 0x0000000000000001
x[8] = 0x0000000000000000 x[9] = 0x0000000109400000 x[10] = 0x0000000105f01c80 x[11] = 0x0000000000000000
x[12] = 0x000000000000003a x[13] = 0x0000000000000000 x[14] = 0x000000016b6a2aac x[15] = 0x00006090000018d8
x[16] = 0x000000018cc0a16c x[17] = 0x00000001f9528c10 x[18] = 0x0000000000000000 x[19] = 0x0000000120004000
x[20] = 0x000000010598b728 x[21] = 0x000000010598b998 x[22] = 0x0000619000001e00 x[23] = 0x0000000000000000
x[24] = 0x0000000000000008 x[25] = 0x00000001f1358000 x[26] = 0x0000000000000017 x[27] = 0x0000000000000016
x[28] = 0x0000000000000016 fp = 0x000000016b6a2770 lr = 0x00000001071fb200 sp = 0x000000016b6a2750
LeakSanitizer can not provide additional info.
SUMMARY: LeakSanitizer: BUS (libvsgd.1.1.8.dylib:arm64+0x71fc) in vsg::IntrusiveAllocator::MemoryBlock::~MemoryBlock()+0x30
==22487==ABORTING
zsh: abort vsgscreenshot
rainerge@RainersacStudio bin % vsgvolume
vsgvolume(22519,0x1f134f240) malloc: nano zone abandoned due to inability to reserve vm space.
LeakSanitizer: bad pointer 0x864b741d53be6962
LeakSanitizer: CHECK failed: sanitizer_allocator_secondary.h:177 "((IsAligned(reinterpret_cast(p), page_size_))) != (0)" (0x0, 0x0) (tid=127719)
zsh: abort vsgvolume
rainerge@RainersacStudio bin % vsgtransform
vsgtransform(22520,0x1f134f240) malloc: nano zone abandoned due to inability to reserve vm space.
Please specify model to load on command line.
LeakSanitizer:DEADLYSIGNAL
==22520==ERROR: LeakSanitizer: BUS on unknown address (pc 0x0001048a8dc0 bp 0x00016bdb6780 sp 0x00016bdb6760 T0)
==22520==The signal is caused by a READ memory access.
==22520==Hint: this fault was caused by a dereference of a high value address (see register values below). Disassemble the provided pc to learn which register was used.
#0 0x0001048a8dc0 in __sanitizer::LargeMmapAllocator<__sanitizer::NoOpMapUnmapCallback, __sanitizer::LargeMmapAllocatorPtrArrayDynamic, __sanitizer::LocalAddressSpaceView>::Deallocate(__sanitizer::AllocatorStats*, void*)+0x44 (libclang_rt.lsan_osx_dynamic.dylib:arm64+0x2cdc0)
#1 0x000106a7f1fc in vsg::IntrusiveAllocator::MemoryBlock::~MemoryBlock()+0x30 (libvsgd.1.1.8.dylib:arm64+0x71fc)
#2 0x000106a7f240 in vsg::IntrusiveAllocator::MemoryBlock::~MemoryBlock()+0x18 (libvsgd.1.1.8.dylib:arm64+0x7240)
#3 0x000106a8bb7c in std::__1::allocatorvsg::IntrusiveAllocator::MemoryBlock::destroyabi:ne180100+0x20 (libvsgd.1.1.8.dylib:arm64+0x13b7c)
#4 0x000106a8bb4c in void std::__1::allocator_traits<std::__1::allocatorvsg::IntrusiveAllocator::MemoryBlock>::destroy[abi:ne180100]<vsg::IntrusiveAllocator::MemoryBlock, void>(std::__1::allocatorvsg::IntrusiveAllocator::MemoryBlock&, vsg::IntrusiveAllocator::MemoryBlock*)+0x1c (libvsgd.1.1.8.dylib:arm64+0x13b4c)
#5 0x000106a8bb18 in void std::__1::__shared_ptr_emplace<vsg::IntrusiveAllocator::MemoryBlock, std::__1::allocatorvsg::IntrusiveAllocator::MemoryBlock>::__on_zero_shared_impl[abi:ne180100]<std::__1::allocatorvsg::IntrusiveAllocator::MemoryBlock, 0>()+0x2c (libvsgd.1.1.8.dylib:arm64+0x13b18)
#6 0x000106a8b914 in std::__1::__shared_ptr_emplace<vsg::IntrusiveAllocator::MemoryBlock, std::__1::allocatorvsg::IntrusiveAllocator::MemoryBlock>::__on_zero_shared()+0x14 (libvsgd.1.1.8.dylib:arm64+0x13914)
#7 0x000106a8af58 in std::__1::__shared_count::__release_sharedabi:ne180100+0x38 (libvsgd.1.1.8.dylib:arm64+0x12f58)
#8 0x000106a8aefc in std::__1::__shared_weak_count::__release_sharedabi:ne180100+0x18 (libvsgd.1.1.8.dylib:arm64+0x12efc)
#9 0x000106a8aecc in std::__1::shared_ptrvsg::IntrusiveAllocator::MemoryBlock::~shared_ptrabi:ne180100+0x34 (libvsgd.1.1.8.dylib:arm64+0x12ecc)
#10 0x000106a827e8 in std::__1::shared_ptrvsg::IntrusiveAllocator::MemoryBlock::~shared_ptrabi:ne180100+0x18 (libvsgd.1.1.8.dylib:arm64+0xa7e8)
#11 0x000106a8adb0 in std::__1::allocator<std::__1::shared_ptrvsg::IntrusiveAllocator::MemoryBlock>::destroyabi:ne180100+0x18 (libvsgd.1.1.8.dylib:arm64+0x12db0)
#12 0x000106a8ad74 in void std::__1::allocator_traits<std::__1::allocator<std::__1::shared_ptrvsg::IntrusiveAllocator::MemoryBlock>>::destroy[abi:ne180100]<std::__1::shared_ptrvsg::IntrusiveAllocator::MemoryBlock, void>(std::__1::allocator<std::__1::shared_ptrvsg::IntrusiveAllocator::MemoryBlock>&, std::__1::shared_ptrvsg::IntrusiveAllocator::MemoryBlock)+0x1c (libvsgd.1.1.8.dylib:arm64+0x12d74)
#13 0x000106a8ad30 in std::__1::vector<std::__1::shared_ptrvsg::IntrusiveAllocator::MemoryBlock, std::__1::allocator<std::__1::shared_ptrvsg::IntrusiveAllocator::MemoryBlock>>::__base_destruct_at_endabi:ne180100+0x60 (libvsgd.1.1.8.dylib:arm64+0x12d30)
#14 0x000106a8ac14 in std::__1::vector<std::__1::shared_ptrvsg::IntrusiveAllocator::MemoryBlock, std::__1::allocator<std::__1::shared_ptrvsg::IntrusiveAllocator::MemoryBlock>>::__clearabi:ne180100+0x18 (libvsgd.1.1.8.dylib:arm64+0x12c14)
#15 0x000106a8ab84 in std::__1::vector<std::__1::shared_ptrvsg::IntrusiveAllocator::MemoryBlock, std::__1::allocator<std::__1::shared_ptrvsg::IntrusiveAllocator::MemoryBlock>>::__destroy_vector::operator()abi:ne180100+0x30 (libvsgd.1.1.8.dylib:arm64+0x12b84)
#16 0x000106a8ab04 in std::__1::vector<std::__1::shared_ptrvsg::IntrusiveAllocator::MemoryBlock, std::__1::allocator<std::__1::shared_ptrvsg::IntrusiveAllocator::MemoryBlock>>::~vectorabi:ne180100+0x28 (libvsgd.1.1.8.dylib:arm64+0x12b04)
#17 0x000106a82814 in std::__1::vector<std::__1::shared_ptrvsg::IntrusiveAllocator::MemoryBlock, std::__1::allocator<std::__1::shared_ptrvsg::IntrusiveAllocator::MemoryBlock>>::~vectorabi:ne180100+0x18 (libvsgd.1.1.8.dylib:arm64+0xa814)
#18 0x000106a827b0 in vsg::IntrusiveAllocator::MemoryBlocks::~MemoryBlocks()+0x38 (libvsgd.1.1.8.dylib:arm64+0xa7b0)
#19 0x000106a82840 in vsg::IntrusiveAllocator::MemoryBlocks::~MemoryBlocks()+0x18 (libvsgd.1.1.8.dylib:arm64+0xa840)
#20 0x000106a8286c in vsg::IntrusiveAllocator::MemoryBlocks::~MemoryBlocks()+0x18 (libvsgd.1.1.8.dylib:arm64+0xa86c)
#21 0x000106a90a9c in std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks::operator()abi:ne180100 const+0x30 (libvsgd.1.1.8.dylib:arm64+0x18a9c)
#22 0x000106a83a4c in std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>::resetabi:ne180100+0x5c (libvsgd.1.1.8.dylib:arm64+0xba4c)
#23 0x000106a8ecb8 in std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>::~unique_ptrabi:ne180100+0x1c (libvsgd.1.1.8.dylib:arm64+0x16cb8)
#24 0x000106a8ec88 in std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>::~unique_ptrabi:ne180100+0x18 (libvsgd.1.1.8.dylib:arm64+0x16c88)
#25 0x000106a8ec60 in std::__1::allocator<std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>>::destroy[abi:ne180100](std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>
)+0x18 (libvsgd.1.1.8.dylib:arm64+0x16c60)
#26 0x000106a8ec24 in void std::__1::allocator_traits<std::__1::allocator<std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>>>::destroy[abi:ne180100]<std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>, void>(std::__1::allocator<std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>>&, std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>)+0x1c (libvsgd.1.1.8.dylib:arm64+0x16c24)
#27 0x000106a8ebe0 in std::__1::vector<std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>, std::__1::allocator<std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>>>::__base_destruct_at_end[abi:ne180100](std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>
)+0x60 (libvsgd.1.1.8.dylib:arm64+0x16be0)
#28 0x000106a8eac4 in std::__1::vector<std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>, std::__1::allocator<std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>>>::__clearabi:ne180100+0x18 (libvsgd.1.1.8.dylib:arm64+0x16ac4)
#29 0x000106a8ea34 in std::__1::vector<std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>, std::__1::allocator<std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>>>::__destroy_vector::operator()abi:ne180100+0x30 (libvsgd.1.1.8.dylib:arm64+0x16a34)
#30 0x000106a8e9b4 in std::__1::vector<std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>, std::__1::allocator<std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>>>::~vectorabi:ne180100+0x28 (libvsgd.1.1.8.dylib:arm64+0x169b4)
#31 0x000106a83b04 in std::__1::vector<std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>, std::__1::allocator<std::__1::unique_ptr<vsg::IntrusiveAllocator::MemoryBlocks, std::__1::default_deletevsg::IntrusiveAllocator::MemoryBlocks>>>::~vectorabi:ne180100+0x18 (libvsgd.1.1.8.dylib:arm64+0xbb04)
#32 0x000106a84160 in vsg::IntrusiveAllocator::~IntrusiveAllocator()+0x44 (libvsgd.1.1.8.dylib:arm64+0xc160)
#33 0x000106a84194 in vsg::IntrusiveAllocator::~IntrusiveAllocator()+0x18 (libvsgd.1.1.8.dylib:arm64+0xc194)
#34 0x000106a841c0 in vsg::IntrusiveAllocator::~IntrusiveAllocator()+0x18 (libvsgd.1.1.8.dylib:arm64+0xc1c0)
#35 0x000106a7ea80 in std::__1::default_deletevsg::Allocator::operator()abi:ne180100 const+0x30 (libvsgd.1.1.8.dylib:arm64+0x6a80)
#36 0x000106a7e9f4 in std::__1::unique_ptr<vsg::Allocator, std::__1::default_deletevsg::Allocator>::resetabi:ne180100+0x5c (libvsgd.1.1.8.dylib:arm64+0x69f4)
#37 0x000106a7e984 in std::__1::unique_ptr<vsg::Allocator, std::__1::default_deletevsg::Allocator>::~unique_ptrabi:ne180100+0x1c (libvsgd.1.1.8.dylib:arm64+0x6984)
#38 0x000106a7e8b4 in std::__1::unique_ptr<vsg::Allocator, std::__1::default_deletevsg::Allocator>::~unique_ptrabi:ne180100+0x18 (libvsgd.1.1.8.dylib:arm64+0x68b4)
#39 0x00018caca994 in __cxa_finalize_ranges+0x1d8 (libsystem_c.dylib:arm64+0x28994)
#40 0x00018caca758 in exit+0x28 (libsystem_c.dylib:arm64+0x28758)
#41 0x00018cc32948 in dyld4::LibSystemHelpers::exit(int) const+0x10 (libdyld.dylib:arm64+0x1d948)
#42 0x00018c88c2c4 ()

==22520==Register values:
x[0] = 0x000000010520f990 x[1] = 0x000000010520f998 x[2] = 0x0000000150008000 x[3] = 0x0000000000000000
x[4] = 0x0000000105801a80 x[5] = 0x0000000000000080 x[6] = 0x000000000000000a x[7] = 0x0000000000000001
x[8] = 0x0000000000000000 x[9] = 0x0000000108c84000 x[10] = 0x0000000105801c80 x[11] = 0x0000000000000000
x[12] = 0x0000000000000038 x[13] = 0x0000000000000000 x[14] = 0x000000016bdb6abc x[15] = 0x00006090000018d8
x[16] = 0x000000018cc0a16c x[17] = 0x00000001f9528c10 x[18] = 0x0000000000000000 x[19] = 0x0000000150004000
x[20] = 0x000000010520f728 x[21] = 0x000000010520f998 x[22] = 0x0000619000001e00 x[23] = 0x0000000000000000
x[24] = 0x0000000000000008 x[25] = 0x00000001f1358000 x[26] = 0x0000000000000017 x[27] = 0x0000000000000016
x[28] = 0x0000000000000016 fp = 0x000000016bdb6780 lr = 0x0000000106a7f200 sp = 0x000000016bdb6760
LeakSanitizer can not provide additional info.
SUMMARY: LeakSanitizer: BUS (libvsgd.1.1.8.dylib:arm64+0x71fc) in vsg::IntrusiveAllocator::MemoryBlock::~MemoryBlock()+0x30
==22520==ABORTING
zsh: abort vsgtransform_

The macOS clang++ system compiler does not support the leak sanitizer, the llvm clang++ compiler must be used.
Script to build VSG with the nessecary parameters:
m_bleed_d_sh.txt

@AnyOldName3
Copy link
Contributor

You probably want to put three backticks ` on the line before and after your backtrace so GitHub doesn't interpret it as Markdown and turn a bunch of characters into formatting and links. It'll be much easier to read that way.

@rainergericke
Copy link
Contributor Author

I have a workaround for the memory leak problem. It seems vsg::ref_ptr<vsg::Data> imageData causes the leak. Avoiding any use of imageData in this context removes the leak problem.

@AnyOldName3
Copy link
Contributor

That's a ref_ptr, so like std::smart_ptr, while there are still some around that point to something, it won't be deleted. If you've done everything exactly like the screenshot example, then these vsg::ref_ptr<vsg::Data>s are stack-allocated, and go out of scope quickly, so should tidy themselves up. If you're doing anything differently that would extend their storage duration, they'll obviously stay around for longer.

All that said, the leak sanitiser won't work with the VSG's allocator as it only sees when whole memory blocks are allocated and freed, not individual objects, and memory blocks won't be freed until you explicitly call vsg::Allocator::instance()->deleteEmptyMemoryBlocks() as it's typically faster to reuse them.

@rainergericke
Copy link
Contributor Author

Thanks for the info about the leak sanitizer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants