rts/LdvProfile.c: Fix NULL dereference on shutdown
authorErik de Castro Lopo <erikd@mega-nerd.com>
Thu, 28 Apr 2016 21:15:53 +0000 (07:15 +1000)
committerErik de Castro Lopo <erikd@mega-nerd.com>
Thu, 28 Apr 2016 21:17:19 +0000 (07:17 +1000)
Test Plan: validate

Reviewers: carter, austin, simonmar, bgamari

Reviewed By: simonmar, bgamari

Subscribers: thomie

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

GHC Trac Issues: #11978

rts/LdvProfile.c
testsuite/tests/profiling/should_run/T11978a.hs [new file with mode: 0644]
testsuite/tests/profiling/should_run/T11978a.stdout [new file with mode: 0644]
testsuite/tests/profiling/should_run/all.T

index 2330d74..4a2ee42 100644 (file)
@@ -178,6 +178,9 @@ processNurseryForDead( void )
     StgPtr p;
     bdescr *bd;
 
+    if (MainCapability.r.rNursery == NULL)
+        return;
+
     for (bd = MainCapability.r.rNursery->blocks; bd != NULL; bd = bd->link) {
         p = bd->start;
         while (p < bd->free) {
diff --git a/testsuite/tests/profiling/should_run/T11978a.hs b/testsuite/tests/profiling/should_run/T11978a.hs
new file mode 100644 (file)
index 0000000..bb859f3
--- /dev/null
@@ -0,0 +1,2 @@
+main :: IO ()
+main = putStrLn "Hello!"
diff --git a/testsuite/tests/profiling/should_run/T11978a.stdout b/testsuite/tests/profiling/should_run/T11978a.stdout
new file mode 100644 (file)
index 0000000..10ddd6d
--- /dev/null
@@ -0,0 +1 @@
+Hello!
index c6ce6d4..1f74a27 100644 (file)
@@ -106,3 +106,7 @@ test('T11627b', [ extra_run_opts('+RTS -i0 -RTS')  # census after each GC
                 ]
                 , compile_and_run
                 , [''])
+
+test('T11978a',
+     [only_ways(['profthreaded']), extra_run_opts('+RTS -hb -N10')],
+     compile_and_run, [''])