Open jtru opened 1 year ago
Whatever you're using to run make
is probably leaking file descriptors into the process. Try changing this to close file descriptors up to 200.
Ah! I was not aware of that piece of code that should make open fds meet expectations in the first place :)
I can confirm making that loop go up to fd < 200
(or any other number that makes it also traverse and also close()
fd 24
) fixes the failing test. I guess cosmopolitan/libc/testlib/testmain.c
should be adapted to close at least the range of fds that CheckForFileLeaks()
patrols to check for leakage.
And thanks very much for the astonishingly quick reply, btw! ;)
I've been testing the latest 3.0 release on my Arch Linux/KDE Plasma 5 desktop system, and stumbled over a curious test failure in
test/libc/thread/mu_semaphore_sem_test.com
, which looks like this:Unable to reproduce the issue in other environments I have access to, I dug a little deeper, and found this oddity that makes my desktop system differ from the others (which are mostly Debian-based headless servers):
Closing that fd in the shell invoking the test fixes the observed problem:
So, something in my env makes all the interactive shells I run as children of my graphical login session inherit an inotify-related fd for reasons I do not yet understand. For posterity, the process tree at this particular moment in time looked like this:
... and it seems like
plasmashell
is responsible for the culprit (fd 24) that leaks into its descendants:Maybe this is intentional by KDE Plasma, maybe whatever causes this missed to apply
FD_CLOEXEC
to the fd after having created it, or maybe something else is the reason for the observed behavior... I am not sure yet, but will try to look into it.Whatever the real reason, I guess there could be other environments where this is a problem, too, and cannot be fixed as trivially as in my case. Having run into the problem this way, I feel unsure whether the implemented testing logic is what really is required/wanted...
Looking at
test/libc/thread/mu_semaphore_sem_test.c
, that callsCheckForFileLeaks()
, defined inlibc/stdio/fleaks.c
, where all open fds less than a magic constant calledMIN_CLANDESTINE_FD
(afaiui arbitrarily defined as100
) and greater than2 (STDERR)
will cause the test to blow up.I think that might be a bit overzealous, and the caller maybe should allow for a list of known-and-OK-to-be-open fds (which the failing test should gather before it starts it pthread-related mutex frenzy) to be supplied to prevent the explosive
exit(1)
.What do you think - does this make sense, or is my current env, with that lone and curently unexplained open fd, considered too broken to be supported? :)