From: Paul Floyd Date: Sat, 15 Jun 2024 15:09:05 +0000 (+0200) Subject: FreeBSD: mostly filters and suppressions for fdleak tests X-Git-Tag: VALGRIND_3_24_0~112 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=33eb3718a1b695da4fd453da21c1fe5fa17f01f3;p=thirdparty%2Fvalgrind.git FreeBSD: mostly filters and suppressions for fdleak tests Also make close_range behave like linux when highfd is UINT_MAX. We should probably move close_range to generic. --- diff --git a/coregrind/m_syswrap/syswrap-freebsd.c b/coregrind/m_syswrap/syswrap-freebsd.c index 426fa6015..b9532542a 100644 --- a/coregrind/m_syswrap/syswrap-freebsd.c +++ b/coregrind/m_syswrap/syswrap-freebsd.c @@ -6862,7 +6862,7 @@ POST(sys___realpathat) #if (FREEBSD_VERS >= FREEBSD_12_2) // SYS_sys_close_range 575 -// int close_range(close_range(u_int lowfd, u_int highfd, int flags); +// int close_range(u_int lowfd, u_int highfd, int flags); PRE(sys_close_range) { SysRes res = VG_(mk_SysRes_Success)(0); @@ -6923,11 +6923,17 @@ POST(sys_close_range) if (last >= VG_(fd_hard_limit)) last = VG_(fd_hard_limit) - 1; - for (fd = ARG1; fd <= last; fd++) - if ((fd != 2/*stderr*/ || VG_(debugLog_getLevel)() == 0) - && fd != VG_(log_output_sink).fd - && fd != VG_(xml_output_sink).fd) - ML_(record_fd_close)(tid, fd); + /* If the close_range range is too wide, we don't want to loop + through the whole range. */ + if (ARG2 == ~0U) + ML_(record_fd_close_range)(tid, ARG1); + else { + for (fd = ARG1; fd <= last; fd++) + if ((fd != 2/*stderr*/ || VG_(debugLog_getLevel)() == 0) + && fd != VG_(log_output_sink).fd + && fd != VG_(xml_output_sink).fd) + ML_(record_fd_close)(tid, fd); + } } #endif diff --git a/none/tests/fdleak_cmsg_supp.supp b/none/tests/fdleak_cmsg_supp.supp index 5644147a9..92fbacabd 100644 --- a/none/tests/fdleak_cmsg_supp.supp +++ b/none/tests/fdleak_cmsg_supp.supp @@ -1,7 +1,7 @@ { sup1 CoreError:FdNotClosed - fun:accept + fun:*accept fun:server fun:main } @@ -15,33 +15,28 @@ { sup3 CoreError:FdNotClosed - fun:*open* - fun:server - fun:main -} -{ - sup4 - CoreError:FdNotClosed + ... fun:*open* fun:server #fun:main } { - sup5 + sup4 CoreError:FdNotClosed fun:recvmsg fun:client fun:main } { - sup6 + sup5 CoreError:FdNotClosed + ... fun:recvmsg fun:client fun:main } { - sup7 + sup6 CoreError:FdNotClosed fun:socket fun:client diff --git a/none/tests/filter_xml b/none/tests/filter_xml index 70fdb6579..d1ef570a0 100755 --- a/none/tests/filter_xml +++ b/none/tests/filter_xml @@ -2,6 +2,12 @@ dir=`dirname $0` +# FreeBSD adds this one extra line +# but after filter_xml_frames it will just be ...<\/path> +# which matches other lines, so get rid of it while we can +# uniquely match it +sed "/internet<\/path>/d" | + $dir/../../tests/filter_xml_frames | perl -p -e "s/