summaryrefslogtreecommitdiffstats
path: root/testProcess.c
diff options
context:
space:
mode:
authorKWSys Robot <kwrobot@kitware.com>2012-12-19 13:02:08 (GMT)
committerBrad King <brad.king@kitware.com>2012-12-19 13:08:36 (GMT)
commita0f91f1daa7765066a784e4479da7e231374a065 (patch)
tree8146d5138c590438606b53ab01ca894009148380 /testProcess.c
parent4cf44d3621487415d5c2ccc5628c5e0c99119410 (diff)
downloadCMake-a0f91f1daa7765066a784e4479da7e231374a065.zip
CMake-a0f91f1daa7765066a784e4479da7e231374a065.tar.gz
CMake-a0f91f1daa7765066a784e4479da7e231374a065.tar.bz2
KWSys 2012-12-19 (933eb822)
Extract upstream KWSys using the following shell commands. $ git archive --prefix=upstream-kwsys/ 933eb822 | tar x $ git shortlog --no-merges --abbrev=8 --format='%h %s' 3b17de34..933eb822 Brad King (2): fea37696 Process: Remove support for Windows 98 01e15c22 Remove KWSys Registry Rolf Eike Beer (7): f376ec32 SystemInformation: fix typos bfee5174 SystemInformation: sum up all caches found in /proc/cpuinfo 5690d711 SystemInformation: fix value extraction from /proc/cpuinfo 36295981 SystemInformation: PA-RISC chips are from HP 72e9d02e SystemInformation: try harder to find a useful processor name b39de34c SystemInformation: try harder to find the CPU family 933eb822 SystemInformation: extract CPU stepping information from /proc/cpuinfo, too Sean McBride (2): 5e17bfde Process: Dereference NULL++ instead of NULL to force crash 86a78cb7 SystemTools: Add check for empty strings to prevent integer underflow Change-Id: Id7194f434fe67be81e6ee9e96d705010a1171a06
Diffstat (limited to 'testProcess.c')
-rw-r--r--testProcess.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/testProcess.c b/testProcess.c
index 877002a..ec561ea 100644
--- a/testProcess.c
+++ b/testProcess.c
@@ -82,6 +82,14 @@ int test3(int argc, const char* argv[])
int test4(int argc, const char* argv[])
{
+ /* Prepare a pointer to an invalid address. Don't use null, because
+ dereferencing null is undefined behaviour and compilers are free to
+ do whatever they want. ex: Clang will warn at compile time, or even
+ optimize away the write. We hope to 'outsmart' them by using
+ 'volatile' and a slightly larger address, based on a runtime value. */
+ volatile int* invalidAddress = 0;
+ invalidAddress += argc?1:2;
+
#if defined(_WIN32)
/* Avoid error diagnostic popups since we are crashing on purpose. */
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
@@ -94,11 +102,8 @@ int test4(int argc, const char* argv[])
fprintf(stderr, "Output before crash on stderr from crash test.\n");
fflush(stdout);
fflush(stderr);
-#if defined(__clang__)
- *(int*)1 = 0; /* Clang warns about 0-ptr; undefined behavior. */
-#else
- *(int*)0 = 0;
-#endif
+ /* Provoke deliberate crash by writing to the invalid address. */
+ *invalidAddress = 0;
fprintf(stdout, "Output after crash on stdout from crash test.\n");
fprintf(stderr, "Output after crash on stderr from crash test.\n");
return 0;