1
1
List of Bugs uncovered in Rust via arithmetic overflow checking
2
2
===============================================================
3
+
3
4
This document is a list of bugs that were uncovered during the
4
5
implementation and deployment of arithmetic overflow checking.
6
+
5
7
This list is restricted solely to * legitimate* bugs. Cases
6
8
where the overflow was benign (e.g. the computed value is
7
9
unused), transient (e.g. the computed wrapped value is
8
10
guaranteed to be brought back into the original range, such as
9
- in ` unsigned - 1 + provably_ tpositive ` ), or silly (random
11
+ in ` unsigned - 1 + provably_positive ` ), or silly (random
10
12
non-functional code in the tests or documentation) are not
11
13
included in the list.
14
+
12
15
However, extremely rare or obscure corner cases are considered
13
16
legitimate bugs. (We begin with such a case.)
14
17
@@ -20,8 +23,8 @@ legitimate bugs. (We begin with such a case.)
20
23
does need to handle out-of-bounds inputs, so this
21
24
appeared benign at first, but there is the corner case
22
25
of an iterator that actually covers the whole range
23
- of indices, which would then return Some(_ ) here when
24
- (pnkfelix thinks) None should be expected.
26
+ of indices, which would then return ` Some(_) ` here when
27
+ (pnkfelix thinks) ` None ` should be expected.
25
28
26
29
reference:
27
30
https://github.com/rust-lang/rust/pull/22532#issuecomment-75168901
@@ -89,7 +92,7 @@ legitimate bugs. (We begin with such a case.)
89
92
my_stack_top + 20000 - OS_DEFAULT_STACK_ESTIMATE;
90
93
```
91
94
92
- where OS_DEFAULT_STACK_ESTIMATE is a large value
95
+ where ` OS_DEFAULT_STACK_ESTIMATE` is a large value
93
96
(> 1mb).
94
97
95
98
However, my claim is that this code is playing guessing
@@ -100,6 +103,7 @@ legitimate bugs. (We begin with such a case.)
100
103
for now. (pnkfelix subsequently changed the code to use
101
104
saturated arithmetic in both cases, though obviously
102
105
that could be tweaked a bit.)
106
+
103
107
4. struct order of evaluation
104
108
105
109
There is an explanatory story here:
@@ -112,8 +116,8 @@ legitimate bugs. (We begin with such a case.)
112
116
out an attempt to reserve a ridiculous amount
113
117
of space within a `Vec`. (This was on an experimental
114
118
branch of the codebase where we would fill with
115
- a series of 0xC1 bytes when a value was dropped, rather
116
- than filling with 0x00 bytes.)
119
+ a series of ` 0xC1` bytes when a value was dropped, rather
120
+ than filling with ` 0x00` bytes.)
117
121
118
122
It is actually quite likely that this test would still
119
123
have failed without the arithmetic overflow checking,
0 commit comments