gecko-dev/memory
Mike Hommey 5c18ecad6b Bug 1438427 - Fix wrong change from bug 1412722 in RedBlackTree::Remove. r=njn
Before bug 1412722, which removed the sentinels, the code looked like:

  if (rbp_r_c->Right()->Left()->IsBlack()) {

At that point in the code, rbp_r_c is the root node of the tree. If
rbp_r_c->Right() was the sentinel, ->Right()->Left() would be the
sentinel too, and the sentinel is black. Which means the condition would
be true.

The code after was:

  if (rbp_r_c->Right() && (!rbp_r_c->Right()->Left() ||
                           rbp_r_c->Right()->Left()->IsBlack())) {

The second half correctly deals with the case of
rbp_r_c->Right()->Left() being the sentinel. But the first half now
makes things different: ->Right() being null would correspond to the
previous case where it was the sentinel, and the test would not return
true in that case when it would have before. When ->Right() is not null,
things are normal again.

The correct check is to make the branch taken when ->Right() is null.

Now, looking under which conditions we may get in that branch wrongly:
- The root node's right link must be empty, which means a very small tree.
- The comparison between the removed key and the root node must indicate
  the key is greater than the value of the root node.
- There's another case where the comparison result (rbp_r_cmp) can be
  eGreater, when it is reassigned under one of the branches under the
  eEqual test, and that branch is only taken when ->Right() on the root
  node was non-null, which was the non-broken case.

So it would seem we can't reach that code when rbp_r_c->Right() is null
anyways, so it /should/ practically make no difference. Better safe than
sorry, though. It's hard to tell anything from crash stats, because
since the templatization in bug 1403444, all crashes fit in one bucket,
when there used to be 5 functions before :(

While here, add a missing include in rb.h.

--HG--
extra : rebase_source : 2ebcb84345ad52059b0c081b9e2e1af1d0bbb7bc
2018-02-15 14:38:52 +09:00
..
build Bug 1438427 - Fix wrong change from bug 1412722 in RedBlackTree::Remove. r=njn 2018-02-15 14:38:52 +09:00
fallible Bug 1423802 - Remove the dummy fallible library. r=nalexander 2017-12-07 12:16:50 +09:00
gtest Bug 1418123 - Apply junk on huge and large reallocations. r=njn 2017-11-16 16:34:31 +09:00
mozalloc Bug 1417504 - Also wrap Heap{Alloc,ReAlloc,Free} when building without our allocator. r=njn 2017-12-19 14:46:23 +09:00
replace Bug 1431533: Part 5a - Auto-rewrite code to use ChromeUtils import methods. r=florian 2018-01-29 15:20:18 -08:00
volatile Bug 1423107 - Replace uses of moz_posix_memalign with posix_memalign. r=njn 2017-12-05 16:46:17 +09:00
app.mozbuild Bug 1417309 - Add the necessary bits to support a --enable-project=memory option. r=nalexander 2017-11-16 08:37:36 +09:00
moz.build Bug 1417309 - Add the necessary bits to support a --enable-project=memory option. r=nalexander 2017-11-16 08:37:36 +09:00
moz.configure Bug 1417309 - Add the necessary bits to support a --enable-project=memory option. r=nalexander 2017-11-16 08:37:36 +09:00