summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
67419f2)
The GC wasn't properly marking pending signal handlers, which could
lead to "EVACUATED object entered!" errors. Also, a race occurs if a
signal arrives during GC. Two fixes:
(a) mark all pending signal handlers during GC, and
(b) block signals during GC
MERGE TO STABLE
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
- * $Id: GC.c,v 1.141 2002/09/10 10:43:52 simonmar Exp $
+ * $Id: GC.c,v 1.142 2002/09/17 12:11:44 simonmar Exp $
*
* (c) The GHC Team 1998-1999
*
*
* (c) The GHC Team 1998-1999
*
#include "Prelude.h"
#include "ParTicky.h" // ToDo: move into Rts.h
#include "GCCompact.h"
#include "Prelude.h"
#include "ParTicky.h" // ToDo: move into Rts.h
#include "GCCompact.h"
#if defined(GRAN) || defined(PAR)
# include "GranSimRts.h"
# include "ParallelRts.h"
#if defined(GRAN) || defined(PAR)
# include "GranSimRts.h"
# include "ParallelRts.h"
+ // block signals
+ blockUserSignals();
+
// tell the stats department that we've started a GC
stat_startGC();
// tell the stats department that we've started a GC
stat_startGC();
// ok, GC over: tell the stats department what happened.
stat_endGC(allocated, collected, live, copied, N);
// ok, GC over: tell the stats department what happened.
stat_endGC(allocated, collected, live, copied, N);
+ // unblock signals again
+ unblockUserSignals();
+
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
- * $Id: Signals.c,v 1.28 2002/09/06 14:34:13 simonmar Exp $
+ * $Id: Signals.c,v 1.29 2002/09/17 12:11:45 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
*
* (c) The GHC Team, 1998-1999
*
+/* ----------------------------------------------------------------------------
+ * Mark signal handlers during GC.
+ *
+ * We do this rather than trying to start all the signal handlers
+ * prior to GC, because that requires extra heap for the new threads.
+ * Signals must be blocked (see blockUserSignals() above) during GC to
+ * avoid race conditions.
+ * -------------------------------------------------------------------------- */
+
+void
+markSignalHandlers (evac_fn evac)
+{
+ StgPtr *p;
+
+ p = next_pending_handler;
+ while (p != pending_handler_buf) {
+ p--;
+ evac((StgClosure **)p);
+ }
+}
+
#else // PAR
StgInt
stg_sig_install(StgInt sig, StgInt spi, StgStablePtr handler, sigset_t *mask)
#else // PAR
StgInt
stg_sig_install(StgInt sig, StgInt spi, StgStablePtr handler, sigset_t *mask)
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
- * $Id: Signals.h,v 1.7 2002/03/12 13:57:14 simonmar Exp $
+ * $Id: Signals.h,v 1.8 2002/09/17 12:11:45 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
*
* (c) The GHC Team, 1998-1999
*
/* sig_install declared in PrimOps.h */
extern void startSignalHandlers(void);
/* sig_install declared in PrimOps.h */
extern void startSignalHandlers(void);
+extern void markSignalHandlers (evac_fn evac);
extern void initDefaultHandlers(void);
#else
extern void initDefaultHandlers(void);
#else