From 055512590fc6fbeb138aa81677452d14ff8bd80a Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Thu, 25 Jul 2013 08:47:28 -0600 Subject: [PATCH] place: fix finalizaiton of place channels stuck in a GC'ed channel Lack of ordering on finalization requires some care for explicit clean-up actions in a finalizer. Back-port of commit a5f26013ab. --- src/racket/src/place.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/racket/src/place.c b/src/racket/src/place.c index 27cdb555a7..7a017f0382 100644 --- a/src/racket/src/place.c +++ b/src/racket/src/place.c @@ -2957,6 +2957,11 @@ Scheme_Place_Async_Channel *place_async_channel_create() { static void async_channel_refcount(Scheme_Place_Async_Channel *ch, int for_send, int delta) { + if (!ch->lock) { + /* can happen via finalization, where the channel is already finalized + (due to the lack of ordering on finalization) */ + return; + } mzrt_mutex_lock(ch->lock); if (for_send) ch->wr_ref += delta;