paulfloyd / freebsd_valgrind

Git repo used to Upstream the FreeBSD Port of Valgrind
GNU General Public License v2.0
15 stars 4 forks source link

none/tests/fdleak_cmsg fails [FreeBSD 13.1 and later] #164

Closed paulfloyd closed 1 year ago

paulfloyd commented 2 years ago

The raw output, trimmed, is

==66970== Open file descriptor 5: [unknown]
==66970== 
==66970== Open file descriptor 4: [unknown]

But the expected is

Open file descriptor ...: /tmp/data2
   ...

Open file descriptor ...: /tmp/data1
   ...

The diff is

--- fdleak_cmsg.stderr.exp      2022-04-23 13:58:48.410674000 +0200
+++ fdleak_cmsg.stderr.out      2022-04-23 14:43:09.133987000 +0200
@@ -25,10 +25,10 @@

 FILE DESCRIPTORS: 6 open (3 std) at exit.
-Open file descriptor ...: /tmp/data2
+Open file descriptor ...: ...
    ...

-Open file descriptor ...: /tmp/data1
+Open file descriptor ...: ...
    ...

 Open AF_UNIX socket ...: <unknown>

The testcase does a fork and a bunch of file/socket things in both parent and child. And it looks like it's the parent process that is wrong.

And it's probably

Bool VG_(resolve_filename) ( Int fd, const HChar** result )

that is failing.

Need to debug that.

However there is a new way to get the name

https://freebsdfoundation.org/blog/freebsd-foundation-q4-2021-status-update/

and

https://reviews.freebsd.org/D33277

That's in FreeBSD 13.1 14 but not 12.3 or 13 or earlier.

Might just be that this code is not fork-safe. Or a FreeBSD bug?

struct kinfo_file has changed a lot in FreeBSD but I don't think that it is incompatible.

OK debugged resolve_filename, it finds the fd but it contains an empty string.

paulfloyd commented 2 years ago

I tried the new fcntl F_KINFO and (according to someone on IRC) it only does a 'best effort' lookup of the cache. That 'best effort' is not good enough. In particular, all regtests do something like

valgrind test > stdout.err.out 2> stderr.err.out

So fd 1 is (always?) stdout.err.out

And fcntl F_KINFO just returns a blank string "" for these fd 1s. It doesn't return a failure error code either.

paulfloyd commented 1 year ago

Don't get this on my desktop. Could be flakiness as described above that only happens in VBox.