Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
crush/builder: free 'crush_rule' before return
When sanitizer is enabled, unittest_erasure_code_shec shows: ``` ================================================================= ==437976==ERROR: LeakSanitizer: detected memory leaks Direct leak of 2021708 byte(s) in 29731 object(s) allocated from: #0 0xaaaab0144820 in malloc (/root/ceph-19.0.0/build/bin/unittest_erasure_code_shec+0x1d4820) (BuildId: c0999ecf82504ed7e184ea4b4b9ae9d32faa1c46) #1 0xffffa770057c in crush_make_rule /root/ceph-19.0.0/src/crush/builder.c:104:9 ceph#2 0xffffa7751638 in CrushWrapper::add_simple_rule_at(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, int, std::ostream*) /root/ceph-19.0.0/src/crush/CrushWrapper.cc:2327:22 ceph#3 0xffffa7751d2c in CrushWrapper::add_simple_rule(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, std::ostream*) /root/ceph-19.0.0/src/crush/CrushWrapper.cc:2369:10 ceph#4 0xffffa39d6198 in ceph::ErasureCode::create_rule(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, CrushWrapper&, std::ostream*) const /root/ceph-19.0.0/src/erasure-code/ErasureCode.cc:76:18 ceph#5 0xaaaab01f5a6c in thread3(void*) /root/ceph-19.0.0/src/test/erasure-code/TestErasureCodeShec.cc:2756:11 ceph#6 0xffffa2dad5c4 in start_thread nptl/./nptl/pthread_create.c:442:8 ceph#7 0xffffa2e15ed8 misc/../sysdeps/unix/sysv/linux/aarch64/clone.S:79 SUMMARY: AddressSanitizer: 2021708 byte(s) leaked in 29731 allocation(s). ``` When crush_add_rule exceeds the number of max_rules, crush_rule shoule be freed right before returning in caller site. Signed-off-by: Rongqi Sun <[email protected]>
- Loading branch information