#1127746 motion leaks file descriptors leading to missing recordings

Package:
motion
Source:
motion
Description:
V4L capture program supporting motion detection
Submitter:
Thadeu Lima de Souza Cascardo
Date:
2026-09-20 15:57:02 UTC
Severity:
normal
#1127746#5
Date:
2026-02-12 14:02:26 UTC
From:
To:
Dear Maintainer,

	Sometimes, motion stops recording. When I inspect the process,
	it has open files pointing to old recordings (by looking at
	/proc/<PID>/fd/).
	When running strace, there are plenty of EMFILES errors.

	Restarting the process makes it work again. But by the time, the
	issue is noticed, lots of recordings have been lost, which is a
	serious data loss.

	I cannot tell what leads to this situation. My only guess would
	be that I have a cronjob that removes old files (more than 30
	days old).

	I would like to close saying that I appreciate the work done in
	maintaining the package.

	Thanks.
	Cascardo.

#1127746#10
Date:
2026-02-20 15:30:48 UTC
From:
To:
Hello,

I don't deny you have an issue, but setting the flag critical for an
issue you have with the package in stable may be a little bit much?

The bug also flags the package for autoremoval in testing...

Concerning your issue, can you be more specific on the problems?
I'm using motion for a long time myself and I never had such problems.
Maybe you can look at your system configuration, for example if you save
the files on a remote location that could lead to files lock issues?

If the problem doesn't come from the package itself, we'll transfer it
upstream then.

/Nicolas

#1127746#17
Date:
2026-02-21 19:05:30 UTC
From:
To:
Sorry, I was following the criteria that it makes me lose data (the
video that I wanted to save) that cannot be restored (no way to backup
upfront new videos). That has made some family members frustrated that
the NVR I setup does not work reliably.

I don't mind that the priority is downgrade, as long as the issue is
taken seriously and it results in an updated package. I would rather not
have to rebuild the package myself everytime there is an update.

I had the chance to look at it. Unfortunately, it seems upstream has
moved the codebase, even changing from C to C++. From what I could
conclude, the new codebase does not suffer from the same issue, that is,
it is already fixed there. But not the version in Debian stable.

Attached is a proposed fix (that needs to be properly massaged to be
applied for an archive upload). If attribution to the fix can be added,
please use:

Thadeu Lima de Souza Cascardo <cascardo@debian.org>

Thanks.
Cascardo.

#1127746#22
Date:
2026-09-20 15:56:13 UTC
From:
To:
We believe that the bug you reported is fixed in the latest version of
motion, 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 1127746@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Nicolas Mora <babelouest@debian.org> (supplier of updated motion 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 ftpmaster@ftp-master.debian.org)
Format: 1.8
Date: Thu, 17 Sep 2026 17:25:48 -0400
Source: motion
Architecture: source
Version: 4.7.1-2
Distribution: unstable
Urgency: medium
Maintainer: Nicolas Mora <babelouest@debian.org>
Changed-By: Nicolas Mora <babelouest@debian.org>
Closes: 1127746 1137740
Changes:
 motion (4.7.1-2) unstable; urgency=medium
 .
   [Thadeu Lima de Souza Cascardo]
   * d/patches: Apply fix_file_leak.patch (Closes: #1127746)
 .
   [Nicolas Mora]
   * d/control: Remove Priority: Optional
   * d/control: Update standards version to 4.7.4
   * d/control: Update debhelper compat version to 14
   * d/control: use libmariadb-dev-compat instead of default-libmysqlclient-dev
     (Closes: #1137740)
   * d/motion.install: Add install file to comply with debhelper 14
   * d/patches: Add glibc-2.43.patch to fix glibc 2.43 warnings
   * d/rules: Update motion.conf rename path to comply with debhelper 14
Checksums-Sha1:
 b6bb5132fd8d82abc9b8c33e3d49f68092c81e7b 2088 motion_4.7.1-2.dsc
 f593875cfafd979ed37e30454eff790d7d7ba01b 822351 motion_4.7.1.orig.tar.gz
 a4391e399b13f0c71a6ab51a788ec7870ddc13c3 20024 motion_4.7.1-2.debian.tar.xz
 b78ed9f25dc10c78843218c243e32207ac285988 12011 motion_4.7.1-2_amd64.buildinfo
Checksums-Sha256:
 bc09dba42e0b8e87cb6af4df85dbea26af09e0f37889b4213aed91e72e0f87d8 2088 motion_4.7.1-2.dsc
 c11f68c7cea949227e57797b932f01432d8942ef5323c75063d19b951d0d4194 822351 motion_4.7.1.orig.tar.gz
 4cb07189b74e6689e765aadaeb5ac983e5f5b3c282e7ff207c3eecd1d110c279 20024 motion_4.7.1-2.debian.tar.xz
 7c10d005bc58553066f83762d0b9536d91ff94b316b0759320331103262eaf76 12011 motion_4.7.1-2_amd64.buildinfo
Files:
 fe6b5cdd46f3c61d91981df58f4eb669 2088 video optional motion_4.7.1-2.dsc
 e9ea9eecebd2f3f5919db14d06077016 822351 video optional motion_4.7.1.orig.tar.gz
 302517d350570f9d1c7efbe656484655 20024 video optional motion_4.7.1-2.debian.tar.xz
 961ca5f3305a3398359d5b51334ce1c8 12011 video optional motion_4.7.1-2_amd64.buildinfo
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEhAWwL8wo75dEyPJT/oITlEC9IrkFAmqv+F0ACgkQ/oITlEC9
IrnrqA//fYdNysUhtjKg2kudMjapEfs2mxMp8VaJazw3g+2JkHPJP1i7VffdwPU5
qj28RPeoqVUH1gr0UJceIhW8O3H2pe5wrdwI3vkoeCiDlsxNIv8ZKF4lMWdRDRlw
HQptFkK0WsyerPyI+NwB3GY9GNSt39NKrEuFLRwSmwKqR3b74HTqT4E9CHZiQxiE
cJRB1DtDVbKEKGaR5/IU77mQt0fCjiApr2vvdEBnTY0h2OBjOrhJj44Hu97suOcS
2DR4/0yjw/wV0RUyiGouGhyqG4ZSuYW4z6aVKUc+4Md1vhya8GsOfBSSv7TlGssQ
U+5HprhfjKUB7bH7b+FNPDnNVCyxI5FeXR2W6U8Pog8SQvVqW0kCiismK6sHn69y
4/VrbdJSetstcAImP8+ubyEm+u76bCisbdT5H8XpQL3aqkLxKkVwwgVHinUrdZIq
+yxkEkLGX3+0VhXLs5QylexLE/ptzwjYlsEIySdCBgGBq49xDMqXIcRSpIK19b+I
1tpZvP8QXRo0CIXvYxwqA7gHz+d43lOc5mCB6yvsEdF7x6XVtJo675k7Xj4ko3Lf
jcMfrD0Ix1/4O1noHY7Tz8m7EsrSwN3Zpc/MZXEUd2SQQZVjRfKEcmApHnNQRDNB
oZmtZHDf5mcTplzFrUlPMWuXo4+wh/AlHuReVUYIKAwBLjstz20=
=HlbJ
-----END PGP SIGNATURE-----