You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
(122) |
Nov
(152) |
Dec
(69) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(6) |
Feb
(25) |
Mar
(73) |
Apr
(82) |
May
(24) |
Jun
(25) |
Jul
(10) |
Aug
(11) |
Sep
(10) |
Oct
(54) |
Nov
(203) |
Dec
(182) |
2004 |
Jan
(307) |
Feb
(305) |
Mar
(430) |
Apr
(312) |
May
(187) |
Jun
(342) |
Jul
(487) |
Aug
(637) |
Sep
(336) |
Oct
(373) |
Nov
(441) |
Dec
(210) |
2005 |
Jan
(385) |
Feb
(480) |
Mar
(636) |
Apr
(544) |
May
(679) |
Jun
(625) |
Jul
(810) |
Aug
(838) |
Sep
(634) |
Oct
(521) |
Nov
(965) |
Dec
(543) |
2006 |
Jan
(494) |
Feb
(431) |
Mar
(546) |
Apr
(411) |
May
(406) |
Jun
(322) |
Jul
(256) |
Aug
(401) |
Sep
(345) |
Oct
(542) |
Nov
(308) |
Dec
(481) |
2007 |
Jan
(427) |
Feb
(326) |
Mar
(367) |
Apr
(255) |
May
(244) |
Jun
(204) |
Jul
(223) |
Aug
(231) |
Sep
(354) |
Oct
(374) |
Nov
(497) |
Dec
(362) |
2008 |
Jan
(322) |
Feb
(482) |
Mar
(658) |
Apr
(422) |
May
(476) |
Jun
(396) |
Jul
(455) |
Aug
(267) |
Sep
(280) |
Oct
(253) |
Nov
(232) |
Dec
(304) |
2009 |
Jan
(486) |
Feb
(470) |
Mar
(458) |
Apr
(423) |
May
(696) |
Jun
(461) |
Jul
(551) |
Aug
(575) |
Sep
(134) |
Oct
(110) |
Nov
(157) |
Dec
(102) |
2010 |
Jan
(226) |
Feb
(86) |
Mar
(147) |
Apr
(117) |
May
(107) |
Jun
(203) |
Jul
(193) |
Aug
(238) |
Sep
(300) |
Oct
(246) |
Nov
(23) |
Dec
(75) |
2011 |
Jan
(133) |
Feb
(195) |
Mar
(315) |
Apr
(200) |
May
(267) |
Jun
(293) |
Jul
(353) |
Aug
(237) |
Sep
(278) |
Oct
(611) |
Nov
(274) |
Dec
(260) |
2012 |
Jan
(303) |
Feb
(391) |
Mar
(417) |
Apr
(441) |
May
(488) |
Jun
(655) |
Jul
(590) |
Aug
(610) |
Sep
(526) |
Oct
(478) |
Nov
(359) |
Dec
(372) |
2013 |
Jan
(467) |
Feb
(226) |
Mar
(391) |
Apr
(281) |
May
(299) |
Jun
(252) |
Jul
(311) |
Aug
(352) |
Sep
(481) |
Oct
(571) |
Nov
(222) |
Dec
(231) |
2014 |
Jan
(185) |
Feb
(329) |
Mar
(245) |
Apr
(238) |
May
(281) |
Jun
(399) |
Jul
(382) |
Aug
(500) |
Sep
(579) |
Oct
(435) |
Nov
(487) |
Dec
(256) |
2015 |
Jan
(338) |
Feb
(357) |
Mar
(330) |
Apr
(294) |
May
(191) |
Jun
(108) |
Jul
(142) |
Aug
(261) |
Sep
(190) |
Oct
(54) |
Nov
(83) |
Dec
(22) |
2016 |
Jan
(49) |
Feb
(89) |
Mar
(33) |
Apr
(50) |
May
(27) |
Jun
(34) |
Jul
(53) |
Aug
(53) |
Sep
(98) |
Oct
(206) |
Nov
(93) |
Dec
(53) |
2017 |
Jan
(65) |
Feb
(82) |
Mar
(102) |
Apr
(86) |
May
(187) |
Jun
(67) |
Jul
(23) |
Aug
(93) |
Sep
(65) |
Oct
(45) |
Nov
(35) |
Dec
(17) |
2018 |
Jan
(26) |
Feb
(35) |
Mar
(38) |
Apr
(32) |
May
(8) |
Jun
(43) |
Jul
(27) |
Aug
(30) |
Sep
(43) |
Oct
(42) |
Nov
(38) |
Dec
(67) |
2019 |
Jan
(32) |
Feb
(37) |
Mar
(53) |
Apr
(64) |
May
(49) |
Jun
(18) |
Jul
(14) |
Aug
(53) |
Sep
(25) |
Oct
(30) |
Nov
(49) |
Dec
(31) |
2020 |
Jan
(87) |
Feb
(45) |
Mar
(37) |
Apr
(51) |
May
(99) |
Jun
(36) |
Jul
(11) |
Aug
(14) |
Sep
(20) |
Oct
(24) |
Nov
(40) |
Dec
(23) |
2021 |
Jan
(14) |
Feb
(53) |
Mar
(85) |
Apr
(15) |
May
(19) |
Jun
(3) |
Jul
(14) |
Aug
(1) |
Sep
(57) |
Oct
(73) |
Nov
(56) |
Dec
(22) |
2022 |
Jan
(3) |
Feb
(22) |
Mar
(6) |
Apr
(55) |
May
(46) |
Jun
(39) |
Jul
(15) |
Aug
(9) |
Sep
(11) |
Oct
(34) |
Nov
(20) |
Dec
(36) |
2023 |
Jan
(79) |
Feb
(41) |
Mar
(99) |
Apr
(169) |
May
(48) |
Jun
(16) |
Jul
(16) |
Aug
(57) |
Sep
(83) |
Oct
(89) |
Nov
(97) |
Dec
(30) |
2024 |
Jan
(25) |
Feb
(73) |
Mar
(76) |
Apr
(122) |
May
(46) |
Jun
(44) |
Jul
(27) |
Aug
(30) |
Sep
(33) |
Oct
(67) |
Nov
(91) |
Dec
(70) |
2025 |
Jan
(44) |
Feb
(36) |
Mar
(85) |
Apr
(100) |
May
(138) |
Jun
(55) |
Jul
(107) |
Aug
(27) |
Sep
|
Oct
|
Nov
|
Dec
|
From: Paul F. <pa...@so...> - 2025-04-17 11:01:38
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=972e1878bfa03fba4d29f8f05f1c65fbb91b8b2a commit 972e1878bfa03fba4d29f8f05f1c65fbb91b8b2a Author: Paul Floyd <pj...@wa...> Date: Thu Apr 17 13:00:04 2025 +0200 FreeBSD: changes for --modify-fds Again this is just the minumum to get the track_new test to pass. Other syscalls later. Diff: --- coregrind/m_syswrap/syswrap-freebsd.c | 1 + none/tests/track_new.c | 5 +---- none/tests/track_new.stderr.exp | 1 - 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/coregrind/m_syswrap/syswrap-freebsd.c b/coregrind/m_syswrap/syswrap-freebsd.c index 6fd4367a83..12b18f4e6e 100644 --- a/coregrind/m_syswrap/syswrap-freebsd.c +++ b/coregrind/m_syswrap/syswrap-freebsd.c @@ -5317,6 +5317,7 @@ PRE(sys_openat) POST(sys_openat) { vg_assert(SUCCESS); + POST_newFd_RES; if (!ML_(fd_allowed)(RES, "openat", tid, True)) { VG_(close)(RES); SET_STATUS_Failure( VKI_EMFILE ); diff --git a/none/tests/track_new.c b/none/tests/track_new.c index e4bb546fb4..718fa3a374 100644 --- a/none/tests/track_new.c +++ b/none/tests/track_new.c @@ -1,7 +1,4 @@ -#define _XOPEN_SOURCE 700 - #include <fcntl.h> -#include <stdio.h> #include <unistd.h> #include <sys/stat.h> @@ -15,7 +12,7 @@ main (void) /* Lets open another file... */ int newfd = open ("foobad.txt", O_RDWR|O_CREAT, S_IRUSR | S_IWUSR); /* ... oops we are using the wrong fd (but same number...) */ - dprintf (oldfd, "some new text\n"); + write(oldfd, "some new text\n", 14); close (newfd); return 0; diff --git a/none/tests/track_new.stderr.exp b/none/tests/track_new.stderr.exp index 23dec73bbc..cd443c51a9 100644 --- a/none/tests/track_new.stderr.exp +++ b/none/tests/track_new.stderr.exp @@ -1,6 +1,5 @@ File descriptor was closed already at 0x........: write (in /...libc...) - by 0x........: dprintf (in /...libc...) by 0x........: main Previously closed at 0x........: close (in /...libc...) |
From: Mark W. <ma...@kl...> - 2025-04-17 10:31:07
|
Hi Paul, On Thu, 2025-04-17 at 08:31 +0200, Paul Floyd via Valgrind-developers wrote: > On 4/16/25 22:12, Paul Floyd via Valgrind-developers wrote: > > > > > > The track_new testcase isn't working on FreeBSD. If I add the > > POST_newFd_RES macro to POST(sys_openat) > > then I see the fds being assigned from VG_(fd_hard_limit) downwards > > but when ML_(fd_allowed)() is called from PRE(sys_write) I don't see > > that openbadfd->fd_closed is set for the closed fd. > > > > Need more debugging of what's happening during close. > > I think FreeBSD dprintf is being clever and seeing that the fd is > closed. Outside of Valgrind I was seeing a call to write() but not when > running under Valgrind. > > I'll try using just plain write() rather than dprintf(). Interesting. Yeah, maybe dprintf is too clever/tricky to use in the testcase. But the testcase picked this sequence of calls since it came from some real code that triggered an issue (in highly parallel code). Using plain write might be simpler to analyze what is going on. But we do still have: https://bugs.kde.org/show_bug.cgi?id=493430 Review all syscalls (and ioctls) that use or return (new) file descriptors Given that there are multiple ways to open/create a file descriptor (and sometimes an open call is turned into openat or creat), use a file descriptor and close it we have to audit all syscalls to make sure the call record_fd_open, fd_allowed and record_close when appropriate, and for --modify-fds every syscall that creates a new filedescriptor must have something like POST_newFd_RES or equivalent to make sure all newly returned file descriptors uses a "high" number. I think we did most generic and linux specific calls, but not any non- linux specific ones (thanks for adding at least the open annotation on solaris). On freebsd at least the POST(sys_openat) should get a POST_newFd_RES added I think. Cheers, Mark |
From: Paul F. <pj...@wa...> - 2025-04-17 06:32:14
|
On 4/16/25 22:12, Paul Floyd via Valgrind-developers wrote: > > > The track_new testcase isn't working on FreeBSD. If I add the > POST_newFd_RES macro to POST(sys_openat) > then I see the fds being assigned from VG_(fd_hard_limit) downwards > but when ML_(fd_allowed)() is called from PRE(sys_write) I don't see > that openbadfd->fd_closed is set for the closed fd. > > Need more debugging of what's happening during close. > I think FreeBSD dprintf is being clever and seeing that the fd is closed. Outside of Valgrind I was seeing a call to write() but not when running under Valgrind. I'll try using just plain write() rather than dprintf(). A+ Paul |
From: Paul F. <pj...@wa...> - 2025-04-16 20:12:39
|
On 4/16/25 16:58, Mark Wielaard wrote: > https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=4c78562419ce2c9b6a21a3c9dfc9bf90638c9649 > > commit 4c78562419ce2c9b6a21a3c9dfc9bf90638c9649 > Author: Alexandra Hájková <aha...@re...> > Date: Wed Nov 20 12:00:47 2024 -0500 > > Add --modify-fds=[no|high] option The track_new testcase isn't working on FreeBSD. If I add the POST_newFd_RES macro to POST(sys_openat) then I see the fds being assigned from VG_(fd_hard_limit) downwards but when ML_(fd_allowed)() is called from PRE(sys_write) I don't see that openbadfd->fd_closed is set for the closed fd. Need more debugging of what's happening during close. A+ Paul |
From: Paul F. <pa...@so...> - 2025-04-16 18:33:59
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=99787e6488f9368c380a4586911d22e9750a5546 commit 99787e6488f9368c380a4586911d22e9750a5546 Author: Paul Floyd <pj...@wa...> Date: Wed Apr 16 20:31:38 2025 +0200 Illumos: changes for --modify-fds This is the minumum just to get the new testcase to build and pass. Need to go through the other fd related syscalls later. Diff: --- .gitignore | 1 + coregrind/m_syswrap/syswrap-solaris.c | 2 ++ none/tests/Makefile.am | 2 +- none/tests/cmdline1.stdout.exp-non-linux | 1 + none/tests/cmdline2.stdout.exp-non-linux | 1 + none/tests/track_new.c | 5 ++++- none/tests/track_new.stderr.exp-illumos | 10 ++++++++++ none/tests/track_new.vgtest | 2 ++ 8 files changed, 22 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 43b5d9b6ba..fa0fa0d349 100644 --- a/.gitignore +++ b/.gitignore @@ -1670,6 +1670,7 @@ /none/tests/timestamp /none/tests/tls /none/tests/track-fds-exec-children +/none/tests/track_new /none/tests/unit_debuglog /none/tests/use_after_close /none/tests/valgrind_cpp_test diff --git a/coregrind/m_syswrap/syswrap-solaris.c b/coregrind/m_syswrap/syswrap-solaris.c index dc0068d90c..6b61a0e0dc 100644 --- a/coregrind/m_syswrap/syswrap-solaris.c +++ b/coregrind/m_syswrap/syswrap-solaris.c @@ -1775,6 +1775,8 @@ PRE(sys_open) POST(sys_open) { + POST_newFd_RES; + if (!ML_(fd_allowed)(RES, "open", tid, True)) { VG_(close)(RES); SET_STATUS_Failure(VKI_EMFILE); diff --git a/none/tests/Makefile.am b/none/tests/Makefile.am index c2b36e33c2..2275407738 100644 --- a/none/tests/Makefile.am +++ b/none/tests/Makefile.am @@ -269,7 +269,7 @@ EXTRA_DIST = \ fdbaduse.stderr.exp fdbaduse.vgtest \ use_after_close.stderr.exp use_after_close.vgtest \ track_new.stderr.exp track_new.stdout.exp \ - track_new.stderr.exp.debian32 track_new.vgtest + track_new.stderr.exp.debian32 track_new.vgtest track_new.stderr.exp-illumos check_PROGRAMS = \ diff --git a/none/tests/cmdline1.stdout.exp-non-linux b/none/tests/cmdline1.stdout.exp-non-linux index f0534f824c..d36db3976e 100644 --- a/none/tests/cmdline1.stdout.exp-non-linux +++ b/none/tests/cmdline1.stdout.exp-non-linux @@ -30,6 +30,7 @@ usage: valgrind [options] prog-and-args startup exit abexit valgrindabexit all none --track-fds=no|yes|all track open file descriptors? [no] all includes reporting inherited file descriptors + --modify-fds=no|high modify newly open file descriptors? [no] --time-stamp=no|yes add timestamps to log messages? [no] --log-fd=<number> log messages to file descriptor [2=stderr] --log-file=<file> log messages to <file> diff --git a/none/tests/cmdline2.stdout.exp-non-linux b/none/tests/cmdline2.stdout.exp-non-linux index e518644ab5..5a44b3bfac 100644 --- a/none/tests/cmdline2.stdout.exp-non-linux +++ b/none/tests/cmdline2.stdout.exp-non-linux @@ -30,6 +30,7 @@ usage: valgrind [options] prog-and-args startup exit abexit valgrindabexit all none --track-fds=no|yes|all track open file descriptors? [no] all includes reporting inherited file descriptors + --modify-fds=no|high modify newly open file descriptors? [no] --time-stamp=no|yes add timestamps to log messages? [no] --log-fd=<number> log messages to file descriptor [2=stderr] --log-file=<file> log messages to <file> diff --git a/none/tests/track_new.c b/none/tests/track_new.c index 544ccacb3c..e4bb546fb4 100644 --- a/none/tests/track_new.c +++ b/none/tests/track_new.c @@ -1,9 +1,12 @@ +#define _XOPEN_SOURCE 700 + #include <fcntl.h> #include <stdio.h> #include <unistd.h> +#include <sys/stat.h> int -main () +main (void) { int oldfd = open ("foobar.txt", O_RDWR|O_CREAT, S_IRUSR | S_IWUSR); /*... do something with oldfd ...*/ diff --git a/none/tests/track_new.stderr.exp-illumos b/none/tests/track_new.stderr.exp-illumos new file mode 100644 index 0000000000..670530b603 --- /dev/null +++ b/none/tests/track_new.stderr.exp-illumos @@ -0,0 +1,10 @@ +File descriptor was closed already + at 0x........: fdopen (in /...libc...) + by 0x........: vdprintf (in /...libc...) + by 0x........: dprintf (in /...libc...) + by 0x........: main + Previously closed + at 0x........: close (in /...libc...) + by 0x........: main + Originally opened + at 0x........: main (track_new.c:11) diff --git a/none/tests/track_new.vgtest b/none/tests/track_new.vgtest index f6f72d880d..cad64c5eab 100644 --- a/none/tests/track_new.vgtest +++ b/none/tests/track_new.vgtest @@ -2,3 +2,5 @@ prog: track_new prereq: test -x track_new vgopts: -q --track-fds=yes --modify-fds=high stderr_filter: filter_fdleak +cleanup: rm -f foobad.txt foobar.txt + |
From: Mark W. <ma...@so...> - 2025-04-16 14:58:49
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=4c78562419ce2c9b6a21a3c9dfc9bf90638c9649 commit 4c78562419ce2c9b6a21a3c9dfc9bf90638c9649 Author: Alexandra Hájková <aha...@re...> Date: Wed Nov 20 12:00:47 2024 -0500 Add --modify-fds=[no|high] option Normally a newly recreated file descriptor gets the lowest number available. This might cause old file descriptor numbers to be reused and hides bad file descriptor accesses (because the old number is new again). When enabled, when the program opens a new file descriptor, the highest available file descriptor is returned instead of the lowest one. Add the none/tests/track_new.stderr.exp test to test this new option. Adjust none/tests/filter_fdleak to filter the track_new.vgtest, removing some internal glibc functions from the backtraces and remove symbol versioning. The output of the use_after_close test also had to be adjusted. Also adjust the none/tests/cmdline1 and none/tests/cmdline2 output as the new --modify-fds=no|high is displayed. https://bugs.kde.org/show_bug.cgi?id=493433 Diff: --- coregrind/m_main.c | 10 +++++++ coregrind/m_options.c | 1 + coregrind/m_syswrap/priv_syswrap-generic.h | 13 +++++++++ coregrind/m_syswrap/syswrap-generic.c | 46 ++++++++++++++++++++++++++++++ coregrind/m_syswrap/syswrap-linux.c | 7 +++++ docs/xml/manual-core.xml | 11 +++++++ include/pub_tool_options.h | 2 ++ none/tests/Makefile.am | 7 +++-- none/tests/cmdline1.stdout.exp | 1 + none/tests/cmdline2.stdout.exp | 1 + none/tests/filter_fdleak | 16 +++++++++++ none/tests/track_new.c | 19 ++++++++++++ none/tests/track_new.stderr.exp | 10 +++++++ none/tests/track_new.stderr.exp.debian32 | 10 +++++++ none/tests/track_new.stdout.exp | 0 none/tests/track_new.vgtest | 4 +++ none/tests/use_after_close.stderr.exp | 2 +- 17 files changed, 157 insertions(+), 3 deletions(-) diff --git a/coregrind/m_main.c b/coregrind/m_main.c index 877e6b0b68..55ffd769b3 100644 --- a/coregrind/m_main.c +++ b/coregrind/m_main.c @@ -115,6 +115,7 @@ static void usage_NORETURN ( int need_help ) " startup exit abexit valgrindabexit all none\n" " --track-fds=no|yes|all track open file descriptors? [no]\n" " all includes reporting inherited file descriptors\n" +" --modify-fds=no|high modify newly open file descriptors? [no]\n" " --time-stamp=no|yes add timestamps to log messages? [no]\n" " --log-fd=<number> log messages to file descriptor [2=stderr]\n" " --log-file=<file> log messages to <file>\n" @@ -646,6 +647,15 @@ static void process_option (Clo_Mode mode, VG_(fmsg_bad_option)(arg, "Bad argument, should be 'yes', 'all' or 'no'\n"); } + else if VG_STR_CLO(arg, "--modify-fds", tmp_str) { + if (VG_(strcmp)(tmp_str, "high") == 0) + VG_(clo_modify_fds) = 1; + else if (VG_(strcmp)(tmp_str, "no") == 0) + VG_(clo_modify_fds) = 0; + else + VG_(fmsg_bad_option)(arg, + "Bad argument, should be 'high' or 'no'\n"); + } else if VG_BOOL_CLOM(cloPD, arg, "--trace-children", VG_(clo_trace_children)) {} else if VG_BOOL_CLOM(cloPD, arg, "--child-silent-after-fork", VG_(clo_child_silent_after_fork)) {} diff --git a/coregrind/m_options.c b/coregrind/m_options.c index 16452f2525..6f5a4d0458 100644 --- a/coregrind/m_options.c +++ b/coregrind/m_options.c @@ -182,6 +182,7 @@ XArray *VG_(clo_req_tsyms); // array of strings Bool VG_(clo_run_libc_freeres) = True; Bool VG_(clo_run_cxx_freeres) = True; UInt VG_(clo_track_fds) = 0; +UInt VG_(clo_modify_fds) = 0; Bool VG_(clo_show_below_main)= False; Bool VG_(clo_keep_debuginfo) = False; Bool VG_(clo_show_emwarns) = False; diff --git a/coregrind/m_syswrap/priv_syswrap-generic.h b/coregrind/m_syswrap/priv_syswrap-generic.h index b888a167cc..b24b6b9035 100644 --- a/coregrind/m_syswrap/priv_syswrap-generic.h +++ b/coregrind/m_syswrap/priv_syswrap-generic.h @@ -73,6 +73,8 @@ extern Bool ML_(fd_recorded)(Int fd); // Returned string must not be modified nor free'd. extern const HChar *ML_(find_fd_recorded_by_fd)(Int fd); +extern int ML_(get_next_new_fd)(Int fd); + // Used when killing threads -- we must not kill a thread if it's the thread // that would do Valgrind's final cleanup and output. extern @@ -337,6 +339,17 @@ extern SysRes ML_(generic_PRE_sys_mmap) ( TId, UW, UW, UW, UW, UW, Off64 #undef UW #undef SR +/* Helper macro for POST handlers that return a new file in RES. + If possible sets RES (through SET_STATUS_Success) to a new + (not yet seem before) file descriptor. */ +#define POST_newFd_RES \ + do { \ + if (VG_(clo_modify_fds) == 1) { \ + int newFd = ML_(get_next_new_fd)(RES); \ + if (newFd != RES) \ + SET_STATUS_Success(newFd); \ + } \ + } while (0) ///////////////////////////////////////////////////////////////// diff --git a/coregrind/m_syswrap/syswrap-generic.c b/coregrind/m_syswrap/syswrap-generic.c index dea656aab2..1ab494c840 100644 --- a/coregrind/m_syswrap/syswrap-generic.c +++ b/coregrind/m_syswrap/syswrap-generic.c @@ -552,6 +552,49 @@ static OpenFd *allocated_fds = NULL; /* Count of open file descriptors. */ static Int fd_count = 0; +/* Last used file descriptor for "new" fds. + Used (and updated) in get_next_new_fd to find a new (not yet used) + fd number to return in syscall wrappers. */ +static Int last_new_fd = 0; + +/* Replace (dup2) the fd with the highest file descriptor available. + Close the fd and return the newly created file descriptor on success. + Keep track of the last_new_fd and return the initial fd on failure. */ +int ML_(get_next_new_fd)(int fd) +{ + int next_new_fd; + + /* Check if last_new needs to wrap around. */ + if (last_new_fd == 0) + last_new_fd = VG_(fd_hard_limit); + + next_new_fd = last_new_fd - 1; + + /* Find the next fd number not in use. If we have to wrap around, + just use fd itself. */ + while (next_new_fd >= 0 && ML_(fd_recorded)(next_new_fd)) + next_new_fd--; + if (next_new_fd < 0) + next_new_fd = fd; + + /* Duplicate and close the existing fd if needed. */ + if (next_new_fd != fd) { + SysRes res = VG_(dup2)(fd, next_new_fd); + if (!sr_isError(res)) + VG_(close)(fd); + else + next_new_fd = fd; + + /* Record what the last new fd was we returned. */ + last_new_fd = next_new_fd; + } else { + /* There was no lower "new" fd found. Lets wrap around for + the next round. */ + last_new_fd = VG_(fd_hard_limit); + } + + return next_new_fd; +} Int ML_(get_fd_count)(void) @@ -3693,6 +3736,7 @@ PRE(sys_dup) POST(sys_dup) { vg_assert(SUCCESS); + POST_newFd_RES; if (!ML_(fd_allowed)(RES, "dup", tid, True)) { VG_(close)(RES); SET_STATUS_Failure( VKI_EMFILE ); @@ -4561,6 +4605,7 @@ PRE(sys_open) POST(sys_open) { vg_assert(SUCCESS); + POST_newFd_RES; if (!ML_(fd_allowed)(RES, "open", tid, True)) { VG_(close)(RES); SET_STATUS_Failure( VKI_EMFILE ); @@ -4627,6 +4672,7 @@ PRE(sys_creat) POST(sys_creat) { vg_assert(SUCCESS); + POST_newFd_RES; if (!ML_(fd_allowed)(RES, "creat", tid, True)) { VG_(close)(RES); SET_STATUS_Failure( VKI_EMFILE ); diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c index 92771577bd..de710c97e4 100644 --- a/coregrind/m_syswrap/syswrap-linux.c +++ b/coregrind/m_syswrap/syswrap-linux.c @@ -2103,6 +2103,7 @@ PRE(sys_epoll_create) POST(sys_epoll_create) { vg_assert(SUCCESS); + POST_newFd_RES; if (!ML_(fd_allowed)(RES, "epoll_create", tid, True)) { VG_(close)(RES); SET_STATUS_Failure( VKI_EMFILE ); @@ -2120,6 +2121,7 @@ PRE(sys_epoll_create1) POST(sys_epoll_create1) { vg_assert(SUCCESS); + POST_newFd_RES; if (!ML_(fd_allowed)(RES, "epoll_create1", tid, True)) { VG_(close)(RES); SET_STATUS_Failure( VKI_EMFILE ); @@ -2234,6 +2236,7 @@ PRE(sys_eventfd) } POST(sys_eventfd) { + POST_newFd_RES; if (!ML_(fd_allowed)(RES, "eventfd", tid, True)) { VG_(close)(RES); SET_STATUS_Failure( VKI_EMFILE ); @@ -2250,6 +2253,7 @@ PRE(sys_eventfd2) } POST(sys_eventfd2) { + POST_newFd_RES; if (!ML_(fd_allowed)(RES, "eventfd2", tid, True)) { VG_(close)(RES); SET_STATUS_Failure( VKI_EMFILE ); @@ -2799,6 +2803,7 @@ PRE(sys_fanotify_init) POST(sys_fanotify_init) { + POST_newFd_RES; vg_assert(SUCCESS); if (!ML_(fd_allowed)(RES, "fanotify_init", tid, True)) { VG_(close)(RES); @@ -2847,6 +2852,7 @@ PRE(sys_inotify_init) POST(sys_inotify_init) { vg_assert(SUCCESS); + POST_newFd_RES; if (!ML_(fd_allowed)(RES, "inotify_init", tid, True)) { VG_(close)(RES); SET_STATUS_Failure( VKI_EMFILE ); @@ -5945,6 +5951,7 @@ PRE(sys_openat) POST(sys_openat) { vg_assert(SUCCESS); + POST_newFd_RES; if (!ML_(fd_allowed)(RES, "openat", tid, True)) { VG_(close)(RES); SET_STATUS_Failure( VKI_EMFILE ); diff --git a/docs/xml/manual-core.xml b/docs/xml/manual-core.xml index 3a2ce461cd..ffcb8d4bf5 100644 --- a/docs/xml/manual-core.xml +++ b/docs/xml/manual-core.xml @@ -901,6 +901,17 @@ in most cases. We group the available options by rough categories.</para> </listitem> </varlistentry> + <varlistentry id="opt.modify-fds" xreflabel="--modify-fds"> + <term> + <option><![CDATA[--modify-fds=<no|high> [default: no] ]]></option> + </term> + <listitem> + <para>When enabled, when the program opens a new file descriptor, + the highest available file descriptor is returned instead of the + lowest one.</para> + </listitem> + </varlistentry> + <varlistentry id="opt.time-stamp" xreflabel="--time-stamp"> <term> <option><![CDATA[--time-stamp=<yes|no> [default: no] ]]></option> diff --git a/include/pub_tool_options.h b/include/pub_tool_options.h index 32345dc6a0..fec61e30fe 100644 --- a/include/pub_tool_options.h +++ b/include/pub_tool_options.h @@ -419,6 +419,8 @@ extern Bool VG_(clo_keep_debuginfo); /* Track open file descriptors? 0 = No, 1 = Yes, 2 = All (including std) */ extern UInt VG_(clo_track_fds); +extern UInt VG_(clo_modify_fds); + /* Used to expand file names. "option_name" is the option name, eg. "--log-file". 'format' is what follows, eg. "cachegrind.out.%p". In diff --git a/none/tests/Makefile.am b/none/tests/Makefile.am index ccad463cab..c2b36e33c2 100644 --- a/none/tests/Makefile.am +++ b/none/tests/Makefile.am @@ -267,7 +267,9 @@ EXTRA_DIST = \ log-track-fds.stderr.exp log-track-fds.vgtest \ xml-track-fds.stderr.exp xml-track-fds.vgtest \ fdbaduse.stderr.exp fdbaduse.vgtest \ - use_after_close.stderr.exp use_after_close.vgtest + use_after_close.stderr.exp use_after_close.vgtest \ + track_new.stderr.exp track_new.stdout.exp \ + track_new.stderr.exp.debian32 track_new.vgtest check_PROGRAMS = \ @@ -325,7 +327,8 @@ check_PROGRAMS = \ socket_close \ file_dclose \ fdbaduse \ - use_after_close + use_after_close \ + track_new if HAVE_STATIC_LIBC if ! VGCONF_OS_IS_LINUX diff --git a/none/tests/cmdline1.stdout.exp b/none/tests/cmdline1.stdout.exp index 464c58f42a..d2f3e5d6a8 100644 --- a/none/tests/cmdline1.stdout.exp +++ b/none/tests/cmdline1.stdout.exp @@ -30,6 +30,7 @@ usage: valgrind [options] prog-and-args startup exit abexit valgrindabexit all none --track-fds=no|yes|all track open file descriptors? [no] all includes reporting inherited file descriptors + --modify-fds=no|high modify newly open file descriptors? [no] --time-stamp=no|yes add timestamps to log messages? [no] --log-fd=<number> log messages to file descriptor [2=stderr] --log-file=<file> log messages to <file> diff --git a/none/tests/cmdline2.stdout.exp b/none/tests/cmdline2.stdout.exp index fe526855d8..9a49757461 100644 --- a/none/tests/cmdline2.stdout.exp +++ b/none/tests/cmdline2.stdout.exp @@ -30,6 +30,7 @@ usage: valgrind [options] prog-and-args startup exit abexit valgrindabexit all none --track-fds=no|yes|all track open file descriptors? [no] all includes reporting inherited file descriptors + --modify-fds=no|high modify newly open file descriptors? [no] --time-stamp=no|yes add timestamps to log messages? [no] --log-fd=<number> log messages to file descriptor [2=stderr] --log-file=<file> log messages to <file> diff --git a/none/tests/filter_fdleak b/none/tests/filter_fdleak index 18a65b4568..2cc537df72 100755 --- a/none/tests/filter_fdleak +++ b/none/tests/filter_fdleak @@ -14,6 +14,7 @@ perl -p -e 's/^Open (AF_UNIX socket|file descriptor) [0-9]*: (\/private)?\/tmp\/ perl -p -e 's/^Open file descriptor [0-9]*: .*/Open file descriptor ...: .../' | perl -p -e 's/^Open file descriptor [0-9]*:$/Open file descriptor ...:/' | perl -p -e 's/File descriptor [0-9]*: .* is already closed/File descriptor ...: ... is already closed/' | +perl -p -e 's/File descriptor [0-9]* was closed already/File descriptor was closed already/' | perl -p -e 's/127.0.0.1:[0-9]*/127.0.0.1:.../g' | perl -p -e 's/socket\.c:[1-9][0-9]*/in \/...libc.../' | @@ -32,6 +33,18 @@ perl -p -e 's/open \(open64\.c:[1-9][0-9]*\)/creat (in \/...libc...)/' | perl -p -e "s/: open \(/: creat (/" | # arm64 write resolved to file:line with debuginfo perl -p -e "s/write\.c:[1-9][0-9]*/in \/...libc.../" | +#ppc64le +sed 's/__dprintf.*/dprintf \(in \/...libc...\)/' | + +# Remove "internal" _functions +sed '/by 0x........: _/d' | + +# Remove symbol versioning +sed -E 's/ ([a-zA-Z0-9_]+)@@?[A-Z0-9._]+/ \1/' | + +perl -p -e "s/\(dprintf.c:[0-9]*\)/(in \/...libc...)/" | +perl -p -e "s/\(open.c:[0-9]*\)/(in \/...libc...)/" | +perl -p -e "s/\(lseek(?:64)?.c:[0-9]*\)/(in \/...libc...)/" | # FreeBSD specific fdleak filters perl -p -e 's/ _close / close /;s/ _openat / creat /;s/ _write/ write/;s/internet/AF_INET socket 4: 127.0.0.1:... <-> 127.0.0.1:.../' | @@ -50,6 +63,9 @@ perl -p -0 -e 's/(Open[^\n]*\n)( (at|by)[^\n]*\n)+/$1 ...\n/gs' | sed "s/by 0x........: (below main)/by 0x........: main/" | sed "s/by 0x........: main (.*)/by 0x........: main/" | +sed "s/by 0x........: open (.*)/by 0x........: open/" | +sed "s/by 0x........: write (.*)/by 0x........: write/" | +sed "s/by 0x........: close (.*)/by 0x........: close/" | # With glibc debuginfo installed we might see syscall-template.S, # dup2.c close.c or creat64.c diff --git a/none/tests/track_new.c b/none/tests/track_new.c new file mode 100644 index 0000000000..544ccacb3c --- /dev/null +++ b/none/tests/track_new.c @@ -0,0 +1,19 @@ +#include <fcntl.h> +#include <stdio.h> +#include <unistd.h> + +int +main () +{ + int oldfd = open ("foobar.txt", O_RDWR|O_CREAT, S_IRUSR | S_IWUSR); + /*... do something with oldfd ...*/ + close (oldfd); + + /* Lets open another file... */ + int newfd = open ("foobad.txt", O_RDWR|O_CREAT, S_IRUSR | S_IWUSR); + /* ... oops we are using the wrong fd (but same number...) */ + dprintf (oldfd, "some new text\n"); + + close (newfd); + return 0; +} diff --git a/none/tests/track_new.stderr.exp b/none/tests/track_new.stderr.exp new file mode 100644 index 0000000000..23dec73bbc --- /dev/null +++ b/none/tests/track_new.stderr.exp @@ -0,0 +1,10 @@ +File descriptor was closed already + at 0x........: write (in /...libc...) + by 0x........: dprintf (in /...libc...) + by 0x........: main + Previously closed + at 0x........: close (in /...libc...) + by 0x........: main + Originally opened + at 0x........: creat (in /...libc...) + by 0x........: main diff --git a/none/tests/track_new.stderr.exp.debian32 b/none/tests/track_new.stderr.exp.debian32 new file mode 100644 index 0000000000..eb86871743 --- /dev/null +++ b/none/tests/track_new.stderr.exp.debian32 @@ -0,0 +1,10 @@ +File descriptor was closed already + at 0x........: llseek (in /...libc...) + by 0x........: dprintf (in /...libc...) + by 0x........: main + Previously closed + at 0x........: close (in /...libc...) + by 0x........: main + Originally opened + at 0x........: creat (in /...libc...) + by 0x........: main diff --git a/none/tests/track_new.stdout.exp b/none/tests/track_new.stdout.exp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/none/tests/track_new.vgtest b/none/tests/track_new.vgtest new file mode 100644 index 0000000000..f6f72d880d --- /dev/null +++ b/none/tests/track_new.vgtest @@ -0,0 +1,4 @@ +prog: track_new +prereq: test -x track_new +vgopts: -q --track-fds=yes --modify-fds=high +stderr_filter: filter_fdleak diff --git a/none/tests/use_after_close.stderr.exp b/none/tests/use_after_close.stderr.exp index 75a8d66729..620a6b8d29 100644 --- a/none/tests/use_after_close.stderr.exp +++ b/none/tests/use_after_close.stderr.exp @@ -1,5 +1,5 @@ bad -File descriptor 3 was closed already +File descriptor was closed already at 0x........: write (in /...libc...) by 0x........: main Previously closed |
From: Paul F. <pa...@so...> - 2025-04-15 19:21:16
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=3149c9ff090c2290309419b09708a9b80481ede3 commit 3149c9ff090c2290309419b09708a9b80481ede3 Author: Paul Floyd <pj...@wa...> Date: Tue Apr 15 21:18:33 2025 +0200 Illumos regtest: update expected for memcheck/tests/amd64-solaris/context_fpu The expected contains 8 errors for if (inhandler[1] || inhandler[3] || inhandler[5] || inhandler[7]) assert(0); whilst I would expect 4 (the 4 array elements are uninitialised). It is also failing on Solaris 11.4. Diff: --- .../tests/amd64-solaris/context_fpu.stderr.exp | 48 ---------------------- 1 file changed, 48 deletions(-) diff --git a/memcheck/tests/amd64-solaris/context_fpu.stderr.exp b/memcheck/tests/amd64-solaris/context_fpu.stderr.exp index f47b338606..999e669323 100644 --- a/memcheck/tests/amd64-solaris/context_fpu.stderr.exp +++ b/memcheck/tests/amd64-solaris/context_fpu.stderr.exp @@ -22,54 +22,6 @@ Conditional jump or move depends on uninitialised value(s) at 0x........: malloc (vg_replace_malloc.c:...) by 0x........: main (context_fpu.c:51) -Conditional jump or move depends on uninitialised value(s) - at 0x........: main (context_fpu.c:97) - Uninitialised value was created by a heap allocation - at 0x........: malloc (vg_replace_malloc.c:...) - by 0x........: main (context_fpu.c:51) - -Conditional jump or move depends on uninitialised value(s) - at 0x........: main (context_fpu.c:97) - Uninitialised value was created by a heap allocation - at 0x........: malloc (vg_replace_malloc.c:...) - by 0x........: main (context_fpu.c:51) - -Conditional jump or move depends on uninitialised value(s) - at 0x........: main (context_fpu.c:97) - Uninitialised value was created by a heap allocation - at 0x........: malloc (vg_replace_malloc.c:...) - by 0x........: main (context_fpu.c:51) - -Conditional jump or move depends on uninitialised value(s) - at 0x........: main (context_fpu.c:97) - Uninitialised value was created by a heap allocation - at 0x........: malloc (vg_replace_malloc.c:...) - by 0x........: main (context_fpu.c:51) - -Conditional jump or move depends on uninitialised value(s) - at 0x........: main (context_fpu.c:105) - Uninitialised value was created by a heap allocation - at 0x........: malloc (vg_replace_malloc.c:...) - by 0x........: main (context_fpu.c:51) - -Conditional jump or move depends on uninitialised value(s) - at 0x........: main (context_fpu.c:105) - Uninitialised value was created by a heap allocation - at 0x........: malloc (vg_replace_malloc.c:...) - by 0x........: main (context_fpu.c:51) - -Conditional jump or move depends on uninitialised value(s) - at 0x........: main (context_fpu.c:105) - Uninitialised value was created by a heap allocation - at 0x........: malloc (vg_replace_malloc.c:...) - by 0x........: main (context_fpu.c:51) - -Conditional jump or move depends on uninitialised value(s) - at 0x........: main (context_fpu.c:105) - Uninitialised value was created by a heap allocation - at 0x........: malloc (vg_replace_malloc.c:...) - by 0x........: main (context_fpu.c:51) - Conditional jump or move depends on uninitialised value(s) at 0x........: main (context_fpu.c:105) Uninitialised value was created by a heap allocation |
From: Paul F. <pa...@so...> - 2025-04-15 18:55:59
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=bfc07c71d4069eafaab66e1a5f6843006b194fcb commit bfc07c71d4069eafaab66e1a5f6843006b194fcb Author: Paul Floyd <pj...@wa...> Date: Tue Apr 15 20:52:59 2025 +0200 Flush stack overflow / failure to grow stack messages. These messages were missing for the test none/tests/solaris/stack_overflow on Illumos. The test now passes. Diff: --- coregrind/m_signals.c | 1 + 1 file changed, 1 insertion(+) diff --git a/coregrind/m_signals.c b/coregrind/m_signals.c index 53614d303c..f0e6b8e7cf 100644 --- a/coregrind/m_signals.c +++ b/coregrind/m_signals.c @@ -2741,6 +2741,7 @@ Bool VG_(extend_stack)(ThreadId tid, Addr addr) else VG_(umsg)("Cannot map memory to grow the stack for thread #%u " "to %#lx\n", tid, new_stack_base); + VG_(message_flush)(); return False; } |
From: Paul F. <pa...@so...> - 2025-04-15 18:43:04
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=63fe564468aaddc205f9a5d6eedc07cf85eb01ad commit 63fe564468aaddc205f9a5d6eedc07cf85eb01ad Author: Paul Floyd <pj...@wa...> Date: Tue Apr 15 20:39:22 2025 +0200 nightly: fix check for Illumos libc On Illumos `uname -o` outputs "illumos". We weren't testing for that so it fell through to the Linux block which runs libc.so to get the version string. On Illumos that outputs usage: ld.so.1 [-e option,...] dynamic-object [object args,...] Diff: --- nightly/bin/nightly | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nightly/bin/nightly b/nightly/bin/nightly index bb943eb801..92931e86ff 100755 --- a/nightly/bin/nightly +++ b/nightly/bin/nightly @@ -198,6 +198,8 @@ fi gdb_version="`gdb --version 2> /dev/null | head -1`" if [ `uname -o` = "Solaris" ]; then libc="Solaris libc" +elif [ `uname -o` = "illumos" ]; then + libc="Illumos libc" elif [ `uname -o` = "FreeBSD" ]; then libc="FreeBSD libc" else |
From: Paul F. <pa...@so...> - 2025-04-14 20:07:07
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=87816a9327dcb13b51ac01b74b09aabea4a719d0 commit 87816a9327dcb13b51ac01b74b09aabea4a719d0 Author: Paul Floyd <pj...@wa...> Date: Mon Apr 14 22:05:57 2025 +0200 Illumos readelf: patch for detection of DTrace .data sections Taken from https://github.com/oracle/solaris-userland/blob/master/components/valgrind/patches/03-dtrace-section.patch Diff: --- coregrind/m_debuginfo/readelf.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c index 0c37ea1009..61a39af2af 100644 --- a/coregrind/m_debuginfo/readelf.c +++ b/coregrind/m_debuginfo/readelf.c @@ -2200,17 +2200,24 @@ Bool ML_(read_elf_object) ( struct _DebugInfo* di ) } } } - if (!loaded) { -# if defined(SOLARIS_PT_SUNDWTRACE_THRP) - if ((a_phdr.p_memsz == VKI_PT_SUNWDTRACE_SIZE) - && ((a_phdr.p_flags & (PF_R | PF_W | PF_X)) == PF_R)) { +# if defined(SOLARIS_PT_SUNDWTRACE_THRP) + if ((a_phdr.p_memsz == VKI_PT_SUNWDTRACE_SIZE) + && ((a_phdr.p_flags & (PF_R | PF_W | PF_X)) == PF_R)) { + if (dtrace_data_vaddr != 0) { + ML_(symerr)(di, True, "Multiple dtrace_data headers detected"); + goto out; + } + dtrace_data_vaddr = a_phdr.p_vaddr; + + /* DTrace related section might be outside all mapped regions. */ + if (!loaded) { TRACE_SYMTAB("PT_LOAD[%ld]: ignore dtrace_data program " "header\n", i); - dtrace_data_vaddr = a_phdr.p_vaddr; continue; } -# endif /* SOLARIS_PT_SUNDWTRACE_THRP */ - + } +# endif /* SOLARIS_PT_SUNDWTRACE_THRP */ + if (!loaded) { ML_(symerr)(di, False, "ELF section outside all mapped regions"); /* This problem might be solved by further memory mappings. |
From: Paul F. <pa...@so...> - 2025-04-14 19:11:24
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=f72d263cae92398685b108d9be7227aaf29b9999 commit f72d263cae92398685b108d9be7227aaf29b9999 Author: Paul Floyd <pj...@wa...> Date: Mon Apr 14 21:06:45 2025 +0200 Add 'scripts' directory to dirs_to_ignore in check_headers_and_includes Diff: --- tests/check_headers_and_includes | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/check_headers_and_includes b/tests/check_headers_and_includes index 6e2238e9d3..515d11b47c 100755 --- a/tests/check_headers_and_includes +++ b/tests/check_headers_and_includes @@ -62,6 +62,7 @@ my %dirs_to_ignore = ( "Inst" => 1, # the nightly scripts creates this "VEX" => 1, "docs" => 1, + "scripts" => 1, "auxprogs" => 1, "autom4te.cache" => 1, "m4" => 1, |
From: Paul F. <pa...@so...> - 2025-04-14 18:44:52
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=94eb6d20ff6972209b23e25fef132b3722db96bd commit 94eb6d20ff6972209b23e25fef132b3722db96bd Author: Paul Floyd <pj...@wa...> Date: Mon Apr 14 20:43:20 2025 +0200 Illumos regtest: fix threadname vgtest files I missed one level of ../ and didn't see that there was already a prereq: in each of these two files. Diff: --- memcheck/tests/threadname.vgtest | 3 +-- memcheck/tests/threadname_xml.vgtest | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/memcheck/tests/threadname.vgtest b/memcheck/tests/threadname.vgtest index 71fd4abe4e..b39f96f2ab 100644 --- a/memcheck/tests/threadname.vgtest +++ b/memcheck/tests/threadname.vgtest @@ -1,4 +1,3 @@ -prereq: ! ../tests/os_test illumos +prereq: test -e ./threadname && ! ../../tests/os_test illumos prog: threadname -prereq: test -e ./threadname vgopts: -q diff --git a/memcheck/tests/threadname_xml.vgtest b/memcheck/tests/threadname_xml.vgtest index 67ee778f02..5d3acea6f8 100644 --- a/memcheck/tests/threadname_xml.vgtest +++ b/memcheck/tests/threadname_xml.vgtest @@ -1,5 +1,4 @@ -prereq: ! ../tests/os_test illumos +prereq: test -u ./threadname && ! ../../tests/os_test illumos prog: threadname -prereq: test -e ./threadname vgopts: --xml=yes --xml-fd=2 --log-file=/dev/null stderr_filter: filter_xml |
From: Paul F. <pa...@so...> - 2025-04-14 17:39:37
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=a1efece712896909a19db663b496046d80115bc0 commit a1efece712896909a19db663b496046d80115bc0 Author: Paul Floyd <pj...@wa...> Date: Mon Apr 14 19:38:03 2025 +0200 Illumos nightly: enable sending results to valgrind-testresults Diff: --- nightly/conf/illumos.sendmail | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nightly/conf/illumos.sendmail b/nightly/conf/illumos.sendmail index 8b3e9bf326..f6e15733df 100755 --- a/nightly/conf/illumos.sendmail +++ b/nightly/conf/illumos.sendmail @@ -5,6 +5,5 @@ body=$2 file=$3 filename=$( basename $3 ) -#(cat "$body" "$file") | mailx -s "$subject" -r "Paul Floyd <pj...@wa...>" val...@li... +(cat "$body" "$file") | mailx -s "$subject" -r "Paul Floyd <pj...@wa...>" val...@li... -(cat "$body" "$file") | mailx -s "$subject" -r "Paul Floyd <pj...@wa...>" pj...@wa... |
From: Mark W. <ma...@kl...> - 2025-04-14 12:06:57
|
Hi, On Sun, Apr 06, 2025 at 03:23:54PM +0200, Mark Wielaard wrote: > On Mon, Mar 31, 2025 at 11:29:41AM +0200, Mark Wielaard wrote: > > On Fri, Mar 28, 2025 at 07:02:28PM +0100, Mark Wielaard wrote: > > > On Fri, 2025-03-21 at 14:01 +0100, Florian Weimer wrote: > > > > Without this change, the system call wrapper function is not visible > > > > on the stack at the time of the system call, which causes problems > > > > for interception tools such as valgrind. > > > > > > > > Enhances commit 89b53077d2a58f00e7debdfe58afabe953dac60d ("nptl: Fix > > > > Race conditions in pthread cancellation [BZ#12683]"). > > > > > > > > Tested on i686-linux-gnu, powerpc64le-linux-gnu, x86_64-linux-gnu. > > > > (We're still discussing if valgrind needs this, but if it does, here's a > > > > patch.) > > > > > > I implemented the valgrind part of skipping the syscall_cancel frames > > > here: https://bugs.kde.org/show_bug.cgi?id=502126#c2 > > > And there is a valgrind package build for fedora rawhide: > > > https://koji.fedoraproject.org/koji/buildinfo?buildID=2687393 > > > > > > For ppc64le, s390x and x86_64 that patch seems enough. > > > > > > For i686 and aarch64 there does seem to be an issue with missing the > > > glibc calling function because of a tail call. > > > > > > Also on i686 there is another extra frame on top __libc_do_syscall. > > > > I extended the patch to cover some extra sycall wrapper function > > symbols on i386 and armhf and pushed it to valgrind trunk and > > VALGRIND_3_24_BRANCH. There are builds for fedora rawhide and > > f42. This does seem to show that only on arm64 the tail calls > > obscure observing the full call stack. > > This has now landed in fedora rawhide and f42. Test results look good, > except for some if the arm64 tests where the tail calls obscure > observing the full call stack. Please let me know if you need any more > input from us to get this fix in glibc. Please let me know. Valgrind test results for syscall backtraces on anything except arm64 look good. We are working on valgrind 3.25.0 now, to be released around April 24. Thanks, Mark |
From: Paul F. <pa...@so...> - 2025-04-14 10:31:51
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=aa764f600ffa72f836720698fc27bfd4bd49dfc4 commit aa764f600ffa72f836720698fc27bfd4bd49dfc4 Author: Paul Floyd <pj...@wa...> Date: Mon Apr 14 12:30:52 2025 +0200 Illumos nightly: add conf files for Illumos Diff: --- nightly/conf/illumos.conf | 3 +++ nightly/conf/illumos.sendmail | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/nightly/conf/illumos.conf b/nightly/conf/illumos.conf new file mode 100644 index 0000000000..8654e9ad4d --- /dev/null +++ b/nightly/conf/illumos.conf @@ -0,0 +1,3 @@ +export ABT_DETAILS="Illumos x86" +export ABT_JOBS=4 +#export ABT_PERF="--tools=none,memcheck,callgrind,helgrind,cachegrind,drd,massif --reps=3 --vg=../valgrind-old --vg=../valgrind-new" diff --git a/nightly/conf/illumos.sendmail b/nightly/conf/illumos.sendmail new file mode 100755 index 0000000000..8b3e9bf326 --- /dev/null +++ b/nightly/conf/illumos.sendmail @@ -0,0 +1,10 @@ +#!/bin/sh + +subject=$1 +body=$2 +file=$3 +filename=$( basename $3 ) + +#(cat "$body" "$file") | mailx -s "$subject" -r "Paul Floyd <pj...@wa...>" val...@li... + +(cat "$body" "$file") | mailx -s "$subject" -r "Paul Floyd <pj...@wa...>" pj...@wa... |
From: Florian K. <fk...@so...> - 2025-04-13 12:07:40
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=724e8e47f2be4cf92df4ce184eee784689435633 commit 724e8e47f2be4cf92df4ce184eee784689435633 Author: Florian Krohm <fl...@ei...> Date: Sun Apr 13 12:06:33 2025 +0000 s390x: Regtest integration of none/tests/s390x/disasm-test The checker requires objdump --version >= 2.44 Add command line flag --check-prereq to disasm-test and use it in disasm-test.vgtest. New file none/tests/s390x/disasm-test/disasm-test.post.exp as the checker is run in the "post" hook. Diff: --- none/tests/s390x/disasm-test/Makefile.am | 4 +- none/tests/s390x/disasm-test/disasm-test.post.exp | 4 ++ .../tests/s390x/disasm-test/disasm-test.stderr.exp | 1 - none/tests/s390x/disasm-test/disasm-test.vgtest | 11 ++-- none/tests/s390x/disasm-test/main.c | 62 +++++++++++++++++++++- 5 files changed, 73 insertions(+), 9 deletions(-) diff --git a/none/tests/s390x/disasm-test/Makefile.am b/none/tests/s390x/disasm-test/Makefile.am index ce662cb860..61d4f31963 100644 --- a/none/tests/s390x/disasm-test/Makefile.am +++ b/none/tests/s390x/disasm-test/Makefile.am @@ -1,7 +1,7 @@ include $(top_srcdir)/Makefile.all.am -EXTRA_DIST = disasm-test.vgtest disasm-test.stderr.exp disasm-test.stdout.exp - +EXTRA_DIST = disasm-test.vgtest disasm-test.stderr.exp disasm-test.stdout.exp \ + disasm-test.post.exp dist_noinst_SCRIPTS = filter_stderr #---------------------------------------------------------------------------- diff --git a/none/tests/s390x/disasm-test/disasm-test.post.exp b/none/tests/s390x/disasm-test/disasm-test.post.exp new file mode 100644 index 0000000000..34722229c0 --- /dev/null +++ b/none/tests/s390x/disasm-test/disasm-test.post.exp @@ -0,0 +1,4 @@ +Total: 148751 tests generated +Total: 148659 insns verified +Total: 0 disassembly mismatches +Total: 92 specification exceptions diff --git a/none/tests/s390x/disasm-test/disasm-test.stderr.exp b/none/tests/s390x/disasm-test/disasm-test.stderr.exp index e6a4c48218..139597f9cb 100644 --- a/none/tests/s390x/disasm-test/disasm-test.stderr.exp +++ b/none/tests/s390x/disasm-test/disasm-test.stderr.exp @@ -1,3 +1,2 @@ -One of --verify, --generate, --run, --all, or --unit-test is required diff --git a/none/tests/s390x/disasm-test/disasm-test.vgtest b/none/tests/s390x/disasm-test/disasm-test.vgtest index d7a1a409c1..9f7f9997b0 100644 --- a/none/tests/s390x/disasm-test/disasm-test.vgtest +++ b/none/tests/s390x/disasm-test/disasm-test.vgtest @@ -1,6 +1,7 @@ -prog: disasm-test -# args: --all # enable this eventually # -# NOTE: there are extra newlines in the output which are *not* -# present when disasm-test is invoked by hand. -# Not sure where they are coming from. +# We do not want disasm-test to be run under the auspices of valgrind. +# Therefore the real test here is run in the "post" command. +# +prereq: ./disasm-test --check-prereq +prog: /bin/true +post: ./disasm-test --all --summary diff --git a/none/tests/s390x/disasm-test/main.c b/none/tests/s390x/disasm-test/main.c index c61ab8c681..aa362b511e 100644 --- a/none/tests/s390x/disasm-test/main.c +++ b/none/tests/s390x/disasm-test/main.c @@ -25,6 +25,7 @@ #include <stddef.h> // NULL #include <stdlib.h> // exit, malloc #include <stdio.h> // vfprintf +#include <ctype.h> // isdigit #include <stdarg.h> // va_list #include <string.h> // strchr #include <assert.h> // assert @@ -38,6 +39,8 @@ const char *gcc = "gcc"; // path to GCC const char *objdump = "objdump"; // path to objdump const char *gcc_flags = "-march=arch14"; +#define MIN_OBJDUMP_VERSION 2044000 /* 2.44 */ + #define CHECK_CLO(x, s) (strncmp(x, s, sizeof s - 1) == 0) static const char usage[] = @@ -63,10 +66,12 @@ static const char usage[] = " --unit-test - Run unit tests\n" " --show-spec-exc - Show insns causing specification exceptions\n" " --no-show-miscompares - Do not show disassembly miscompares\n" + " --check-prereq - Check prerequisites (e.g. objdump version)\n" ; static void remove_temp_files(const char *); static int opcode_has_errors(const opcode *); +static int check_objdump(void); static int keep_temp = 0; static int summary = 0; @@ -81,7 +86,7 @@ main(int argc, char *argv[]) { int all = 0, verify = 0, generate = 0, unit_test = 0; int num_clargs = 0; - int run = 0; + int run = 0, check_prereq = 0; const char *clargs[argc]; assert(sizeof(long long) == 8); @@ -118,6 +123,8 @@ main(int argc, char *argv[]) keep_temp = 1; } else if (CHECK_CLO(clo, "--run")) { run = 1; + } else if (CHECK_CLO(clo, "--check-prereq")) { + check_prereq = 1; } else if (CHECK_CLO(clo, "--help")) { printf("%s\n", usage); return 0; @@ -134,6 +141,9 @@ main(int argc, char *argv[]) } } + if (check_prereq) + return check_objdump(); + /* Check consistency of command line options */ if (verify + generate + run + all + unit_test == 0) fatal("One of --verify, --generate, --run, --all, or --unit-test " @@ -333,3 +343,53 @@ opcode_has_errors(const opcode *opc) } return 0; } + + +/* Objdump version 2.44 or later is required, Return 0, if that's + the case. */ +static int +check_objdump(void) +{ + unsigned need = strlen(objdump) + 3 + 1; + char *cmd = mallock(need); + + sprintf(cmd, "%s -V", objdump); + FILE *fp = popen(cmd, "r"); + + /* The version number is expected on the first line and its + format ought to be one of X or X.Y or X.Y.Z where X,Y,Z are + positive integers. */ + int c, rc = 1; + while ((c = fgetc(fp)) != EOF) { + if (c == '\n') break; + if (! isdigit(c)) continue; + + /* Version number is expected to be X or X.Y or X.Y.Z */ + char buf[32]; // assumed large enough + int ix = 0; + do { + buf[ix++] = c; + c = fgetc(fp); + } while (isdigit(c) || c == '.'); + buf[ix] = '\0'; + + unsigned version = 0, v1, v2, v3; + if (sscanf(buf, "%u.%u.%u", &v1,&v2,&v3) == 3) { + version = v1*1000000 + v2*1000 + v3; + } else if (sscanf(buf, "%u.%u", &v1,&v2) == 2) { + version = v1*1000000 + v2*1000; + } else if (sscanf(buf, "%u", &v1) == 1) { + version = v1*1000000; + } else { + error("Could not determine objdump version\n"); + break; + } + if (version >= MIN_OBJDUMP_VERSION) + rc = 0; + break; + } + pclose(fp); + free(cmd); + + return rc; +} |
From: Florian K. <fk...@so...> - 2025-04-13 11:06:47
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=78b3e5447172090387a981a6d9d6a0aa98455b9b commit 78b3e5447172090387a981a6d9d6a0aa98455b9b Author: Florian Krohm <fl...@ei...> Date: Sun Apr 13 11:05:08 2025 +0000 s390x: Final change to fix BZ 495817 This patch makes VEX disassembly match objdump disassembly for objdump versions >= 2.44. Prior objdump versions did not handle the nuances of the "rotate and ..." set of opcodes and there was also a bug disassembling BC insns. Fixes https://bugs.kde.org/show_bug.cgi?id=495817 Diff: --- NEWS | 1 + VEX/priv/guest_s390_toIR.c | 2 +- VEX/priv/host_s390_defs.c | 2 +- VEX/priv/s390_disasm.c | 42 ++++++++++++++++++++++++++++++----- VEX/priv/s390_disasm.h | 1 + none/tests/s390x/disasm-test/opcode.c | 32 ++++++++++++++++++-------- 6 files changed, 64 insertions(+), 16 deletions(-) diff --git a/NEWS b/NEWS index 98270e95e6..fac28e7984 100644 --- a/NEWS +++ b/NEWS @@ -44,6 +44,7 @@ are not entered into bugzilla tend to get forgotten about or ignored. 494337 All threaded applications cause still holding lock errors 495488 Add FreeBSD getrlimitusage syscall wrapper 495816 s390x: Fix disassembler segfault for C[G]RT and CL[G]RT +495817 s390x: Disassembly to match objdump -d output 496370 Illumos: signal handling is broken 496571 False positive for null key passed to bpf_map_get_next_key syscall. 496950 s390x: Fix hardware capabilities and EmFail codes diff --git a/VEX/priv/guest_s390_toIR.c b/VEX/priv/guest_s390_toIR.c index 5381e417e8..102c6a9034 100644 --- a/VEX/priv/guest_s390_toIR.c +++ b/VEX/priv/guest_s390_toIR.c @@ -2856,7 +2856,7 @@ s390_format_RIE_RRUUU(const HChar *(*irgen)(UChar r1, UChar r2, UChar i3, const HChar *mnm = irgen(r1, r2, i3, i4, i5); if (UNLIKELY(vex_traceflags & VEX_TRACE_FE)) - S390_DISASM(MNM(mnm), GPR(r1), GPR(r2), UINT(i3), UINT(i4), UINT(i5)); + S390_DISASM(XMNM(mnm, rotate_disasm), GPR(r1), GPR(r2), MASK(i3), MASK(i4), MASK(i5)); } static void diff --git a/VEX/priv/host_s390_defs.c b/VEX/priv/host_s390_defs.c index c503d6ddeb..b7b2f25207 100644 --- a/VEX/priv/host_s390_defs.c +++ b/VEX/priv/host_s390_defs.c @@ -5208,7 +5208,7 @@ static UChar * s390_emit_RISBG(UChar *p, UChar r1, UChar r2, UChar i3, Char i4, UChar i5) { if (UNLIKELY(vex_traceflags & VEX_TRACE_ASM)) - S390_DISASM(MNM("risbg"), GPR(r1), GPR(r2), UINT(i3), UINT(i4), UINT(i5)); + S390_DISASM(XMNM("risbg", rotate_disasm), GPR(r1), GPR(r2), MASK(i3), MASK(i4), MASK(i5)); return emit_RIEf(p, 0xec0000000055ULL, r1, r2, i3, i4, i5); } diff --git a/VEX/priv/s390_disasm.c b/VEX/priv/s390_disasm.c index 0b03c14edd..0eb8f922f5 100644 --- a/VEX/priv/s390_disasm.c +++ b/VEX/priv/s390_disasm.c @@ -164,7 +164,8 @@ dxb_operand(HChar *p, UInt d, UInt x, UInt b, Bool displacement_is_signed) p += vex_sprintf(p, "%u", d); } if (x != 0) { - p += vex_sprintf(p, "(%s,%s)", gpr_operand(x), gpr_operand(b)); + p += vex_sprintf(p, "(%s,%s)", gpr_operand(x), + b != 0 ? gpr_operand(b) : "0"); } else { if (b != 0) { p += vex_sprintf(p, "(%s)", gpr_operand(b)); @@ -182,7 +183,7 @@ udlb_operand(HChar *p, UInt d, UInt length, UInt b) { p += vex_sprintf(p, "%u", d); p += vex_sprintf(p, "(%u", length + 1); // actual length is +1 - p += vex_sprintf(p, ",%s", gpr_operand(b)); + p += vex_sprintf(p, ",%s", b != 0 ? gpr_operand(b) : "0"); p += vex_sprintf(p, ")"); return p; @@ -203,7 +204,7 @@ dvb_operand(HChar *p, UInt d, UInt v, UInt b, Bool displacement_is_signed) p += vex_sprintf(p, "%u", d); } p += vex_sprintf(p, "(%s", vr_operand(v)); - p += vex_sprintf(p, ",%s", gpr_operand(b)); + p += vex_sprintf(p, ",%s", b != 0 ? gpr_operand(b) : "0"); p += vex_sprintf(p, ")"); return p; @@ -282,9 +283,11 @@ bc_disasm(const s390_opnd *opnds, HChar *p) const HChar *xmnm; UInt mask = opnds[1].mask; - if (mask == 0) + if (mask == 0) { xmnm = "nop"; - else if (mask == 15) + if (opnds[2].d == 0 && opnds[2].b == 0 && opnds[2].x == 0) + return p += vex_sprintf(p, "nop"); + } else if (mask == 15) xmnm = "b"; else xmnm = construct_mnemonic("b", "", mask); @@ -1084,6 +1087,35 @@ adtra_like_disasm(const s390_opnd *opnds, HChar *p) } +static Int +rotate_mh(UInt ix __attribute__((unused)), UInt mask, UInt *value) +{ + *value = mask; + if (ix == 5 && mask == 0) return 0; + if (ix == 3) // rosbg, etc + *value = mask & ~0x80; + if (ix == 4) // risbg + *value = mask & ~0x80; + return 1; +} + + +HChar * +rotate_disasm(const s390_opnd *opnds, HChar *p) +{ + const HChar *base = opnds[0].xmnm.base; + UInt len = vex_strlen(base); + HChar xmnm[len + 1]; + + if (opnds[0].xmnm.base[1] == 'i') + vex_sprintf(xmnm, "%s%c", base, (opnds[4].u & 0x80) ? 'z' : '\0'); + else + vex_sprintf(xmnm, "%s%c", base, (opnds[3].u & 0x80) ? 't' : '\0'); + + return s390_disasm_aux(opnds, xmnm, p, rotate_mh); +} + + /* Write out OPNDS. MH is a mask handler. It decides whether or not a MASK operand is written and if so, massages the mask value as needed. */ static HChar * diff --git a/VEX/priv/s390_disasm.h b/VEX/priv/s390_disasm.h index f84f5061f6..14731898c5 100644 --- a/VEX/priv/s390_disasm.h +++ b/VEX/priv/s390_disasm.h @@ -138,6 +138,7 @@ HChar *vfmix_like_disasm(const s390_opnd *, HChar *); HChar *fp_convf_disasm(const s390_opnd *, HChar *); HChar *fp_convt_disasm(const s390_opnd *, HChar *); HChar *adtra_like_disasm(const s390_opnd *, HChar *); +HChar *rotate_disasm(const s390_opnd *, HChar *); /*---------------------------------------------------------------*/ /*--- end s390_disasm.h ---*/ diff --git a/none/tests/s390x/disasm-test/opcode.c b/none/tests/s390x/disasm-test/opcode.c index 24684a613a..e638c973c5 100644 --- a/none/tests/s390x/disasm-test/opcode.c +++ b/none/tests/s390x/disasm-test/opcode.c @@ -743,15 +743,29 @@ static const char *opcodes[] = { "rll r1,r3,d20(b2)", "rllg r1,r3,d20(b2)", - "rnsbg r1,r2,i3:u8,i4:u8,i5:u8", // gie FIXME un/signed i3/4/5 ? t-bit ? z-bit? - "rxsbg r1,r2,i3:u8,i4:u8,i5:u8", // gie FIXME ditto - "rosbg r1,r2,i3:u8,i4:u8,i5:u8", // gie FIXME ditto - - "risbg r1,r2,i3:u8,i4:u8,i5:u8", // gie FIXME ditto - "risbgn r1,r2,i3:u8,i4:u8,i5:u8", // mi1 FIXME ditto - - "risbhg r1,r2,i3:u8,i4:u8,i5:u8", // hiwo FIXME ditto - "risblg r1,r2,i3:u8,i4:u8,i5:u8", // hiwo FIXME ditto + // Rotate and .... opcodes require special handling + // + // For rosbg and friends + // - Bit #0 of i3 is the T-bit and bit #1 of i3 ought to be 0. + // - i5 is optional and will not be written when 0 + // + // For risbg and friends + // - Bit #0 of i4 is the Z-bit and bit #1 of i4 ought to be 0. + // - i5 is optional and will not be written when 0 + // + // This implies that we need to model i3, i4 and i5 as masks so + // we can manipulate their value when disassembling or suppress + // the mask altogether. Note that we limit the set of allowed values + // for those masks to avoid excessively large numbers of testcases. + "rnsbg r1,r2,m3:u8{0,1,2,63,128,129,191},m4:u6{0,1,2,63},m5:u6{0,1,2,63}", // gie + "rxsbg r1,r2,m3:u8{0,1,2,63,128,129,191},m4:u6{0,1,2,63},m5:u6{0,1,2,63}", // gie + "rosbg r1,r2,m3:u8{0,1,2,63,128,129,191},m4:u6{0,1,2,63},m5:u6{0,1,2,63}", // gie + + "risbg r1,r2,m3:u6{0,1,2,63},m4:u8{0,1,2,63,128,129,191},m5:u6{0,1,2,63}", // gie + "risbgn r1,r2,m3:u6{0,1,2,63},m4:u8{0,1,2,63,128,129,191},m5:u6{0,1,2,63}", // mi1 + + "risbhg r1,r2,m3:u5{0,1,2,31},m4:u8{0,1,2,31,128,129,159},m5:u6{0,1,2,63}", // hiwo + "risblg r1,r2,m3:u5{0,1,2,31},m4:u8{0,1,2,31,128,129,159},m5:u6{0,1,2,63}", // hiwo "srst r1,r2", |
From: Paul F. <pa...@so...> - 2025-04-12 22:03:57
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=298a93a14c3c18f0edcb22d4c1ad83ddd2753572 commit 298a93a14c3c18f0edcb22d4c1ad83ddd2753572 Author: Paul Floyd <pj...@wa...> Date: Sat Apr 12 23:57:58 2025 +0200 Illumos regtest: use LC_ALL=C for execx test There's an uninitialized read in /usr/bin/printf when using the default en_US.UTF-8 locale. This isn't a printf test, and using the C locale makes the error go away. Diff: --- memcheck/tests/solaris/execx.vgtest | 1 + 1 file changed, 1 insertion(+) diff --git a/memcheck/tests/solaris/execx.vgtest b/memcheck/tests/solaris/execx.vgtest index 3c81690707..8d28bece1b 100644 --- a/memcheck/tests/solaris/execx.vgtest +++ b/memcheck/tests/solaris/execx.vgtest @@ -1,3 +1,4 @@ prereq: test -e execx +env: LC_ALL=C prog: execx vgopts: -q --trace-children=yes --num-callers=1 |
From: Florian K. <fk...@so...> - 2025-04-12 22:00:29
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=1d8257e4a24356198d9a620904ac516bc94d6699 commit 1d8257e4a24356198d9a620904ac516bc94d6699 Author: Florian Krohm <fl...@ei...> Date: Sat Apr 12 21:45:22 2025 +0000 s390x: Fix IR generation for SRNMB disasm-test generated this test: asm volatile("srnmb 4095(%r0)"); which was disassembled in VEX to srnmb 0 causing a mismatch with what objdump does. 4095 is not a valid bfp rounding mode and the old implementation of s390_irgen_SRNMB let it slide by with a warning. However, POP calls for a specification exception in this case. This is what this patch changes.i It also eliminates the s390_irgen_srnmb_wrapper function along the way. While adjusting none/tests/s390x/srnmb.* I noticed that the line number shown in the specification exception is incorrect. This is not a regression. It has been incorrect before as well. I have opened https://bugs.kde.org/show_bug.cgi?id=502729 fro the line number issue. Diff: --- VEX/priv/guest_s390_toIR.c | 41 +++++++++++++++++---------------------- VEX/priv/main_main.c | 3 --- VEX/pub/libvex_emnote.h | 3 --- none/tests/s390x/srnmb.c | 3 ++- none/tests/s390x/srnmb.stderr.exp | 21 ++++++++++++++++---- none/tests/s390x/srnmb.stdout.exp | 1 - 6 files changed, 37 insertions(+), 35 deletions(-) diff --git a/VEX/priv/guest_s390_toIR.c b/VEX/priv/guest_s390_toIR.c index 63dc360b0f..5381e417e8 100644 --- a/VEX/priv/guest_s390_toIR.c +++ b/VEX/priv/guest_s390_toIR.c @@ -11313,12 +11313,24 @@ s390_irgen_SRNM(IRTemp op2addr) } static const HChar * -s390_irgen_SRNMB(IRTemp op2addr) +s390_irgen_SRNMB(UChar b2, UShort d2) { - UInt input_mask, fpc_mask; + /* Can only check at IR generation time when b2 == 0 */ + if (b2 == 0) { + s390_insn_assert("srnmb", d2 <= 3 || d2 == 7); // valid rounding mode + /* d2 == 7 requires fpext */ + if (d2 == 7 && ! s390_host_has_fpext) { + emulation_failure(EmFail_S390X_fpext); + return "srnmb"; + } + } + IRTemp op2addr = newTemp(Ity_I64); - input_mask = 7; - fpc_mask = 7; + assign(op2addr, binop(Iop_Add64, mkU64(d2), b2 != 0 ? get_gpr_dw0(b2) : + mkU64(0))); + + UInt input_mask = 7; + UInt fpc_mask = 7; put_fpc_w0(binop(Iop_Or32, binop(Iop_And32, get_fpc_w0(), mkU32(~fpc_mask)), @@ -11327,25 +11339,8 @@ s390_irgen_SRNMB(IRTemp op2addr) return "srnmb"; } -static void -s390_irgen_srnmb_wrapper(UChar b2, UShort d2) -{ - if (b2 == 0) { /* This is the typical case */ - if (d2 > 3) { - if (s390_host_has_fpext && d2 == 7) { - /* ok */ - } else { - emulation_warning(EmWarn_S390X_invalid_rounding); - d2 = S390_FPC_BFP_ROUND_NEAREST_EVEN; - } - } - } - - s390_format_S_RD(s390_irgen_SRNMB, b2, d2); -} -/* Wrapper to validate the parameter as in SRNMB is not required, as all - the 8 values in op2addr[61:63] correspond to a valid DFP rounding mode */ +/* All 8 values in op2addr[61:63] correspond to a valid DFP rounding mode */ static const HChar * s390_irgen_SRNMT(IRTemp op2addr) { @@ -21017,7 +21012,7 @@ s390_decode_4byte_and_irgen(const UChar *bytes) goto ok; case 0xb2b1: /* STFL */ goto unimplemented; case 0xb2b2: /* LPSWE */ goto unimplemented; - case 0xb2b8: s390_irgen_srnmb_wrapper(S_b2(ovl), S_d2(ovl)); + case 0xb2b8: s390_format_S_RD_raw(s390_irgen_SRNMB, S_b2(ovl), S_d2(ovl)); goto ok; case 0xb2b9: s390_format_S_RD(s390_irgen_SRNMT, S_b2(ovl), S_d2(ovl)); goto ok; diff --git a/VEX/priv/main_main.c b/VEX/priv/main_main.c index fe3cf9e573..0520fd7470 100644 --- a/VEX/priv/main_main.c +++ b/VEX/priv/main_main.c @@ -1535,9 +1535,6 @@ const HChar* LibVEX_EmNote_string ( VexEmNote ew ) " feature requires the floating point extension facility\n" " which is not available on this host. Continuing using\n" " the rounding mode from FPC. Results may differ!"; - case EmWarn_S390X_invalid_rounding: - return "The specified rounding mode is invalid.\n" - " Continuing using 'round to nearest'. Results may differ!"; case EmFail_S390X_stfle: return "Instruction stfle is not supported on this host"; case EmFail_S390X_stckf: diff --git a/VEX/pub/libvex_emnote.h b/VEX/pub/libvex_emnote.h index 27b95880cb..be17a8922f 100644 --- a/VEX/pub/libvex_emnote.h +++ b/VEX/pub/libvex_emnote.h @@ -89,9 +89,6 @@ typedef facility is not available on this host */ EmWarn_S390X_fpext_rounding, - /* insn (e.g. srnmb) specifies an invalid rounding mode */ - EmWarn_S390X_invalid_rounding, - /* stfle insn is not supported on this host */ EmFail_S390X_stfle, diff --git a/none/tests/s390x/srnmb.c b/none/tests/s390x/srnmb.c index 548b644ca3..72fc799fb7 100644 --- a/none/tests/s390x/srnmb.c +++ b/none/tests/s390x/srnmb.c @@ -27,6 +27,7 @@ int main(void) { + setlinebuf(stdout); printf("initial rounding mode = %u\n", get_rounding_mode()); /* Set basic rounding modes in various ways */ @@ -57,7 +58,7 @@ int main(void) srnmb(0,001); printf("rounding mode = %u\n", get_rounding_mode()); - srnmb0(004); // -> emul warning invalid rounding mode + srnmb0(004); // -> specification exception printf("rounding mode = %u\n", get_rounding_mode()); return 0; diff --git a/none/tests/s390x/srnmb.stderr.exp b/none/tests/s390x/srnmb.stderr.exp index b9db22774f..bfdaf8b0ab 100644 --- a/none/tests/s390x/srnmb.stderr.exp +++ b/none/tests/s390x/srnmb.stderr.exp @@ -1,6 +1,19 @@ -Emulation warning: unsupported action: - The specified rounding mode is invalid. - Continuing using 'round to nearest'. Results may differ! - at 0x........: main (srnmb.c:61) +vex s390->IR: specification exception: B2B8 0004 +valgrind: Unrecognised instruction at address 0x......... + at 0x........: main (srnmb.c:59) +Your program just tried to execute an instruction that Valgrind +did not recognise. There are two possible reasons for this. +1. Your program has a bug and erroneously jumped to a non-code + location. If you are running Memcheck and you just saw a + warning about a bad jump, it's probably your program's fault. +2. The instruction is legitimate but Valgrind doesn't handle it, + i.e. it's Valgrind's fault. If you think this is the case or + you are not sure, please let us know and we'll try to fix it. +Either way, Valgrind will now raise a SIGILL signal which will +probably kill your program. + +Process terminating with default action of signal 4 (SIGILL) + Illegal opcode at address 0x........ + at 0x........: main (srnmb.c:59) diff --git a/none/tests/s390x/srnmb.stdout.exp b/none/tests/s390x/srnmb.stdout.exp index c2be0f77a2..c9127aaf1c 100644 --- a/none/tests/s390x/srnmb.stdout.exp +++ b/none/tests/s390x/srnmb.stdout.exp @@ -4,4 +4,3 @@ rounding mode = 2 rounding mode = 1 rounding mode = 0 rounding mode = 1 -rounding mode = 0 |
From: Paul F. <pa...@so...> - 2025-04-12 16:35:28
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=3a23860abe7737d3fababd8c0bb19cf68332fea0 commit 3a23860abe7737d3fababd8c0bb19cf68332fea0 Author: Paul Floyd <pj...@wa...> Date: Sat Apr 12 18:27:06 2025 +0200 Illumos regtest: add 'illumos' to os_test and turn off a few tests The threadname tests fail on Illumos. Solaris has a syscall, sys_lwp_name, which we intercept and record. Illumos doesn't have that, with the pthread name functions looking ofr the name in /proc That's not implemented in Valgrind so I'm turning those 2 tests off. The other 3 are all based on none faultstatus. This test checks 4 things, one of which is reading from a 32k mmap that is PRIVATE and READ but is only backed by a 16k file. All other OSes generate a SIGBUS. Illumos just reads 0 from the address. Diff: --- gdbserver_tests/mcsignopass.vgtest | 2 +- gdbserver_tests/mcsigpass.vgtest | 2 +- memcheck/tests/threadname.vgtest | 1 + memcheck/tests/threadname_xml.vgtest | 1 + none/tests/faultstatus.vgtest | 1 + tests/os_test.c | 2 ++ 6 files changed, 7 insertions(+), 2 deletions(-) diff --git a/gdbserver_tests/mcsignopass.vgtest b/gdbserver_tests/mcsignopass.vgtest index 73def5e6b7..33347b7143 100644 --- a/gdbserver_tests/mcsignopass.vgtest +++ b/gdbserver_tests/mcsignopass.vgtest @@ -4,7 +4,7 @@ # faultstatus C code will report a failure for the signal not passed # (i.e. SIGBUG, Test 3). Other tests will be successful, because signals # are eventually passed. -prereq: test -e gdb +prereq: test -e gdb && ! ../tests/os_test illumos prog: ../none/tests/faultstatus vgopts: --tool=memcheck --vgdb=full --vex-iropt-register-updates=allregs-at-mem-access --vgdb-error=0 --vgdb-prefix=./vgdb-prefix-mcsignopass stderr_filter: filter_memcheck_monitor diff --git a/gdbserver_tests/mcsigpass.vgtest b/gdbserver_tests/mcsigpass.vgtest index 20f786456d..9f0d6c9958 100644 --- a/gdbserver_tests/mcsigpass.vgtest +++ b/gdbserver_tests/mcsigpass.vgtest @@ -1,5 +1,5 @@ # test the signal handling, when signals are passed to the Valgrind guest. -prereq: test -e gdb +prereq: test -e gdb && ! ../tests/os_test illumos prog: ../none/tests/faultstatus vgopts: --tool=memcheck --vgdb=full --vex-iropt-register-updates=allregs-at-mem-access --vgdb-error=0 --vgdb-prefix=./vgdb-prefix-mcsigpass stderr_filter: filter_memcheck_monitor diff --git a/memcheck/tests/threadname.vgtest b/memcheck/tests/threadname.vgtest index 2692bd0784..71fd4abe4e 100644 --- a/memcheck/tests/threadname.vgtest +++ b/memcheck/tests/threadname.vgtest @@ -1,3 +1,4 @@ +prereq: ! ../tests/os_test illumos prog: threadname prereq: test -e ./threadname vgopts: -q diff --git a/memcheck/tests/threadname_xml.vgtest b/memcheck/tests/threadname_xml.vgtest index 7796ac2c8e..67ee778f02 100644 --- a/memcheck/tests/threadname_xml.vgtest +++ b/memcheck/tests/threadname_xml.vgtest @@ -1,3 +1,4 @@ +prereq: ! ../tests/os_test illumos prog: threadname prereq: test -e ./threadname vgopts: --xml=yes --xml-fd=2 --log-file=/dev/null diff --git a/none/tests/faultstatus.vgtest b/none/tests/faultstatus.vgtest index d388f29c09..adbd3874e5 100644 --- a/none/tests/faultstatus.vgtest +++ b/none/tests/faultstatus.vgtest @@ -1 +1,2 @@ +prereq: ! ../../tests/os_test illumos prog: faultstatus diff --git a/tests/os_test.c b/tests/os_test.c index 7e47bf0ce4..0c5bb1ddbb 100644 --- a/tests/os_test.c +++ b/tests/os_test.c @@ -25,6 +25,7 @@ char* all_OSes[] = { "darwin", "solaris", "freebsd", + "illumos", NULL }; @@ -66,6 +67,7 @@ static Bool go(char* OS, char *min_version) #elif defined(VGO_solaris) if ( 0 == strcmp( OS, "solaris" ) ) return True; + if ( 0 == strcmp( OS, "illumos" ) ) return True; #elif defined(VGO_freebsd) if ( 0 == strcmp( OS, "freebsd" ) ) return True; |
From: Paul F. <pa...@so...> - 2025-04-12 06:35:45
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=14c11aa117ca01bfa8caba56b66d61c5e806e73f commit 14c11aa117ca01bfa8caba56b66d61c5e806e73f Author: Paul Floyd <pj...@wa...> Date: Sat Apr 12 08:34:13 2025 +0200 FreeBSD nightly: automatically use all CPUs Diff: --- nightly/conf/freebsd.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nightly/conf/freebsd.conf b/nightly/conf/freebsd.conf index 0ca2d8c8a6..d9cc5d6e07 100644 --- a/nightly/conf/freebsd.conf +++ b/nightly/conf/freebsd.conf @@ -1,4 +1,4 @@ export ABT_DETAILS=`uname -mrs` -export ABT_JOBS=4 +export ABT_JOBS=`sysctl -n hw.ncpu` #export ABT_PERF="--tools=none,memcheck,callgrind,helgrind,cachegrind,drd,massif --reps=3 --vg=../valgrind-old --vg=../valgrind-new" export ABT_CONFIGURE_OPTIONS="CC=clang CXX=clang++" |
From: Philippe W. <phi...@so...> - 2025-04-11 20:01:32
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=50d1a471cd86ba82f3bc4e79943b43bf9193d8cb commit 50d1a471cd86ba82f3bc4e79943b43bf9193d8cb Author: Philippe Waroquiers <phi...@sk...> Date: Fri Apr 11 21:37:18 2025 +0200 Fix typo: segement -> segment No impact, typo in a comment. Diff: --- coregrind/m_ume/elf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coregrind/m_ume/elf.c b/coregrind/m_ume/elf.c index 67d3139d29..5f2ac1fedb 100644 --- a/coregrind/m_ume/elf.c +++ b/coregrind/m_ume/elf.c @@ -514,7 +514,7 @@ Bool VG_(match_ELF)(const void *hdr, SizeT len) the furthest-along mapping it creates. The executable is mapped starting at EBASE, which is usually read from it (eg, 0x8048000 etc) except if it's a PIE, in which case aspacem is queried for - the first adequately sized segement. + the first adequately sized segment. The returned address is recorded in info->brkbase as the start point of the brk (data) segment, as it is traditional to place |
From: Paul F. <pa...@so...> - 2025-04-11 18:31:34
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=80aaed9a8e57d41e47f82613053619b304dd0928 commit 80aaed9a8e57d41e47f82613053619b304dd0928 Author: Paul Floyd <pj...@wa...> Date: Fri Apr 11 20:29:58 2025 +0200 Regtest: use FLAG_PIE for bug290061 Illumos GCC doesn't have -pie. Also use it for the link command. Diff: --- none/tests/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/none/tests/Makefile.am b/none/tests/Makefile.am index 8bd4b9bf28..ccad463cab 100644 --- a/none/tests/Makefile.am +++ b/none/tests/Makefile.am @@ -374,7 +374,7 @@ AM_CXXFLAGS += $(AM_FLAG_M3264_PRI) # Extra stuff for C tests ansi_CFLAGS = $(AM_CFLAGS) -ansi -bug290061_CFLAGS = ${AM_CFLAGS} -pie +bug290061_LDFLAGS = @FLAG_PIE@ bug491394_LDADD = -lc bug491394_LDFLAGS = -nostdlib -static bug491394_CFLAGS = ${AM_CFLAGS} -Os |
From: Andreas A. <ar...@so...> - 2025-04-11 14:53:46
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=6efb1ef86b1ec547ac4dddecc529dbbfeae409cf commit 6efb1ef86b1ec547ac4dddecc529dbbfeae409cf Author: Andreas Arnez <ar...@li...> Date: Thu Apr 10 17:27:30 2025 +0200 s390x: Implement VTM without dirty helper The VTM instruction is currently translated to a dirty helper call, which comes with the usual drawbacks. Replace its implementation and remove the dirty helper. Diff: --- VEX/priv/guest_s390_defs.h | 1 - VEX/priv/guest_s390_helpers.c | 7 ------- VEX/priv/guest_s390_toIR.c | 45 ++++++++++++++++++++----------------------- 3 files changed, 21 insertions(+), 32 deletions(-) diff --git a/VEX/priv/guest_s390_defs.h b/VEX/priv/guest_s390_defs.h index 0ec242a99b..29efa01311 100644 --- a/VEX/priv/guest_s390_defs.h +++ b/VEX/priv/guest_s390_defs.h @@ -268,7 +268,6 @@ typedef enum { S390_VEC_OP_VPKS, S390_VEC_OP_VPKLS, S390_VEC_OP_VCEQ, - S390_VEC_OP_VTM, S390_VEC_OP_VGFM, S390_VEC_OP_VGFMA, S390_VEC_OP_VMAH, diff --git a/VEX/priv/guest_s390_helpers.c b/VEX/priv/guest_s390_helpers.c index b99d71a5af..6e0321feaa 100644 --- a/VEX/priv/guest_s390_helpers.c +++ b/VEX/priv/guest_s390_helpers.c @@ -2453,7 +2453,6 @@ s390x_dirtyhelper_vec_op(VexGuestS390XState *guest_state, [S390_VEC_OP_VPKS] = {0xe7, 0x97}, [S390_VEC_OP_VPKLS] = {0xe7, 0x95}, [S390_VEC_OP_VCEQ] = {0xe7, 0xf8}, - [S390_VEC_OP_VTM] = {0xe7, 0xd8}, [S390_VEC_OP_VGFM] = {0xe7, 0xb4}, [S390_VEC_OP_VGFMA] = {0xe7, 0xbc}, [S390_VEC_OP_VMAH] = {0xe7, 0xab}, @@ -2538,12 +2537,6 @@ s390x_dirtyhelper_vec_op(VexGuestS390XState *guest_state, the_insn.VRR.op2 = opcodes[d->op][1]; switch(d->op) { - case S390_VEC_OP_VTM: - the_insn.VRR.v1 = 2; - the_insn.VRR.v2 = 3; - the_insn.VRR.rxb = 0b1100; - break; - case S390_VEC_OP_VPKS: case S390_VEC_OP_VPKLS: case S390_VEC_OP_VCEQ: diff --git a/VEX/priv/guest_s390_toIR.c b/VEX/priv/guest_s390_toIR.c index f2ef193765..63dc360b0f 100644 --- a/VEX/priv/guest_s390_toIR.c +++ b/VEX/priv/guest_s390_toIR.c @@ -19087,32 +19087,29 @@ s390_irgen_VSUMQ(UChar v1, UChar v2, UChar v3, UChar m4) static const HChar * s390_irgen_VTM(UChar v1, UChar v2) { - IRDirty* d; - IRTemp cc = newTemp(Ity_I64); - - s390x_vec_op_details_t details = { .serialized = 0ULL }; - details.op = S390_VEC_OP_VTM; - details.v2 = v1; - details.v3 = v2; - details.read_only = 1; - - d = unsafeIRDirty_1_N(cc, 0, "s390x_dirtyhelper_vec_op", - &s390x_dirtyhelper_vec_op, - mkIRExprVec_2(IRExpr_GSPTR(), - mkU64(details.serialized))); - - d->nFxState = 2; - vex_bzero(&d->fxState, sizeof(d->fxState)); - d->fxState[0].fx = Ifx_Read; - d->fxState[0].offset = S390X_GUEST_OFFSET(guest_v0) + v1 * sizeof(V128); - d->fxState[0].size = sizeof(V128); - d->fxState[1].fx = Ifx_Read; - d->fxState[1].offset = S390X_GUEST_OFFSET(guest_v0) + v2 * sizeof(V128); - d->fxState[1].size = sizeof(V128); + IRTemp op1 = newTemp(Ity_V128); + IRTemp op2 = newTemp(Ity_V128); + IRTemp masked = newTemp(Ity_V128); + IRTemp diff = newTemp(Ity_V128); + IRTemp cc = newTemp(Ity_I64); + IRExpr* masked_is_zero; + IRExpr* diff_is_zero; - stmt(IRStmt_Dirty(d)); + assign(op1, get_vr_qw(v1)); + assign(op2, get_vr_qw(v2)); + assign(masked, binop(Iop_AndV128, mkexpr(op1), mkexpr(op2))); + assign(diff, binop(Iop_XorV128, mkexpr(op2), mkexpr(masked))); + masked_is_zero = binop(Iop_CmpEQ64, + binop(Iop_Or64, unop(Iop_V128to64, mkexpr(masked)), + unop(Iop_V128HIto64, mkexpr(masked))), + mkU64(0)); + diff_is_zero = binop(Iop_CmpEQ64, + binop(Iop_Or64, unop(Iop_V128to64, mkexpr(diff)), + unop(Iop_V128HIto64, mkexpr(diff))), + mkU64(0)); + assign(cc, mkite(masked_is_zero, mkU64(0), + mkite(diff_is_zero, mkU64(3), mkU64(1)))); s390_cc_set(cc); - return "vtm"; } |
From: Florian K. <fk...@so...> - 2025-04-11 12:01:17
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=395274bca618c356b282256c999200bb0d44eda6 commit 395274bca618c356b282256c999200bb0d44eda6 Author: Florian Krohm <fl...@ei...> Date: Fri Apr 11 12:00:11 2025 +0000 s390x: disasm-test - minor tweak Diff: --- none/tests/s390x/disasm-test/README | 2 +- none/tests/s390x/disasm-test/generate.c | 2 +- none/tests/s390x/disasm-test/main.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/none/tests/s390x/disasm-test/README b/none/tests/s390x/disasm-test/README index 36485aec33..a3b4ea4e2b 100644 --- a/none/tests/s390x/disasm-test/README +++ b/none/tests/s390x/disasm-test/README @@ -53,7 +53,7 @@ Other non-debugging options Specify which GCC to use. Default is: gcc on $PATH. --gcc-flags=FLAGS - Specify which flags GCC to use. Default is: "-c -march=arch14". + Specify which flags GCC to use. Default is: "-march=arch14". --objdump=/path/to/objdump Specify which objdump to use. Default is: objdump on $PATH. diff --git a/none/tests/s390x/disasm-test/generate.c b/none/tests/s390x/disasm-test/generate.c index 2dc1970425..408fe370e0 100644 --- a/none/tests/s390x/disasm-test/generate.c +++ b/none/tests/s390x/disasm-test/generate.c @@ -567,7 +567,7 @@ generate_tests(const opcode *opc) printf("...%u testcases generated for '%s'\n", num_tests, opc->name); - run_cmd("%s %s %s.c", gcc, gcc_flags, opc->name); + run_cmd("%s -c %s %s.c", gcc, gcc_flags, opc->name); run_cmd("%s --disassemble=%s %s.o > %s.dump", objdump, FUNCTION, opc->name, opc->name); diff --git a/none/tests/s390x/disasm-test/main.c b/none/tests/s390x/disasm-test/main.c index f74dc73894..c61ab8c681 100644 --- a/none/tests/s390x/disasm-test/main.c +++ b/none/tests/s390x/disasm-test/main.c @@ -36,7 +36,7 @@ int verbose, debug, show_spec_exc, show_miscompares; const char *gcc = "gcc"; // path to GCC const char *objdump = "objdump"; // path to objdump -const char *gcc_flags = "-c -march=arch14"; +const char *gcc_flags = "-march=arch14"; #define CHECK_CLO(x, s) (strncmp(x, s, sizeof s - 1) == 0) |