From b1e4eaf59f675eed93d4eb0b8cde2f7ae33e5e2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20V=C3=A1rady?= Date: Mon, 27 May 2024 12:42:13 +0200 Subject: [PATCH 1/4] driver: extract _log_dest_driver_release_queues() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: László Várady --- lib/driver.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/driver.c b/lib/driver.c index 7c5a6afb8e..b1f8f9122e 100644 --- a/lib/driver.c +++ b/lib/driver.c @@ -387,10 +387,9 @@ _log_dest_driver_unregister_counters(LogDestDriver *self) stats_unlock(); } -gboolean -log_dest_driver_deinit_method(LogPipe *s) +static inline void +_log_dest_driver_release_queues(LogDestDriver *self) { - LogDestDriver *self = (LogDestDriver *) s; GList *l, *l_next; for (l = self->queues; l; l = l_next) @@ -404,7 +403,16 @@ log_dest_driver_deinit_method(LogPipe *s) * which automatically frees the ref on the list too */ log_dest_driver_release_queue(self, log_queue_ref(q)); } + g_assert(self->queues == NULL); +} + +gboolean +log_dest_driver_deinit_method(LogPipe *s) +{ + LogDestDriver *self = (LogDestDriver *) s; + + _log_dest_driver_release_queues(self); _log_dest_driver_unregister_counters(self); From f21fe57c1bca8a9bd044140906fa3c214fd0ea9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20V=C3=A1rady?= Date: Mon, 27 May 2024 12:43:41 +0200 Subject: [PATCH 2/4] driver: release the queues of half-initialized pipes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes a crash when init() fails on a disk-buffered destination: > modules/diskq/logqueue-disk.c:127:log_queue_disk_free_method: > assertion failed: (!qdisk_started(self->qdisk)) Signed-off-by: László Várady --- lib/driver.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/driver.c b/lib/driver.c index b1f8f9122e..4effc0cedb 100644 --- a/lib/driver.c +++ b/lib/driver.c @@ -439,12 +439,9 @@ void log_dest_driver_free(LogPipe *s) { LogDestDriver *self = (LogDestDriver *) s; - GList *l; - for (l = self->queues; l; l = l->next) - { - log_queue_unref((LogQueue *) l->data); - } - g_list_free(self->queues); + /* half-initialized pipes can't release their queue in deinit() */ + _log_dest_driver_release_queues(self); + log_driver_free(s); } From 545258653f14b90adf127e8f0af518d46eb5b4f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20V=C3=A1rady?= Date: Mon, 27 May 2024 12:44:46 +0200 Subject: [PATCH 3/4] logthrdest: destroy all workers when _acquire_worker_queue() fails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: László Várady --- lib/logthrdest/logthrdestdrv.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/logthrdest/logthrdestdrv.c b/lib/logthrdest/logthrdestdrv.c index 8404dd84fe..09075de99c 100644 --- a/lib/logthrdest/logthrdestdrv.c +++ b/lib/logthrdest/logthrdestdrv.c @@ -1352,7 +1352,11 @@ _create_workers(LogThreadedDestDriver *self, gint stats_level, StatsClusterKeyBu self->workers[self->created_workers] = dw; if (!_acquire_worker_queue(dw, stats_level, driver_sck_builder)) - return FALSE; + { + /* failed worker needs to be destroyed */ + self->created_workers++; + return FALSE; + } } return TRUE; From 629fb42fd7d3d7127e4e19615141974a22618f69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20V=C3=A1rady?= Date: Mon, 27 May 2024 12:48:04 +0200 Subject: [PATCH 4/4] news: add entry for #128 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: László Várady --- news/bugfix-128.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 news/bugfix-128.md diff --git a/news/bugfix-128.md b/news/bugfix-128.md new file mode 100644 index 0000000000..380adf6167 --- /dev/null +++ b/news/bugfix-128.md @@ -0,0 +1,3 @@ +`disk-buffer()`: fix crash when pipeline initialization fails + +`log_queue_disk_free_method: assertion failed: (!qdisk_started(self->qdisk))`