aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvapier@chromium.org <vapier@chromium.org>2015-07-20 06:19:49 +0000
committervapier@chromium.org <vapier@chromium.org>2015-07-20 06:19:49 +0000
commit85e4cf80298364680e00dcf86d346dac51d53fd5 (patch)
tree9b16ecb9eba5e22ceb9edf949faff002c584de1c /src
parentAdd ELF header analysis when checking for instruction pointer in code. (diff)
downloadbreakpad-85e4cf80298364680e00dcf86d346dac51d53fd5.tar.xz
tests: InstructionPointerMemoryNullPointer: make it work under llvm
When LLVM sees an attempt to dereference a NULL pointer, it will generate invalid opcodes (undefined behavior) which leads to SIGILL which breaks this unittest. Upstream's recommendation in this case is to add volatile markings to get the actual dereference to happen. This is documented in the blog post under "Dereferencing a NULL Pointer": http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1473 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src')
-rw-r--r--src/client/linux/handler/exception_handler_unittest.cc7
-rw-r--r--src/client/mac/tests/exception_handler_test.cc4
2 files changed, 9 insertions, 2 deletions
diff --git a/src/client/linux/handler/exception_handler_unittest.cc b/src/client/linux/handler/exception_handler_unittest.cc
index 289c9cd1..b4065b41 100644
--- a/src/client/linux/handler/exception_handler_unittest.cc
+++ b/src/client/linux/handler/exception_handler_unittest.cc
@@ -774,8 +774,13 @@ TEST(ExceptionHandlerTest, InstructionPointerMemoryNullPointer) {
true, -1);
// Try calling a NULL pointer.
typedef void (*void_function)(void);
- void_function memory_function = reinterpret_cast<void_function>(NULL);
+ // Volatile markings are needed to keep Clang from generating invalid
+ // opcodes. See http://crbug.com/498354 for details.
+ volatile void_function memory_function =
+ reinterpret_cast<void_function>(NULL);
memory_function();
+ // not reached
+ exit(1);
}
close(fds[1]);
diff --git a/src/client/mac/tests/exception_handler_test.cc b/src/client/mac/tests/exception_handler_test.cc
index e19944d0..a8cf6968 100644
--- a/src/client/mac/tests/exception_handler_test.cc
+++ b/src/client/mac/tests/exception_handler_test.cc
@@ -610,7 +610,9 @@ TEST_F(ExceptionHandlerTest, InstructionPointerMemoryNullPointer) {
ExceptionHandler eh(tempDir.path(), NULL, MDCallback, &fds[1], true, NULL);
// Try calling a NULL pointer.
typedef void (*void_function)(void);
- void_function memory_function =
+ // Volatile markings are needed to keep Clang from generating invalid
+ // opcodes. See http://crbug.com/498354 for details.
+ volatile void_function memory_function =
reinterpret_cast<void_function>(NULL);
memory_function();
// not reached