https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113258
Bug ID: 113258 Summary: Pre-C++17 code that supplies operator new/delete crashes when mixed with post-C+17 code that uses the align_val_t variants of new/delete Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: nmiell at gmail dot com Target Milestone: --- Correctly functioning pre-C++17 applications that supply their own versions of operator new and delete as allowed by the standard crash when mixed with correctly functioning post-C++17 shared libraries that used the std::align_val_t variants of operator new/delete. This is typically the result of the libstdc++ version of operator delete(void* ptr, std::align_val_t alignment) calling the application-supplied version of operator delete(void* ptr), and the application-supplied allocator asserting or crashing because the original pointer was produced by the libstdc++ version of operator new(std::size_t size, std::align_val_t alignment) and not the application-supplied operator new(std::size_t size). This is both a regression and an ABI breakage. A typical stack trace looks like the following: thread #1, name = 'bms_linux', stop reason = signal SIGABRT * frame #0: 0xf7f69589 [vdso]`__kernel_vsyscall + 9 frame #1: 0xf7d5a2c7 libc.so.6`__pthread_kill_implementation + 279 frame #2: 0xf7d05fc5 libc.so.6`raise + 37 frame #3: 0xf7ced370 libc.so.6`abort + 242 frame #4: 0xf7ed7e8a libtcmalloc_minimal.so.4`tcmalloc::Log(mode=kCrash, filename="", line=278, a=LogItem @ 0xff92cd0c, b=LogItem @ 0xff92cd18, c=LogItem @ 0xff92cd24, d=LogItem @ 0xff92cd30) at internal_logging.cc:120 frame #5: 0xf7ed335d libtcmalloc_minimal.so.4`(anonymous namespace)::InvalidFree(ptr=0x0a5c7d00) at tcmalloc.cc:278 frame #6: 0xf7ee4762 libtcmalloc_minimal.so.4`::tc_free(void *) [inlined] free_null_or_invalid(ptr=0x0a5c7d00, invalid_free_fn=0x0000b2b0) at tcmalloc.cc:1141 frame #7: 0xf7ee4751 libtcmalloc_minimal.so.4`::tc_free(void *) at tcmalloc.cc:1185 frame #8: 0xf7ee4720 libtcmalloc_minimal.so.4`::tc_free(void *) at tcmalloc.cc:1225 frame #9: 0xf7ee4720 libtcmalloc_minimal.so.4`::tc_free(void *) [inlined] do_free(ptr=0x0a5c7d00) at tcmalloc.cc:1234 frame #10: 0xf7ee4720 libtcmalloc_minimal.so.4`tc_free(ptr=0x0a5c7d00) at tcmalloc.cc:1585 frame #11: 0xf7899f4c libstdc++.so.6`operator delete(void*, std::align_val_t) + 28 frame #12: 0xeaaac2c8 libLLVM-17.so`llvm::deallocate_buffer(void*, unsigned int, unsigned int) + 40 frame #13: 0xeacd0ef6 libLLVM-17.so`llvm::DenseMap<void const*, llvm::PassInfo const*, llvm::DenseMapInfo<void const*, void>, llvm::detail::DenseMapPair<void const*, llvm::PassInfo const*>>::grow(unsigned int) + 662 frame #14: 0xead0db09 libLLVM-17.so`llvm::detail::DenseMapPair<void const*, llvm::PassInfo const*>* llvm::DenseMapBase<llvm::DenseMap<void const*, llvm::PassInfo const*, llvm::DenseMapInfo<void const*, void>, llvm::detail::DenseMapPair<void const*, llvm::PassInfo const*>>, void const*, llvm::PassInfo const*, llvm::DenseMapInfo<void const*, void>, llvm::detail::DenseMapPair<void const*, llvm::PassInfo const*>>::InsertIntoBucket<void const*, llvm::PassInfo const*>(llvm::detail::DenseMapPair<void const*, llvm::PassInfo const*>*, void const*&&, llvm::PassInfo const*&&) + 121 frame #15: 0xead0d1fb libLLVM-17.so`llvm::PassRegistry::registerPass(llvm::PassInfo const&, bool) + 283 frame #16: 0xed0e209a libLLVM-17.so`initializeSIFoldOperandsPassOnce(llvm::PassRegistry&) + 138 frame #17: 0xeac6f832 libLLVM-17.so`std::once_flag::_Prepare_execution::_Prepare_execution<void std::call_once<void* (&)(llvm::PassRegistry&), std::reference_wrapper<llvm::PassRegistry>>(std::once_flag&, void* (&)(llvm::PassRegistry&), std::reference_wrapper<llvm::PassRegistry>&&)::'lambda'()>(void* (&)(llvm::PassRegistry&))::'lambda'()::__invoke() + 50 frame #18: 0xf7d5d4da libc.so.6`__pthread_once_slow + 250 frame #19: 0xed0e1fd2 libLLVM-17.so`llvm::initializeSIFoldOperandsPass(llvm::PassRegistry&) + 130 frame #20: 0xed042916 libLLVM-17.so`LLVMInitializeAMDGPUTarget + 166 frame #21: 0xf238c8c7 radeonsi_dri.so`ac_init_llvm_target + 71 frame #22: 0xf7d5d4da libc.so.6`__pthread_once_slow + 250 frame #23: 0xf1ae26c0 radeonsi_dri.so`call_once + 32 frame #24: 0xf238c946 radeonsi_dri.so`ac_init_shared_llvm_once + 38 frame #25: 0xf238c968 radeonsi_dri.so`ac_init_llvm_once + 24 etc.