rts: don't crash on 'hs_init(NULL, NULL)' in debug rts
authorSergei Trofimovich <slyfox@gentoo.org>
Fri, 10 Oct 2014 20:43:30 +0000 (21:43 +0100)
committerSergei Trofimovich <slyfox@gentoo.org>
Fri, 10 Oct 2014 20:57:16 +0000 (21:57 +0100)
Caught by T6006 as a NULL dereference:

  Command: ./T6006

  Invalid read of size 8
     at 0x660ED9: hs_init_ghc (RtsStartup.c:168)
     by 0x660D90: hs_init (RtsStartup.c:112)
     by 0x40504D: main (in /home/slyfox/dev/git/ghc-validate/testsuite/tests/rts/T6006)
   Address 0x0 is not stack'd, malloc'd or (recently) free'd

The regression was introduced by commit
cb0a503a44bf016de3d9042906c6ac0c0821ffea

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
rts/RtsStartup.c

index 5e6f9fa..32bed5a 100644 (file)
@@ -161,12 +161,12 @@ hs_init_ghc(int *argc, char **argv[], RtsConfig rts_config)
         setFullProgArgv(*argc,*argv);
         setupRtsFlags(argc, *argv,
                       rts_config.rts_opts_enabled, rts_config.rts_opts, rts_config.rts_hs_main);
-    }
 
 #ifdef DEBUG
-    /* load debugging symbols for current binary */
-    DEBUG_LoadSymbols((*argv)[0]);
+        /* load debugging symbols for current binary */
+        DEBUG_LoadSymbols((*argv)[0]);
 #endif /* DEBUG */
+    }
 
     /* Initialise the stats department, phase 1 */
     initStats1();