Date: Thu, 06 Jun 2024 18:51:24 +0000 From: bugzilla-noreply@freebsd.org To: standards@FreeBSD.org Subject: [Bug 279560] FreeBSD 14.1 ships libc++ which passes wrong size to sized operator delete Message-ID: <bug-279560-99@https.bugs.freebsd.org/bugzilla/>
next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D279560 Bug ID: 279560 Summary: FreeBSD 14.1 ships libc++ which passes wrong size to sized operator delete Product: Base System Version: 14.0-RELEASE Hardware: Any OS: Any Status: New Severity: Affects Many People Priority: --- Component: standards Assignee: standards@FreeBSD.org Reporter: alkondratenko@gmail.com Hi. I maintain gperftools (https://github.com/gperftools/gperftools). I not= iced announcement of release of 14.1 and installed it in VM. When I run gperftoo= ls unit tests "debug" configurations pretty much ~all fail due to mismatch bet= ween requested allocation size and allocation size passed to sized delete. It should be straighforward to reproduce by simply git cloning from github = and running ./autogen.sh && ./configure && make check I don't have capacity to investigate more, but I have backtrace of allocati= on: #0 MallocBlock::Initialize (this=3Dthis@entry=3D0xc480f0, size=3Dsize@entr= y=3D25, type=3Dtype@entry=3D-21308287) at src/debugallocation.cc:382 #1 0x0000000000225e4c in MallocBlock::Allocate (size=3Dsize@entry=3D25, type=3D-21308287) at src/debugallocation.cc:560 #2 0x00000000002245d1 in DebugAllocate (size=3D25, type=3Dtype@entry=3D-21= 308287) at src/debugallocation.cc:1051 #3 0x000000000026eff4 in debug_cpp_alloc (size=3D12878064, new_type=3D-213= 08287, nothrow=3Dfalse) at src/debugallocation.cc:1220 #4 tc_new (size=3D12878064) at src/debugallocation.cc:1328 #5 0x0000000000256edd in std::__1::__libcpp_operator_new[abi:se180100]<unsigned long>(unsigned long) (__args=3D25) at /usr/include/c++/v1/new:271 #6 std::__1::__libcpp_allocate[abi:se180100](unsigned long, unsigned long) (__size=3D25, __align=3D1) at /usr/include/c++/v1/new:295 #7 std::__1::allocator<char>::allocate[abi:se180100](unsigned long) (this=3D0x7fffffffd878, __n=3D25) at /usr/include/c++/v1/__memory/allocator= .h:125 #8 std::__1::__allocate_at_least[abi:se180100]<std::__1::allocator<char> >(std::__1::allocator<char>&, unsigned long) (__alloc=3D..., __n=3D25) at /usr/include/c++/v1/__memory/allocate_at_least.h:55 #9 std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__init (this=3D0x7fffffffd878, __sz=3D23, __s=3D<optimized out>) at /usr/include/c++/v1/string:2212 #10 _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2B8se180100= ILi0EEEPKc (this=3D0x7fffffffd878, __s=3D<optimized out>) at /usr/include/c++/v1/strin= g:954 #11 testing::internal::UnitTestImpl::GetTestSuite (this=3D0xc50020, test_suite_name=3D0xc4e021 "MallocExtensionTest", type_param=3D0x0, set_up_tc=3Dset_up_tc@entry=3D0x0,=20 tear_down_tc=3Dtear_down_tc@entry=3D0x0) at vendor/googletest/googletest/src/gtest.cc:5786 #12 0x000000000025d7d2 in testing::internal::UnitTestImpl::AddTestInfo (this=3D<optimized out>, set_up_tc=3D0x0, tear_down_tc=3D0x0, test_info=3Dtest_info@entry=3D0xc4e020) at ./vendor/googletest/googletest/src/gtest-internal-inl.h:690 #13 0x0000000000242ba3 in testing::internal::MakeAndRegisterTestInfo (test_suite_name=3D<optimized out>, name=3D0x209287 "Basics", type_param=3Dtype_param@entry=3D0x0,=20 value_param=3Dvalue_param@entry=3D0x0, code_location=3D..., fixture_class_id=3Dfixture_class_id@entry=3D0x4237f1 <testing::internal::TypeIdHelper<testing::Test>::dummy_>, set_up_tc=3D0x0,= =20 tear_down_tc=3D0x0, factory=3D0xc4c020) at vendor/googletest/googletest/src/gtest.cc:2794 #14 0x0000000000221fdb in __cxx_global_var_init () at src/tests/malloc_extension_test.cc:47 #15 0x0000000000221fdb in _GLOBAL__sub_I_malloc_extension_test.cc () #16 0x000000080027df5d in objlist_call_init (list=3Dlist@entry=3D0x7fffffff= e9c8, lockstate=3Dlockstate@entry=3D0x7fffffffe7d8) at /usr/src/libexec/rtld-elf/rtld.c:3150 #17 0x000000080027cb89 in _rtld (sp=3D<optimized out>, exit_proc=3D0x7fffff= ffea40, objp=3D0x7fffffffea48) at /usr/src/libexec/rtld-elf/rtld.c:990 #18 0x0000000800279df9 in rtld_start () at /usr/src/libexec/rtld-elf/amd64/rtld_start.S:40 (we see it uses size of 25 bytes) and this is backtrace of deallocation (which passes 24 bytes): #0 0x0000000000227ecb in MallocBlock::CheckAndClear (this=3D0xc480f0, type=3D<optimized out>, given_size=3D24) at src/debugallocation.cc:417 #1 0x0000000000227d66 in MallocBlock::Deallocate (this=3D0x4, type=3D2, given_size=3D2138871) at src/debugallocation.cc:338 #2 0x0000000000224152 in DebugDeallocate (ptr=3D<optimized out>, type=3D2, given_size=3D2138871) at src/debugallocation.cc:1065 #3 0x000000000026f460 in tc_delete_sized (p=3D<optimized out>, size=3D<opt= imized out>) at src/debugallocation.cc:1350 #4 0x0000000000256f51 in std::__1::__libcpp_operator_delete[abi:se180100]<void*, unsigned long>(void= *, unsigned long) (__args=3D2, __args=3D2) at /usr/include/c++/v1/new:280 #5 std::__1::__do_deallocate_handle_size[abi:se180100]<>(void*, unsigned l= ong) (__ptr=3D0x4, __size=3D2) at /usr/include/c++/v1/new:304 #6 std::__1::__libcpp_deallocate[abi:se180100](void*, unsigned long, unsig= ned long) (__ptr=3D0x4, __size=3D2, __align=3D1) at /usr/include/c++/v1/new:317 #7 std::__1::allocator<char>::deallocate[abi:se180100](char*, unsigned lon= g) (this=3D0x7fffffffd878, __p=3D0x4 <error: Cannot access memory at address 0= x4>, __n=3D2) at /usr/include/c++/v1/__memory/allocator.h:139 #8 std::__1::allocator_traits<std::__1::allocator<char> >::deallocate[abi:se180100](std::__1::allocator<char>&, char*, unsigned lon= g) (__a=3D...,=20 __p=3D0x4 <error: Cannot access memory at address 0x4>, __n=3D2) at /usr/include/c++/v1/__memory/allocator_traits.h:289 #9 std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_string (this=3D0x7fffffffd878) at /usr/include/c++/v1/string:1105 #10 testing::internal::UnitTestImpl::GetTestSuite (this=3D0xc50020, test_suite_name=3D0xc4e021 "MallocExtensionTest", type_param=3D0x0, set_up_tc=3Dset_up_tc@entry=3D0x0,=20 tear_down_tc=3Dtear_down_tc@entry=3D0x0) at vendor/googletest/googletest/src/gtest.cc:5786 #11 0x000000000025d7d2 in testing::internal::UnitTestImpl::AddTestInfo (this=3D<optimized out>, set_up_tc=3D0x0, tear_down_tc=3D0x0, test_info=3Dtest_info@entry=3D0xc4e020) at ./vendor/googletest/googletest/src/gtest-internal-inl.h:690 #12 0x0000000000242ba3 in testing::internal::MakeAndRegisterTestInfo (test_suite_name=3D<optimized out>, name=3D0x209287 "Basics", type_param=3Dtype_param@entry=3D0x0,=20 value_param=3Dvalue_param@entry=3D0x0, code_location=3D..., fixture_class_id=3Dfixture_class_id@entry=3D0x4237f1 <testing::internal::TypeIdHelper<testing::Test>::dummy_>, set_up_tc=3D0x0,= =20 tear_down_tc=3D0x0, factory=3D0xc4c020) at vendor/googletest/googletest/src/gtest.cc:2794 #13 0x0000000000221fdb in __cxx_global_var_init () at src/tests/malloc_extension_test.cc:47 #14 0x0000000000221fdb in _GLOBAL__sub_I_malloc_extension_test.cc () #15 0x000000080027df5d in objlist_call_init (list=3Dlist@entry=3D0x7fffffff= e9c8, lockstate=3Dlockstate@entry=3D0x7fffffffe7d8) at /usr/src/libexec/rtld-elf/rtld.c:3150 #16 0x000000080027cb89 in _rtld (sp=3D<optimized out>, exit_proc=3D0x7fffff= ffea40, objp=3D0x7fffffffea48) at /usr/src/libexec/rtld-elf/rtld.c:990 #17 0x0000000800279df9 in rtld_start () at /usr/src/libexec/rtld-elf/amd64/rtld_start.S:40 Most likely, it is some sort of a bug in upstream clang's libc++ in whatever version you ship. Although it is somewhat odd, given that Google runs with sized deallocation enabled and with ~always latest clang/llvm bits, but may= be they exercise different configuration. --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-279560-99>