Skip to content

Commit

Permalink
Merge pull request #1377 from jluebbe/fix-service-leaks
Browse files Browse the repository at this point in the history
fix minor memory leaks in the D-Bus service and related tests
  • Loading branch information
ejoerns committed Apr 5, 2024
2 parents 88b1192 + a2d3517 commit 05772ed
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/sanitizers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
build/test/nbd-test
build/test/network-test
build/test/progress-test
build/test/service-test -l
build/test/service-test
build/test/signature-test
build/test/slot-test
build/test/stats-test
Expand Down
2 changes: 1 addition & 1 deletion qemu-test
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ fi
qemu-system-x86_64 \
$QEMU_ARGS \
-machine q35 \
-m 512M \
-m 1G \
-smp 2 \
-kernel bzImage \
-nographic -serial mon:stdio \
Expand Down
7 changes: 4 additions & 3 deletions qemu-test-init
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ mount -t tmpfs none /tmp
mkdir /tmp/etc-overlay /tmp/etc-work
mount -t overlay overlay -o lowerdir=/etc,upperdir=/tmp/etc-overlay,workdir=/tmp/etc-work /etc

# switch to rauc dir
cd "$(dirname "$0")"

BUILD_DIR="build/"

# parse cmdline
Expand All @@ -29,6 +32,7 @@ for x in $(cat /proc/cmdline); do
elif [ "$x" = "asan" ]; then
export G_SLICE=always-malloc G_DEBUG=gc-friendly
export ASAN_OPTIONS=malloc_context_size=64:fast_unwind_on_malloc=0
export LSAN_OPTIONS=suppressions="$(pwd)/test/asan.supp"
elif [ "$x" = "service-backtrace" ]; then
SERVICE_BACKTRACE=1
fi
Expand All @@ -50,9 +54,6 @@ ip link set eth0 up
ip route add default via 10.0.2.2
echo "nameserver 10.0.2.3" > /etc/resolv.conf

# switch to rauc dir
cd "$(dirname "$0")"

# allow git access to our repo
git config --system --add safe.directory "$(pwd)"

Expand Down
2 changes: 1 addition & 1 deletion src/install.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ gboolean determine_boot_states(GError **error)
/* get boot state */
g_hash_table_iter_init(&iter, r_context()->config->slots);
while (g_hash_table_iter_next(&iter, NULL, (gpointer*) &slot)) {
GError *ierror = NULL;
g_autoptr(GError) ierror = NULL;

if (!slot->bootname)
continue;
Expand Down
2 changes: 1 addition & 1 deletion src/service.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ static gboolean service_install_notify(gpointer data)

g_mutex_lock(&args->status_mutex);
while (!g_queue_is_empty(&args->status_messages)) {
gchar *msg = g_queue_pop_head(&args->status_messages);
g_autofree gchar *msg = g_queue_pop_head(&args->status_messages);
g_message("installing %s: %s", args->name, msg);
}
g_mutex_unlock(&args->status_mutex);
Expand Down
1 change: 1 addition & 0 deletions test/asan.supp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
leak:g_private_set_alloc0
1 change: 1 addition & 0 deletions test/boot_raw_fallback.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ static void test_boot_raw_fallback(BootRawFallbackFixture *fixture,

if (data->options & OPT_EXPECT_FAIL) {
g_assert_error(ierror, data->err_domain, data->err_code);
g_clear_error(&ierror);
g_assert_false(res);
goto out;
} else {
Expand Down
5 changes: 3 additions & 2 deletions test/boot_switch.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ typedef struct {

static gchar *sfdisk_get(const gchar *device)
{
GSubprocess *sub;
g_autoptr(GSubprocess) sub = NULL;
GError *error = NULL;
GBytes *stdout_buf = NULL;
gsize size;
Expand Down Expand Up @@ -129,7 +129,7 @@ static void sfdisk_check(const gchar *device, const gchar *expected)

static void sfdisk_set(const gchar *device, const gchar *dump)
{
GSubprocess *sub;
g_autoptr(GSubprocess) sub = NULL;
GError *error = NULL;
g_autoptr(GBytes) stdin_buf = NULL;
gboolean res = FALSE;
Expand Down Expand Up @@ -366,6 +366,7 @@ static void test_boot_switch(BootSwitchFixture *fixture,

if (data->params & BOOT_SWITCH_EXPECT_FAIL) {
g_assert_error(ierror, data->err_domain, data->err_code);
g_clear_error(&ierror);
g_assert_false(res);
goto out;
} else {
Expand Down
2 changes: 2 additions & 0 deletions test/service.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ static void service_fixture_tear_down(ServiceFixture *fixture, gconstpointer use
g_assert_no_error(error);
g_assert_true(ret);
g_free(fixture->tmpdir);

g_clear_pointer(&testloop, g_main_loop_unref);
}

static void on_installer_changed(GDBusProxy *proxy, GVariant *changed,
Expand Down

0 comments on commit 05772ed

Please sign in to comment.