From: Kefu Chai Date: Tue, 25 Mar 2025 07:11:34 +0000 (+0800) Subject: erasure-code: use new/delete to alloc/free coefficients array X-Git-Tag: v20.3.0~236^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=e8f02e8edaefc5244060952c0fd717f8a1f83fc2;p=ceph.git erasure-code: use new/delete to alloc/free coefficients array before this change, we allocate coefficients table with malloc() in ErasureCodeIsaDefault::prepare(), but free them using delete. so, in this change, we use new [] and delete [] to allocate and free them, to be more consistent, and to silence this warning. this issue was identified by AddressSanitizer: ``` 2025-03-22T04:27:58.210 INFO:tasks.ceph.osd.3.smithi102.stderr:==42899==ERROR: AddressSanitizer: alloc-dealloc-mismatch (operator new [] vs free) on 0x611000570d40 2025-03-22T04:27:58.253 DEBUG:teuthology.orchestra.run.smithi102:> sudo adjust-ulimits ceph-coverage /home/ubuntu/cephtest/archive/coverage timeout 120 env ASAN_OPTIONS=detect_leaks=0,detect_odr_violation=0,alloc_dealloc_mismatch=0 LD_PRELOAD=/lib64/libasan.so.6 ceph --cluster ceph osd pool set cephfs_data_ec allow_ec_overwrites true 2025-03-22T04:27:58.442 INFO:tasks.ceph.osd.3.smithi102.stderr: #0 0x7efdc30b46b7 in free (/lib64/libasan.so.6+0xb46b7) 2025-03-22T04:27:58.442 INFO:tasks.ceph.osd.3.smithi102.stderr: #1 0x7efd9e2e5f26 in ErasureCodeIsaTableCache::setEncodingTable(int, int, int, unsigned char*) (/usr/lib64/ceph/erasure-code/libec_isa.so+0x3bf26) 2025-03-22T04:27:58.442 INFO:tasks.ceph.osd.3.smithi102.stderr: #2 0x7efd9e2f0fae in ErasureCodeIsaDefault::prepare() (/usr/lib64/ceph/erasure-code/libec_isa.so+0x46fae) 2025-03-22T04:27:58.442 INFO:tasks.ceph.osd.3.smithi102.stderr: #3 0x7efd9e2bfa3e in ErasureCodeIsa::init(std::map, std::allocator >, std::__cxx11::basic_string, std::allocator >, std::less, std::allocator > >, std::allocator, std::allocator > const, std::__cxx11::basic_string, std::allocator > > > >&, std::ostream*) (/usr/lib64/ceph/erasure-code/libec_isa.so+0x15a3e) 2025-03-22T04:27:58.442 INFO:tasks.ceph.osd.3.smithi102.stderr: #4 0x7efd9e2ff510 in ErasureCodePluginIsa::factory(std::__cxx11::basic_string, std::allocator > const&, std::map, std::allocator >, std::__cxx11::basic_string, std::allocator >, std::less, std::allocator > >, std::allocator, std::allocator > const, std::__cxx11::basic_string, std::allocator > > > >&, std::shared_ptr*, std::ostream*) (/usr/lib64/ceph/erasure-code/libec_isa.so+0x55510) 2025-03-22T04:27:58.442 INFO:tasks.ceph.osd.3.smithi102.stderr: #5 0x55a7ef19b395 in ceph::ErasureCodePluginRegistry::factory(std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&, std::map, std::allocator >, std::__cxx11::basic_string, std::allocator >, std::less, std::allocator > >, std::allocator, std::allocator > const, std::__cxx11::basic_string, std::allocator > > > >&, std::shared_ptr*, std::ostream*) (/usr/bin/ceph-osd+0x4dcb395) 2025-03-22T04:27:58.442 INFO:tasks.ceph.osd.3.smithi102.stderr: #6 0x55a7eb9089d8 in PGBackend::build_pg_backend(pg_pool_t const&, std::map, std::allocator >, std::__cxx11::basic_string, std::allocator >, std::less, std::allocator > >, std::allocator, std::allocator > const, std::__cxx11::basic_string, std::allocator > > > > const&, PGBackend::Listener*, coll_t, boost::intrusive_ptr&, ObjectStore*, ceph::common::CephContext*) (/usr/bin/ceph-osd+0x15389d8) 2025-03-22T04:27:58.443 INFO:tasks.ceph.osd.3.smithi102.stderr: #7 0x55a7eb4b63ec in PrimaryLogPG::PrimaryLogPG(OSDService*, std::shared_ptr, PGPool const&, std::map, std::allocator >, std::__cxx11::basic_string, std::allocator >, std::less, std::allocator > >, std::allocator, std::allocator > const, std::__cxx11::basic_string, std::allocator > > > > const&, spg_t) (/usr/bin/ceph-osd+0x10e63ec) 2025-03-22T04:27:58.443 INFO:tasks.ceph.osd.3.smithi102.stderr: #8 0x55a7eaef1cc7 in OSD::_make_pg(std::shared_ptr, spg_t) (/usr/bin/ceph-osd+0xb21cc7) 2025-03-22T04:27:58.443 INFO:tasks.ceph.osd.3.smithi102.stderr: #9 0x55a7eaef8d69 in OSD::handle_pg_create_info(std::shared_ptr const&, PGCreateInfo const*) (/usr/bin/ceph-osd+0xb28d69) 2025-03-22T04:27:58.443 INFO:tasks.ceph.osd.3.smithi102.stderr: #10 0x55a7eafeb9ed in OSD::ShardedOpWQ::_process(unsigned int, ceph::heartbeat_handle_d*) (/usr/bin/ceph-osd+0xc1b9ed) 2025-03-22T04:27:58.443 INFO:tasks.ceph.osd.3.smithi102.stderr: #11 0x55a7ed04c9aa in ShardedThreadPool::shardedthreadpool_worker(unsigned int) (/usr/bin/ceph-osd+0x2c7c9aa) 2025-03-22T04:27:58.443 INFO:tasks.ceph.osd.3.smithi102.stderr: #12 0x55a7ed04d338 in ShardedThreadPool::WorkThreadSharded::entry() (/usr/bin/ceph-osd+0x2c7d338) 2025-03-22T04:27:58.443 INFO:tasks.ceph.osd.3.smithi102.stderr: #13 0x55a7ecf92b46 in Thread::entry_wrapper() (/usr/bin/ceph-osd+0x2bc2b46) 2025-03-22T04:27:58.443 INFO:tasks.ceph.osd.3.smithi102.stderr: #14 0x55a7ecf92b82 in Thread::_entry_func(void*) (/usr/bin/ceph-osd+0x2bc2b82) 2025-03-22T04:27:58.443 INFO:tasks.ceph.osd.3.smithi102.stderr: #15 0x7efdc1e8a3b1 in start_thread (/lib64/libc.so.6+0x8a3b1) 2025-03-22T04:27:58.443 INFO:tasks.ceph.osd.3.smithi102.stderr: #16 0x7efdc1f0f42f in __GI___clone3 (/lib64/libc.so.6+0x10f42f) 2025-03-22T04:27:58.443 INFO:tasks.ceph.osd.3.smithi102.stderr: 2025-03-22T04:27:58.443 INFO:tasks.ceph.osd.3.smithi102.stderr:0x611000570d40 is located 0 bytes inside of 256-byte region [0x611000570d40,0x611000570e40) 2025-03-22T04:27:58.444 INFO:tasks.ceph.osd.3.smithi102.stderr:allocated by thread T817 here: 2025-03-22T04:27:58.444 INFO:tasks.ceph.osd.3.smithi102.stderr: #0 0x7efdc30b64d7 in operator new[](unsigned long) (/lib64/libasan.so.6+0xb64d7) 2025-03-22T04:27:58.444 INFO:tasks.ceph.osd.3.smithi102.stderr: #1 0x7efd9e2f0e32 in ErasureCodeIsaDefault::prepare() (/usr/lib64/ceph/erasure-code/libec_isa.so+0x46e32) 2025-03-22T04:27:58.444 INFO:tasks.ceph.osd.3.smithi102.stderr: #2 0x7efd9e2bfa3e in ErasureCodeIsa::init(std::map, std::allocator >, std::__cxx11::basic_string, std::allocator >, std::less, std::allocator > >, std::allocator, std::allocator > const, std::__cxx11::basic_string, std::allocator > > > >&, std::ostream*) (/usr/lib64/ceph/erasure-code/libec_isa.so+0x15a3e) 2025-03-22T04:27:58.444 INFO:tasks.ceph.osd.3.smithi102.stderr: #3 0x7efd9e2ff510 in ErasureCodePluginIsa::factory(std::__cxx11::basic_string, std::allocator > const&, std::map, std::allocator >, std::__cxx11::basic_string, std::allocator >, std::less, std::allocator > >, std::allocator, std::allocator > const, std::__cxx11::basic_string, std::allocator > > > >&, std::shared_ptr*, std::ostream*) (/usr/lib64/ceph/erasure-code/libec_isa.so+0x55510) 2025-03-22T04:27:58.444 INFO:tasks.ceph.osd.3.smithi102.stderr: #4 0x55a7ef19b395 in ceph::ErasureCodePluginRegistry::factory(std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&, std::map, std::allocator >, std::__cxx11::basic_string, std::allocator >, std::less, std::allocator > >, std::allocator, std::allocator > const, std::__cxx11::basic_string, std::allocator > > > >&, std::shared_ptr*, std::ostream*) (/usr/bin/ceph-osd+0x4dcb395) 2025-03-22T04:27:58.444 INFO:tasks.ceph.osd.3.smithi102.stderr: #5 0x55a7eb9089d8 in PGBackend::build_pg_backend(pg_pool_t const&, std::map, std::allocator >, std::__cxx11::basic_string, std::allocator >, std::less, std::allocator > >, std::allocator, std::allocator > const, std::__cxx11::basic_string, std::allocator > > > > const&, PGBackend::Listener*, coll_t, boost::intrusive_ptr&, ObjectStore*, ceph::common::CephContext*) (/usr/bin/ceph-osd+0x15389d8) 2025-03-22T04:27:58.444 INFO:tasks.ceph.osd.3.smithi102.stderr: #6 0x55a7eb4b63ec in PrimaryLogPG::PrimaryLogPG(OSDService*, std::shared_ptr, PGPool const&, std::map, std::allocator >, std::__cxx11::basic_string, std::allocator >, std::less, std::allocator > >, std::allocator, std::allocator > const, std::__cxx11::basic_string, std::allocator > > > > const&, spg_t) (/usr/bin/ceph-osd+0x10e63ec) 2025-03-22T04:27:58.444 INFO:tasks.ceph.osd.3.smithi102.stderr: #7 0x55a7eaef1cc7 in OSD::_make_pg(std::shared_ptr, spg_t) (/usr/bin/ceph-osd+0xb21cc7) 2025-03-22T04:27:58.444 INFO:tasks.ceph.osd.3.smithi102.stderr: #8 0x55a7eaef8d69 in OSD::handle_pg_create_info(std::shared_ptr const&, PGCreateInfo const*) (/usr/bin/ceph-osd+0xb28d69) 2025-03-22T04:27:58.444 INFO:tasks.ceph.osd.3.smithi102.stderr: #9 0x55a7eafeb9ed in OSD::ShardedOpWQ::_process(unsigned int, ceph::heartbeat_handle_d*) (/usr/bin/ceph-osd+0xc1b9ed) 2025-03-22T04:27:58.444 INFO:tasks.ceph.osd.3.smithi102.stderr: #10 0x55a7ed04c9aa in ShardedThreadPool::shardedthreadpool_worker(unsigned int) (/usr/bin/ceph-osd+0x2c7c9aa) 2025-03-22T04:27:58.444 INFO:tasks.ceph.osd.3.smithi102.stderr: #11 0x55a7ed04d338 in ShardedThreadPool::WorkThreadSharded::entry() (/usr/bin/ceph-osd+0x2c7d338) 2025-03-22T04:27:58.445 INFO:tasks.ceph.osd.3.smithi102.stderr: #12 0x55a7ecf92b46 in Thread::entry_wrapper() (/usr/bin/ceph-osd+0x2bc2b46) 2025-03-22T04:27:58.445 INFO:tasks.ceph.osd.3.smithi102.stderr: #13 0x55a7ecf92b82 in Thread::_entry_func(void*) (/usr/bin/ceph-osd+0x2bc2b82) 2025-03-22T04:27:58.445 INFO:tasks.ceph.osd.3.smithi102.stderr: #14 0x7efdc1e8a3b1 in start_thread (/lib64/libc.so.6+0x8a3b1) 2025-03-22T04:27:58.445 INFO:tasks.ceph.osd.3.smithi102.stderr: ``` Fixes: https://tracker.ceph.com/issues/70619 Signed-off-by: Kefu Chai --- diff --git a/src/erasure-code/isa/ErasureCodeIsaTableCache.cc b/src/erasure-code/isa/ErasureCodeIsaTableCache.cc index aad44d733f465..496f7fdb34d64 100644 --- a/src/erasure-code/isa/ErasureCodeIsaTableCache.cc +++ b/src/erasure-code/isa/ErasureCodeIsaTableCache.cc @@ -192,7 +192,7 @@ ErasureCodeIsaTableCache::setEncodingTable(int matrix, int k, int m, unsigned ch if (*ec_out_table) { // somebody might have deposited this table in the meanwhile, so clean // the input table and return the stored one - free (ec_in_table); + delete[] ec_in_table; return *ec_out_table; } else { // we store the provided input table and return this one