From 5c0719a58cfc28850916a044851147102612273c Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Mon, 14 Aug 2017 14:23:24 +0800 Subject: [PATCH] crush: CrushWrapper::add_bucket - do not allow caller pass in null 'idout' *** Caught signal (Segmentation fault) ** in thread 7f495c0f6300 thread_name:crushtool ceph version 12.1.2-768-gab69125 (ab6912523e779174f92f0b0fc10372bd0b645415) mimic (dev) 1: (()+0x1a3d1) [0x7f495c1343d1] 2: (()+0xf370) [0x7f4951deb370] 3: (CrushWrapper::add_bucket(int, int, int, int, int, int*, int*, int*)+0x84) [0x7f49538ba084] 4: (CrushCompiler::parse_bucket(__gnu_cxx::__normal_iterator >*, std::vector >, std::allocator > > > > const&)+0xef0) [0x7f49538dc170] 5: (CrushCompiler::parse_crush(__gnu_cxx::__normal_iterator >*, std::vector >, std::allocator > > > > const&)+0x130) [0x7f49538dcba0] 6: (CrushCompiler::compile(std::istream&, char const*)+0xb93) [0x7f49538deaa3] 7: (main()+0x2615) [0x7f495c126015] 8: (__libc_start_main()+0xf5) [0x7f49507ccb35] 9: (()+0xf4b0) [0x7f495c1294b0] 2017-08-14 13:31:25.498050 7f495c0f6300 -1 *** Caught signal (Segmentation fault) ** in thread 7f495c0f6300 thread_name:crushtool Signed-off-by: xie xingguo (cherry picked from commit dc8f925cb4eebffa5f4c13d1063ae3ae8d7e15bd) --- src/crush/CrushCompiler.cc | 4 +++- src/crush/CrushWrapper.cc | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/crush/CrushCompiler.cc b/src/crush/CrushCompiler.cc index eb4f7b7cf4a6e..02ed45935799f 100644 --- a/src/crush/CrushCompiler.cc +++ b/src/crush/CrushCompiler.cc @@ -741,7 +741,9 @@ int CrushCompiler::parse_bucket(iter_t const& i) item_weight[id] = bucketweight; assert(id != 0); - int r = crush.add_bucket(id, alg, hash, type, size, &items[0], &weights[0], NULL); + int idout; + int r = crush.add_bucket(id, alg, hash, type, size, + &items[0], &weights[0], &idout); if (r < 0) { if (r == -EEXIST) err << "Duplicate bucket id " << id << std::endl; diff --git a/src/crush/CrushWrapper.cc b/src/crush/CrushWrapper.cc index d95e8b8d6d049..006c20f2e1e24 100644 --- a/src/crush/CrushWrapper.cc +++ b/src/crush/CrushWrapper.cc @@ -1702,6 +1702,7 @@ int CrushWrapper::add_bucket( crush_bucket *b = crush_make_bucket(crush, alg, hash, type, size, items, weights); assert(b); + assert(idout); int r = crush_add_bucket(crush, bucketno, b, idout); int pos = -1 - *idout; for (auto& p : choose_args) { -- 2.39.5