[commit: ghc] master: rts/win32: Emit exception handler output to stderr (4dfb790)

git at git.haskell.org git at git.haskell.org
Mon Nov 6 21:39:42 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/4dfb790ca0611d4024cd01ba4c28d145f1deb7cb/ghc

>---------------------------------------------------------------

commit 4dfb790ca0611d4024cd01ba4c28d145f1deb7cb
Author: Ben Gamari <bgamari.foss at gmail.com>
Date:   Mon Nov 6 15:33:18 2017 -0500

    rts/win32: Emit exception handler output to stderr
    
    Test Plan: Validate
    
    Reviewers: Phyx, austin, erikd, simonmar
    
    Reviewed By: Phyx
    
    Subscribers: rwbarton, thomie
    
    GHC Trac Issues: #14415
    
    Differential Revision: https://phabricator.haskell.org/D4151


>---------------------------------------------------------------

4dfb790ca0611d4024cd01ba4c28d145f1deb7cb
 rts/win32/veh_excn.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/rts/win32/veh_excn.c b/rts/win32/veh_excn.c
index 3ac008d..fd50562 100644
--- a/rts/win32/veh_excn.c
+++ b/rts/win32/veh_excn.c
@@ -101,7 +101,7 @@ long WINAPI __hs_exception_handler(struct _EXCEPTION_POINTERS *exception_data)
 
     long action = EXCEPTION_CONTINUE_SEARCH;
     ULONG_PTR what;
-    fprintf (stdout, "\n");
+    fprintf (stderr, "\n");
 
     // When the system unwinds the VEH stack after having handled an excn,
     // return immediately.
@@ -111,16 +111,16 @@ long WINAPI __hs_exception_handler(struct _EXCEPTION_POINTERS *exception_data)
         switch (exception_data->ExceptionRecord->ExceptionCode) {
             case EXCEPTION_FLT_DIVIDE_BY_ZERO:
             case EXCEPTION_INT_DIVIDE_BY_ZERO:
-                fprintf(stdout, "divide by zero\n");
+                fprintf(stderr, "divide by zero\n");
                 action = EXCEPTION_CONTINUE_EXECUTION;
                 break;
             case EXCEPTION_STACK_OVERFLOW:
-                fprintf(stdout, "C stack overflow in generated code\n");
+                fprintf(stderr, "C stack overflow in generated code\n");
                 action = EXCEPTION_CONTINUE_EXECUTION;
                 break;
             case EXCEPTION_ACCESS_VIOLATION:
                 what = exception_data->ExceptionRecord->ExceptionInformation[0];
-                fprintf(stdout, "Access violation in generated code"
+                fprintf(stderr, "Access violation in generated code"
                                 " when %s 0x%" PRIxPTR "\n"
                                 , what == 0 ? "reading"
                                 : what == 1 ? "writing"
@@ -140,7 +140,7 @@ long WINAPI __hs_exception_handler(struct _EXCEPTION_POINTERS *exception_data)
         // But the correct action is still to exit as fast as possible.
         if (EXCEPTION_CONTINUE_EXECUTION == action)
         {
-            fflush(stdout);
+            fflush(stderr);
             generateStack (exception_data);
             generateDump (exception_data);
             stg_exit(EXIT_FAILURE);
@@ -247,7 +247,7 @@ void generateDump (EXCEPTION_POINTERS* pExceptionPointers)
                                  MiniDumpWithThreadInfo | MiniDumpWithCodeSegs,
                       &ExpParam, NULL, NULL);
 
-    fprintf (stdout, "Crash dump created. Dump written to:\n\t%ls", szFileName);
+    fprintf (stderr, "Crash dump created. Dump written to:\n\t%ls", szFileName);
 }
 
 // Generate stack trace information, we can piggy back on information we know
@@ -283,9 +283,9 @@ void generateStack (EXCEPTION_POINTERS* pExceptionPointers)
     stackFrame.AddrStack.Offset = context->Esp;
     stackFrame.AddrStack.Mode = AddrModeFlat;
 #endif
-    fprintf (stdout, "\n Attempting to reconstruct a stack trace...\n\n");
+    fprintf (stderr, "\n Attempting to reconstruct a stack trace...\n\n");
     if (!SymInitialize (GetCurrentProcess (), NULL, true))
-        fprintf (stdout, "  \nNOTE: Symbols could not be loaded. Addresses may"
+        fprintf (stderr, "  \nNOTE: Symbols could not be loaded. Addresses may"
                          " be unresolved.\n\n");
 
     /* Maximum amount of stack frames to show.  */
@@ -294,7 +294,7 @@ void generateStack (EXCEPTION_POINTERS* pExceptionPointers)
        few.  */
     int max_frames = 35;
 
-    fprintf (stdout, "   Frame\tCode address\n");
+    fprintf (stderr, "   Frame\tCode address\n");
     DWORD64 lastBp = 0; /* Prevent loops with optimized stackframes.  */
     while (StackWalk64 (machineType, GetCurrentProcess(), GetCurrentThread(),
                         &stackFrame, context, NULL, SymFunctionTableAccess64,
@@ -302,19 +302,19 @@ void generateStack (EXCEPTION_POINTERS* pExceptionPointers)
     {
         if (stackFrame.AddrPC.Offset == 0)
         {
-            fprintf (stdout, "Null address\n");
+            fprintf (stderr, "Null address\n");
             break;
         }
         wchar_t buffer[1024];
         uintptr_t topSp = 0;
-        fprintf (stdout, " * 0x%" PRIxPTR "\t%ls\n",
+        fprintf (stderr, " * 0x%" PRIxPTR "\t%ls\n",
                  (uintptr_t)stackFrame.AddrFrame.Offset,
                  resolveSymbolAddr ((wchar_t*)&buffer, 1024,
                                    (SymbolAddr*)stackFrame.AddrPC.Offset,
                                    &topSp));
         if (lastBp >= stackFrame.AddrFrame.Offset)
         {
-            fprintf (stdout, "Stack frame out of sequence...\n");
+            fprintf (stderr, "Stack frame out of sequence...\n");
             break;
         }
         lastBp = stackFrame.AddrFrame.Offset;
@@ -322,9 +322,9 @@ void generateStack (EXCEPTION_POINTERS* pExceptionPointers)
         max_frames--;
         if (max_frames ==0)
         {
-            fprintf (stdout, "\n   ... (maximum recursion depth reached.)\n");
+            fprintf (stderr, "\n   ... (maximum recursion depth reached.)\n");
         }
     }
-    fprintf (stdout, "\n");
-    fflush(stdout);
+    fprintf (stderr, "\n");
+    fflush(stderr);
 }



More information about the ghc-commits mailing list