summaryrefslogtreecommitdiff
path: root/rts/win32
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2017-01-15 11:54:41 -0500
committerRyan Scott <ryan.gl.scott@gmail.com>2017-01-15 11:54:41 -0500
commitc13151e5ac774d38d7c5a807692851022c18fe6b (patch)
treee95e46062ec96ca66dbe64e42c0b63b3a9a9b7b7 /rts/win32
parentdb91d17edfbe7deecb62bbb89c804249f9c4a4bd (diff)
downloadhaskell-c13151e5ac774d38d7c5a807692851022c18fe6b.tar.gz
Improve access violation reporting on Windows
Summary: This patch is courtesy of @awson. Currently, whenever GHC catches a segfault on Windows, it simply reports the somewhat uninformative message `Segmentation fault/access violation in generated code`. This patch adds to the message the type of violation (read/write/dep) and location information, which should help debugging segfaults in the future. Fixes #13108. Test Plan: Build on Windows Reviewers: austin, erikd, bgamari, simonmar, Phyx Reviewed By: bgamari, Phyx Subscribers: awson, thomie, #ghc_windows_task_force Differential Revision: https://phabricator.haskell.org/D2969 GHC Trac Issues: #13108
Diffstat (limited to 'rts/win32')
-rw-r--r--rts/win32/veh_excn.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/rts/win32/veh_excn.c b/rts/win32/veh_excn.c
index bf2151a59a..c94dc5a830 100644
--- a/rts/win32/veh_excn.c
+++ b/rts/win32/veh_excn.c
@@ -32,6 +32,7 @@ PVOID __hs_handle = NULL;
long WINAPI __hs_exception_handler(struct _EXCEPTION_POINTERS *exception_data)
{
long action = EXCEPTION_CONTINUE_SEARCH;
+ ULONG_PTR what;
// When the system unwinds the VEH stack after having handled an excn,
// return immediately.
@@ -49,7 +50,12 @@ long WINAPI __hs_exception_handler(struct _EXCEPTION_POINTERS *exception_data)
action = EXCEPTION_CONTINUE_EXECUTION;
break;
case EXCEPTION_ACCESS_VIOLATION:
- fprintf(stdout, "Segmentation fault/access violation in generated code\n");
+ what = exception_data->ExceptionRecord->ExceptionInformation[0];
+ fprintf(stdout, "Access violation in generated code"
+ " when %s %p\n"
+ , what == 0 ? "reading" : what == 1 ? "writing" : what == 8 ? "executing data at" : "?"
+ , (void*) exception_data->ExceptionRecord->ExceptionInformation[1]
+ );
action = EXCEPTION_CONTINUE_EXECUTION;
break;
default:;