summaryrefslogtreecommitdiffstats
path: root/compiler-rt/test/safestack/overflow.c
diff options
context:
space:
mode:
authorDimitry Andric <dimitry@andric.com>2016-01-07 22:19:12 +0000
committerDimitry Andric <dimitry@andric.com>2016-01-07 22:19:12 +0000
commit6e8526358fba6da130202b349a81af7fcf11a960 (patch)
tree78da9e8f1e16aa2d0fd4c5d182e3be75926ba14f /compiler-rt/test/safestack/overflow.c
parentb3326be6add34fa7addb86eb9c2f4483be569b4b (diff)
downloadbcm5719-llvm-6e8526358fba6da130202b349a81af7fcf11a960.tar.gz
bcm5719-llvm-6e8526358fba6da130202b349a81af7fcf11a960.zip
Ensure safestack overflow test doesn't segfault
Summary: In rL255491, the safestack overflow test was disabled for aarch64, since it "is currently failing on an AArch64 buildbot with a segfault, but it is currently passing on other configuration". While testing on FreeBSD on x86, I also encountered a segfault. This is because the `fct()` function actually writes before and after `buffer`, and on FreeBSD this crashes because `buffer` is usually allocated at the end of a page. That this runs correctly on Linux is probably just by accident. I propose to fix this by adding a pre and post buffer, to act as a safety zone. The pre and post buffers must be accessed in an 'unsafe' way, otherwise -fsanitize=safestack will allocate them on the safe stack, and they will not bookend `buffer` itself. Therefore, I create them large enough for `fct()`, and call it on both of them. On FreeBSD, this makes the test run as expected, without segfaulting, and I suppose this will also fix the segfault on AArch64. I do not have AArch64 testing capabilities, so if someone could try that out, I would be much obliged. Reviewers: pcc, kcc, zatrazz Subscribers: llvm-commits, aemerson, emaste Differential Revision: http://reviews.llvm.org/D15725 llvm-svn: 257106
Diffstat (limited to 'compiler-rt/test/safestack/overflow.c')
-rw-r--r--compiler-rt/test/safestack/overflow.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/compiler-rt/test/safestack/overflow.c b/compiler-rt/test/safestack/overflow.c
index 27436947e49..62f86536916 100644
--- a/compiler-rt/test/safestack/overflow.c
+++ b/compiler-rt/test/safestack/overflow.c
@@ -17,9 +17,13 @@ void fct(volatile int *buffer)
int main(int argc, char **argv)
{
+ int prebuf[7];
int value1 = 42;
int buffer[5];
int value2 = 42;
+ int postbuf[7];
+ fct(prebuf + 1);
+ fct(postbuf + 1);
fct(buffer);
return value1 != 42 || value2 != 42;
}
OpenPOWER on IntegriCloud