#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-02-21 19:17: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.