Your message dated Sat, 29 Jul 2023 19:35:31 +0000
with message-id <e1qppit-004n2z...@fasolo.debian.org>
and subject line Bug#1042001: fixed in libblockdev 3.0.2-3
has caused the Debian Bug report #1042001,
regarding libblockdev3 leaks empty directories in bd_fs_get_free_space on btrfs
partition
to be marked as done.
This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.
(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact ow...@bugs.debian.org
immediately.)
--
1042001: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1042001
Debian Bug Tracking System
Contact ow...@bugs.debian.org with problems
--- Begin Message ---
Package: libblockdev3
Version: 3.0.2-1
Severity: normal
Tags: upstream
Dear Maintainer,
libblockdev seems to leak empty temporary directories, when the function
bd_fs_get_free_space is called (even unsuccessfully) on a btrfs partition as it
calls fs_mount internally, which then either fails and exhibits the behavior OR
succeeds and btrfs_get_info leaks the directory.
I am relatively sure that this is not limited to btrfs, but that is what I have
here.
I noticed this while steam was running and my /tmp directory was suddenly
overflowing with hundreds of blockdev.XXXXXX directories. I don't know what
steam does there or if it is in fact steam itself, proton or something else,
but libblockdev should not leak the directories.
This little piece of code demonstrates the problem. It does not matter, if the
device exists or not. It just cannot be mounted already.
Run it and an empty blockdev.XXXXXX dir remains in /tmp
#include <blockdev/blockdev.h>
#include <blockdev/fs/generic.h>
#include <stdio.h>
int main()
{
GError *err = NULL;
BDPluginSpec fs_plugin = {BD_PLUGIN_FS, NULL};
BDPluginSpec *plugins[] = {&fs_plugin, NULL};
if (!bd_init(plugins, NULL, &err)) {
fprintf(stdout, "failed to init lib: %s\n", err->message);
}
err = NULL;
guint64 space = bd_fs_get_free_space("/dev/sda1", "btrfs", &err);
if (space == 0) {
fprintf(stdout, "failed to get fs size: %s\n", err->message);
} else {
fprintf(stdout, "%d\n", space);
}
return 0;
}
As far as I can see, the following patch should remedy at least the unsuccessul
path, where the device cannot be mounted. However, I have not tested this!!
diff --git a/src/plugins/fs/generic.c b/src/plugins/fs/generic.c
index 21032b8a..843de8b1 100644
--- a/src/plugins/fs/generic.c
+++ b/src/plugins/fs/generic.c
@@ -650,6 +650,7 @@ static gchar* fs_mount (const gchar *device, gchar *fstype,
gboolean read_only,
if (!ret) {
g_propagate_prefixed_error (error, l_error, "Failed to mount '%s':
", device);
g_free (mountpoint);
+ g_rmdir (tempdir);
return NULL;
} else
*unmount = TRUE;
I am not sure how to handle the successful calls to fs_mount from the other
functions in that file. Do we really need to delete the dir downstream in all
the calling functions? Seems strange to me, but I don't see a different
solution right now.
Ps:
fs_mount() might also leak a little memory in case it creates the tmp mount,
but I am not certain enough about the behavior of glib2 here (i.e. valgrind
does not immediately see this as a definite leak). reassigning 'mountpoint'
with the result of g_mkdtemp() looks as if the original memory, returned by
g_build_path() is lost? The glib documentation at least suggests a leak here.
from line 642ff:
mountpoint = g_build_path (G_DIR_SEPARATOR_S, g_get_tmp_dir (),
"blockdev.XXXXXX", NULL);
mountpoint = g_mkdtemp (mountpoint);
Regards
Andre
-- System Information:
Debian Release: trixie/sid
APT prefers unstable-debug
APT policy: (500, 'unstable-debug'), (500, 'unstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 6.3.0-2-amd64 (SMP w/12 CPU threads; PREEMPT)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
Versions of packages libblockdev3 depends on:
ii libblockdev-utils3 3.0.2-1
ii libc6 2.37-6
ii libglib2.0-0 2.76.4-3
libblockdev3 recommends no packages.
libblockdev3 suggests no packages.
-- no debconf information
--- End Message ---
--- Begin Message ---
Source: libblockdev
Source-Version: 3.0.2-3
Done: Michael Biebl <bi...@debian.org>
We believe that the bug you reported is fixed in the latest version of
libblockdev, which is due to be installed in the Debian FTP archive.
A summary of the changes between this version and the previous one is
attached.
Thank you for reporting the bug, which will now be closed. If you
have further comments please address them to 1042...@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.
Debian distribution maintenance software
pp.
Michael Biebl <bi...@debian.org> (supplier of updated libblockdev package)
(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmas...@ftp-master.debian.org)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Format: 1.8
Date: Sat, 29 Jul 2023 09:00:22 +0200
Source: libblockdev
Architecture: source
Version: 3.0.2-3
Distribution: unstable
Urgency: medium
Maintainer: Utopia Maintenance Team
<pkg-utopia-maintain...@lists.alioth.debian.org>
Changed-By: Michael Biebl <bi...@debian.org>
Closes: 1042001
Changes:
libblockdev (3.0.2-3) unstable; urgency=medium
.
* fs: Fix leaking directories with temporary mounts (Closes: #1042001)
Checksums-Sha1:
d44c99f23b2789977fd8cd85553a29e7178c1aa0 5496 libblockdev_3.0.2-3.dsc
bb2a1b6c85dae7f19dc7cbb438dfb9546054b1f1 13888
libblockdev_3.0.2-3.debian.tar.xz
bf8e357a286645ab5afbc18cf0e819c5272f6e1f 14878
libblockdev_3.0.2-3_source.buildinfo
Checksums-Sha256:
b795770e534de500ef9dfddfbfa409f6253c1512a4b09e26bf3a531113c29696 5496
libblockdev_3.0.2-3.dsc
5b7edad2349799a47c60ec7b7d875d7ce5d721611730f4a5476934cec79266df 13888
libblockdev_3.0.2-3.debian.tar.xz
da2a17bbd2c701efa53092f89b2db4b0522e3481c558f3a48614825776e7d93e 14878
libblockdev_3.0.2-3_source.buildinfo
Files:
37425c349e582443f10991d53e08541c 5496 libs optional libblockdev_3.0.2-3.dsc
0045f9c6a78d398b49a670fb43ee8f2a 13888 libs optional
libblockdev_3.0.2-3.debian.tar.xz
4e611851a1bd0ce44e4f9e6c51718418 14878 libs optional
libblockdev_3.0.2-3_source.buildinfo
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCAAdFiEECbOsLssWnJBDRcxUauHfDWCPItwFAmTFZZQACgkQauHfDWCP
ItwzmhAAlpxURv/om3FrYMN8bbKJ3TsODDPwwSwGCelG7uyJVlXquYTNhujV76Za
QBPW7wpjvMhOnmUCA6LM2gOrN2YB/UTuoIWEZZHddZ/ITdhDpEa6qbWDvkxi121w
4o3pEWfLQE2oq4B3N4NjnAaCWMosB69JMmgVTUFd3ktdkQTfq5XzjXT+5yru1mO3
hr0jo4L/vA/F0rHcxg6mQVAo3t4kWT0CXO0vLOf2+NwtrAZOpH1a9NdCgn0Bp0eE
16ZVc59g3c0+6Vqga+NImqV3rJSiJ+k4mUEMOQNMXWeuXIPwKX9VA10eTufPMe54
ChjQqI/vdrnyoENl6km/EE/yNOF9kBFEFn1OqCetpQD+uKsQg5ASaBsvfPnR0BWX
z3raimG+qaL72IayLoUnyJ2MSBISxNR2pkvr2OyuiN+kmHLltraqMi2ckhU9uPYg
yFQqXUh/MRz2Ahc01Qcm6ZP5IPJimfo6uuQT2dHlDu6CO0r/VeR1cBk9doOHXdxP
i86ypmlI3EPDTMsxeUXdAVZmJ1MVgtQhp4jlCzQoGGLqNBD80ZvIENwg24x2sw2/
BXJ8INDgZtg+PxF+rYUHR8h8LBE4pgBhBfnWpluYXrxPjTeUqykeWnY47ROCWs4g
jLX1BsIFxZj2+J95pQi5edyGm39GMsS8oZEaacit+n/VpOQvkZ4=
=bn+1
-----END PGP SIGNATURE-----
--- End Message ---
_______________________________________________
Pkg-utopia-maintainers mailing list
Pkg-utopia-maintainers@alioth-lists.debian.net
https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/pkg-utopia-maintainers