Do not segfault if no common root can be found
authorMoritz Angermann <moritz.angermann@gmail.com>
Sun, 9 Oct 2016 22:17:46 +0000 (18:17 -0400)
committerBen Gamari <ben@smart-cactus.org>
Sun, 9 Oct 2016 22:17:51 +0000 (18:17 -0400)
When trying to profile a plugin, ghc mysteriously segfaulted.  Upon
closer examination the segfault happend due to a `->prevStack` lookup
on a NULL pointer.

A new CostCentre: Unknown is introduced that is set, if ccsapp and
ccsfn are of equal depth (e.g. 0), and do not have a common CostCentre
in their stacks.

Reviewers: bgamari, simonmar, austin, erikd

Reviewed By: simonmar

Subscribers: Phyx, thomie

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

rts/Linker.c

index f16fb83..3eeb46e 100644 (file)
@@ -1399,6 +1399,11 @@ static SymbolAddr* lookupSymbol_ (SymbolName* lbl)
                 errorBelch("Could not on-demand load symbol '%s'\n", lbl);
                 return NULL;
             }
+#ifdef PROFILING
+            // collect any new cost centres & CCSs
+            // that were defined during runInit
+            initProfiling2();
+#endif
         }
 
         return val;