[scudo][standalone] Fix tests under ASan/UBSan
authorKostya Kortchinsky <kostyak@google.com>
Wed, 23 Sep 2020 17:22:15 +0000 (10:22 -0700)
committerKostya Kortchinsky <kostyak@google.com>
Wed, 23 Sep 2020 19:04:57 +0000 (12:04 -0700)
commit2efc09c90914a6c887cb772130d6b375a1713472
tree209a4cd6ef9d879e1bb6778c2f32c23a3130e6ec
parentc96d0cceb684fa176b51d7df5f4f8370e2c983f4
[scudo][standalone] Fix tests under ASan/UBSan

Fix a potential UB in `appendSignedDecimal` (with -INT64_MIN) by making
it a special case.

Fix the terrible test cases for `isOwned`: I was pretty sloppy on those
and used some stack & static variables, but since `isOwned` accesses
memory prior to the pointer to check for the validity of the Scudo
header, it ended up being detected as some global and stack buffer out
of bounds accesses. So not I am using buffers with enough room so that
the test will not access memory prior to the variables.

With those fixes, the tests pass on the ASan+UBSan Fuchsia build.

Thanks to Roland for pointing those out!

Differential Revision: https://reviews.llvm.org/D88170
compiler-rt/lib/scudo/standalone/string_utils.cpp
compiler-rt/lib/scudo/standalone/tests/combined_test.cpp