On Thu, Aug 12, 2021 at 3:34 PM Sergei Trofimovich via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > From: Sergei Trofimovich <siarh...@google.com> > > I noticed test failures when ran gcc test suite from under mc shell. > mc opens fd=9 and exposes it to child processes. As a result a few > tests failes: > FAIL: b2test_buildid > FAIL: btest_gnudebuglink > FAIL: btest > FAIL: btest_lto > FAIL: btest_alloc > FAIL: ctestg > FAIL: ctesta > FAIL: ctestg_alloc > FAIL: ctesta_alloc > FAIL: dwarf5 > FAIL: dwarf5_alloc > > Instead of trying to close file descripts in range test polls for > first available file descriptor by creating it via dup(1). > > libbacktrace/ > > * btest.c (check_open_files): Use last free file descriptor as a > signal for flie descriptor leak.
This isn't a useful replacement, as this will pass as long as libbacktrace closes the first file descriptor that it opens. It won't check whether libbacktrace left any other file descriptors open. Perhaps at program startup we could fstat descriptors up to 10 and record whether they are valid, and then skip those files in check_open_files. Ian