Project

General

Profile

Bug #11080

bucket_straw2_choose div by zero when item_weight is 0

Added by Dan van der Ster about 9 years ago. Updated almost 9 years ago.

Status:
Duplicate
Priority:
Urgent
Assignee:
-
Category:
-
Target version:
-
% Done:

0%

Source:
other
Tags:
Backport:
Regression:
No
Severity:
2 - major
Reviewed:
Affected Versions:
ceph-qa-suite:
Pull request ID:
Crash signature (v1):
Crash signature (v2):

Description

Following #11079 we found that zero weighted items create a Floating point exception in straw2 buckets:

$ gdb /usr/bin/crushtool
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying" 
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/bin/crushtool...Reading symbols from /usr/lib/debug/usr/bin/crushtool.debug...done.
done.
(gdb) run -i crush.test --test
Starting program: /usr/bin/crushtool -i crush.test --test
[Thread debugging using libthread_db enabled]
[New Thread 0x7ffff7fe8700 (LWP 101803)]
[New Thread 0x7ffff712e700 (LWP 101804)]
WARNING: no output selected; use --output-csv or --show-X

Program received signal SIGFPE, Arithmetic exception.
0x000000000064b24e in bucket_straw2_choose (in=0x2a66f40, x=9, r=0) at crush/mapper.c:331
331                     draw = ln / bucket->item_weights[i];
Missing separate debuginfos, use: debuginfo-install sqlite-3.6.20-1.el6.x86_64
(gdb) bt
#0  0x000000000064b24e in bucket_straw2_choose (in=0x2a66f40, x=9, r=0) at crush/mapper.c:331
#1  crush_bucket_choose (in=0x2a66f40, x=9, r=0) at crush/mapper.c:360
#2  0x000000000064b53f in crush_choose_firstn (map=0x2a2fb50, bucket=0x2a66f40, weight=0x2b3f690, weight_max=7310, x=9, numrep=1, type=0, out=0x7fffffffcdd8, outpos=0, out_size=1, tries=1, recurse_tries=0, local_retries=0, local_fallback_retries=0, recurse_to_leaf=0,
    vary_r=1, out2=0x0, parent_r=0) at crush/mapper.c:467
#3  0x000000000064b8d1 in crush_choose_firstn (map=0x2a2fb50, bucket=0x2a4d680, weight=0x2b3f690, weight_max=7310, x=9, numrep=1, type=2, out=0x7fffffffcdd4, outpos=0, out_size=1, tries=51, recurse_tries=1, local_retries=0, local_fallback_retries=0, recurse_to_leaf=1,
    vary_r=1, out2=0x7fffffffcdd8, parent_r=0) at crush/mapper.c:510
#4  0x000000000064c1d5 in crush_do_rule (map=0x2a2fb50, ruleno=<value optimized out>, x=9, result=0x7fffffffcdf0, result_max=1, weight=0x2b3f690, weight_max=7310, scratch=0x7fffffffcdd0) at crush/mapper.c:901
#5  0x000000000057c1b5 in CrushWrapper::do_rule (this=<value optimized out>, rule=5, x=9, out=std::vector of length 0, capacity 0, maxout=1, weight=std::vector of length 7310, capacity 8192 = {...}) at crush/CrushWrapper.h:1025
#6  0x000000000059727c in CrushTester::test (this=0x7fffffffd830) at crush/CrushTester.cc:575
#7  0x00000000004ef775 in main (argc=<value optimized out>, argv=<value optimized out>) at tools/crushtool.cc:811
(gdb) p bucket->item_weights[i]
value has been optimized out
(gdb) p bucket->h.size
$2 = 4
(gdb) p bucket->item_weights[0]
$3 = 0
(gdb) p bucket->item_weights[1]
$4 = 0
(gdb) p bucket->item_weights[2]
$5 = 0
(gdb) p bucket->item_weights[3]
$6 = 0
(gdb) p bucket->h.weight
$8 = 0
(gdb) p bucket->h.id
$9 = -200

crush.test (182 KB) Dan van der Ster, 03/10/2015 10:57 AM


Related issues

Duplicates RADOS - Bug #11357: crush: straw2: divide by 0 when weight is 0 Resolved 04/09/2015

History

#1 Updated by Kefu Chai about 9 years ago

maybe we can have something like crush_multiplication_is_unsafe() check in crush_make_straw2_bucket()? or just check for the zero before assigning item_weights[]?

#2 Updated by Dan van der Ster about 9 years ago

My 2c: zero weighted items are useful, especially when draining OSDs before decommissioning. It would be a pity if straw2 didn't allow them...

#3 Updated by Loïc Dachary almost 9 years ago

  • Status changed from New to Duplicate

Also available in: Atom PDF