T11300: Fix test on windows
authorTamar Christina <tamar@zhox.com>
Sun, 10 Jan 2016 06:20:57 +0000 (07:20 +0100)
committerBen Gamari <ben@smart-cactus.org>
Fri, 15 Jan 2016 12:09:30 +0000 (13:09 +0100)
Summary: Fix exit code for Windows to match expected for out-of-memory test

Test Plan: ./validate

Reviewers: simonmar, austin, thomie, bgamari

Reviewed By: thomie, bgamari

Differential Revision: https://phabricator.haskell.org/D1753

GHC Trac Issues: #11422

(cherry picked from commit db371c10a2da722a18b0d5bc042eb2d02ba60e1b)

rts/win32/OSMem.c
rts/win32/veh_excn.c

index 47e24f0..0009a4e 100644 (file)
@@ -59,7 +59,8 @@ allocNew(nat n) {
         rec=0;
         if (GetLastError() == ERROR_NOT_ENOUGH_MEMORY) {
 
-            errorBelch("out of memory");
+            errorBelch("Out of memory");
+            stg_exit(EXIT_HEAPOVERFLOW);
         } else {
             sysErrorBelch(
                 "getMBlocks: VirtualAlloc MEM_RESERVE %d blocks failed", n);
@@ -177,7 +178,7 @@ commitBlocks(char* base, W_ size) {
         temp = VirtualAlloc(base, size_delta, MEM_COMMIT, PAGE_READWRITE);
         if(temp==0) {
             sysErrorBelch("getMBlocks: VirtualAlloc MEM_COMMIT failed");
-            stg_exit(EXIT_FAILURE);
+            stg_exit(EXIT_HEAPOVERFLOW);
         }
         size-=size_delta;
         base+=size_delta;
index a24354e..bf2151a 100644 (file)
 
 // this should be in <excpt.h>, but it's been removed from MinGW distributions
 #ifndef EH_UNWINDING
-#define EH_UNWINDING   0x02 
+#define EH_UNWINDING   0x02
 #endif /* EH_UNWINDING */
 
 // Registered exception handler
 PVOID __hs_handle = NULL;
 
 long WINAPI __hs_exception_handler(struct _EXCEPTION_POINTERS *exception_data)
-{        
+{
     long action = EXCEPTION_CONTINUE_SEARCH;
 
     // When the system unwinds the VEH stack after having handled an excn,
     // return immediately.
     if ((exception_data->ExceptionRecord->ExceptionFlags & EH_UNWINDING) == 0)
     {
-
         // Error handling cases covered by this implementation.
         switch (exception_data->ExceptionRecord->ExceptionCode) {
             case EXCEPTION_FLT_DIVIDE_BY_ZERO:
@@ -62,7 +61,7 @@ long WINAPI __hs_exception_handler(struct _EXCEPTION_POINTERS *exception_data)
         if (EXCEPTION_CONTINUE_EXECUTION == action)
         {
             fflush(stdout);
-            stg_exit(1);
+            stg_exit(EXIT_FAILURE);
         }
     }
 
@@ -88,7 +87,7 @@ void __unregister_hs_exception_handler( void )
 {
     if (__hs_handle != NULL)
     {
-        // Should the return value be checked? we're terminating anyway. 
+        // Should the return value be checked? we're terminating anyway.
         RemoveVectoredExceptionHandler(__hs_handle);
         __hs_handle = NULL;
     }