On Thu, 12 Aug 2021 16:16:04 -0700 Ian Lance Taylor wrote: > On Thu, Aug 12, 2021 at 3:34 PM Sergei Trofimovich via Gcc-patches > wrote: > > > > From: Sergei Trofimovich > > > > 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. Oh, great point! Completely missed it. Changed the patch to poll for present file descriptors with fcntl(fd, F_GETFD) to compare before/after. -- Sergei