From 5f7d8416c6616b452a02ff5d85e59d923af66e8f Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sun, 13 Aug 2023 23:33:12 -0700 Subject: modules/rtv: don't gc from cleanup_channel() cleanup_channel() is called from rtv_destroy_context(), which can be called by a gc. The gc isn't reentrant and generally isn't expecting this, so it breaks in hilarious ways when this happens, usually ending in a segfault. gc should probably get some defenses for asserting on reentry... for now let's just prevent crashing by removing the gc call from the destroy path. --- src/modules/rtv/rtv.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/modules/rtv/rtv.c b/src/modules/rtv/rtv.c index bfd4e57..5853296 100644 --- a/src/modules/rtv/rtv.c +++ b/src/modules/rtv/rtv.c @@ -137,8 +137,6 @@ static void cleanup_channel(rtv_context_t *ctxt) ctxt->channel->settings_as_arg = NULL; ctxt->caption = ctxt->channel->caption = txt_free(ctxt->channel->caption); - - til_stream_gc_module_contexts(ctxt->til_module_context.stream); } @@ -151,8 +149,13 @@ static void setup_next_channel(rtv_context_t *ctxt, unsigned ticks) */ if (ctxt->channel) { ctxt->channel->cumulative_time += now - ctxt->channel->last_on_time; - if (ctxt->channel->cumulative_time >= ctxt->context_duration) + if (ctxt->channel->cumulative_time >= ctxt->context_duration) { cleanup_channel(ctxt); + /* XXX: gc used to be part of cleanup_channel(), but rtv_destroy_context() uses it + * as well, creating a potential recursive gc and things go boom. + */ + til_stream_gc_module_contexts(ctxt->til_module_context.stream); + } } if (!ctxt->n_channels || -- cgit v1.2.1