]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Bug 498317 - FdBadUse is not a valid CoreError type in a suppression even though...
authorPaul Floyd <pjfloyd@wanadoo.fr>
Tue, 7 Jan 2025 07:05:20 +0000 (08:05 +0100)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Tue, 7 Jan 2025 07:05:20 +0000 (08:05 +0100)
.gitignore
NEWS
coregrind/m_errormgr.c
coregrind/m_syswrap/syswrap-freebsd.c
none/tests/freebsd/Makefile.am
none/tests/freebsd/bug498317.c [new file with mode: 0644]
none/tests/freebsd/bug498317.stderr.exp [new file with mode: 0644]
none/tests/freebsd/bug498317.supp [new file with mode: 0644]
none/tests/freebsd/bug498317.vgtest [new file with mode: 0644]

index 46c9126716d81cb673e9e6ce77156f91592a4894..0456de003fe7ad58024c1a2851225035e5e15ab4 100644 (file)
 /none/tests/freebsd/Makefile
 /none/tests/freebsd/Makefile.in
 /none/tests/freebsd/auxv
+/none/tests/freebsd/bug498317
 /none/tests/freebsd/osrel
 /none/tests/freebsd/swapcontext
 /none/tests/freebsd/fexecve
diff --git a/NEWS b/NEWS
index 0be2ff033959536d291e9c0ae5fcd30e22571d55..118961a034c33cb6fe611f1ab81df082899d8dfb 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -38,6 +38,8 @@ are not entered into bugzilla tend to get forgotten about or ignored.
 497455  Update drd/scripts/download-and-build-gcc
 497723  Enabling Ada demangling breaks callgrind differentiation between
         overloaded functions and procedures
+498317  FdBadUse is not a valid CoreError type in a suppression
+        even though it's generated by --gen-suppressions=yes
 
 To see details of a given bug, visit
   https://bugs.kde.org/show_bug.cgi?id=XXXXXX
index 4bbcea02474cca4656a61cba92d3ddc2132adca8..2ce919482f771b89bfce9e6c9cae8455374349ba 100644 (file)
@@ -206,7 +206,8 @@ typedef
       // example should new core errors ever be added.
       ThreadSupp = -1,    /* Matches ThreadErr */
       FdBadCloseSupp = -2,
-      FdNotClosedSupp = -3
+      FdNotClosedSupp = -3,
+      FdBadUseSupp = -4
    }
    CoreSuppKind;
 
@@ -1033,7 +1034,7 @@ static Bool core_error_matches_suppression(const Error* err, const Supp* su)
       return err->ekind == FdBadClose;
    case FdNotClosedSupp:
       return err->ekind == FdNotClosed;
-   case FdBadUse:
+   case FdBadUseSupp:
       return err->ekind == FdBadUse;
    default:
       VG_(umsg)("FATAL: unknown core suppression kind: %d\n", su->skind );
@@ -1522,6 +1523,8 @@ static void load_one_suppressions_file ( Int clo_suppressions_i )
             supp->skind = FdBadCloseSupp;
          else if (VG_STREQ(supp_name, "FdNotClosed"))
             supp->skind = FdNotClosedSupp;
+         else if (VG_STREQ(supp_name, "FdBadUse"))
+            supp->skind = FdBadUseSupp;
          else
             BOMB("unknown core suppression type");
       }
index ea0ca2bfe5f12435a54f3abdac40ecbe879f31ac..d358c90eb05104ec231c19233b49623ed8b2a1c4 100644 (file)
@@ -1400,6 +1400,10 @@ PRE(sys_fcntl)
       PRINT("sys_fcntl[UNKNOWN] ( %lu, %lu, %lu )", ARG1,ARG2,ARG3);
       I_die_here;
    }
+
+   if (!ML_(fd_allowed)(ARG1, "fcntl", tid, False)) {
+     SET_STATUS_Failure (VKI_EBADF);
+   }
 }
 
 POST(sys_fcntl)
index fe4f8db69824430f4c3d8cbf64a448c7ccf91174..1ccfefb57fe2e3902c4bafbac8b58e44df0cf444 100644 (file)
@@ -11,6 +11,8 @@ EXTRA_DIST = \
        auxv.stderr.exp-freebsd131 \
        auxv.stderr.exp-freebsd14 \
        auxv.stderr.exp-arm64 \
+       bug498317.vgtest bug498317.stderr.exp \
+       bug498317.supp \
        cp.vgtest \
        cp.stderr.exp \
        osrel.vgtest \
@@ -61,7 +63,7 @@ EXTRA_DIST = \
        usrstack.stdout.exp
 
 check_PROGRAMS = \
-       auxv osrel swapcontext hello_world fexecve 452275 usrstack \
+       auxv bug498317 osrel swapcontext hello_world fexecve 452275 usrstack \
        proc_pid_file sanity_level_thread umtx_shm_creat
 
 AM_CFLAGS   += $(AM_FLAG_M3264_PRI)
diff --git a/none/tests/freebsd/bug498317.c b/none/tests/freebsd/bug498317.c
new file mode 100644 (file)
index 0000000..36a1a5a
--- /dev/null
@@ -0,0 +1,7 @@
+#include <fcntl.h>
+
+int main(void) {
+        fcntl(-1, F_GETFD);
+        return 0;
+}
+
diff --git a/none/tests/freebsd/bug498317.stderr.exp b/none/tests/freebsd/bug498317.stderr.exp
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/none/tests/freebsd/bug498317.supp b/none/tests/freebsd/bug498317.supp
new file mode 100644 (file)
index 0000000..b3a9944
--- /dev/null
@@ -0,0 +1,8 @@
+{
+   test suppression of FdBadUse
+   CoreError:FdBadUse
+   fun:_fcntl
+   fun:fcntl
+   fun:main
+}
+
diff --git a/none/tests/freebsd/bug498317.vgtest b/none/tests/freebsd/bug498317.vgtest
new file mode 100644 (file)
index 0000000..6579ebc
--- /dev/null
@@ -0,0 +1,2 @@
+prog: bug498317
+vgopts: -q