Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 373cb301 authored by George Burgess IV's avatar George Burgess IV
Browse files

memunreachable_test: don't use `write` to escape addresses

A recent change
(https://android-review.googlesource.com/c/platform/bionic/+/961601)
caused this test to fail. This change allowed LLVM to optimize what was
previously `__write_chk` into a standard call to `write`.

LLVM knows things about `write`. In particular, it knows that `write`
doesn't capture its buffer param, which `Ref` assumes isn't possible.

LLVM can't reason much about `volatile` operations; storing this to a
`volatile` ptr should be good enough. If not, there are a few other
tricks we can play here.

Bug: 133479661
Test: `atest
memunreachable_test:memunreachable_test.MemunreachableTest#stack --
--abi x86` on internal-master

Change-Id: I905e510210cafdf83fa1b50f2f090d4f8b9653da
parent 3e48b665
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -47,7 +47,8 @@ class HiddenPointer {

// Trick the compiler into thinking a value on the stack is still referenced.
static void Ref(void** ptr) {
  write(0, ptr, 0);
  void** volatile storage;
  storage = ptr;
}

class MemunreachableTest : public ::testing::Test {