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 + |