diff --git a/0012-Recognize-new-DWARF5-DW_LANG-constants.patch b/0012-Recognize-new-DWARF5-DW_LANG-constants.patch new file mode 100644 index 0000000..ef89578 --- /dev/null +++ b/0012-Recognize-new-DWARF5-DW_LANG-constants.patch @@ -0,0 +1,144 @@ +From a2c30f44ac39eb36baa4e831b041fe7cdf25e481 Mon Sep 17 00:00:00 2001 +From: Mark Wielaard +Date: Fri, 6 Dec 2024 15:39:25 +0100 +Subject: [PATCH 12/14] Recognize new DWARF5 DW_LANG constants + +When using --read-var-info=yes readdwarf3 will try to read and +interpret the CU DW_AT_langauge attribute. Since DWARF5 was released a +number if new language constants have been introduced. See +https://dwarfstd.org/languages.html + +GCC15 might start emitting some of these when switching to C23 by +default. + +When valgrind --read-var-info=yes encounters an unknown DW_LANG +constant it will produce an error and stop processing any further +DWARF. + +Recognize all currently known language constants. In particular +recognize DW_LANG_C17, DW_LANG_C23, DW_LANG_C_plus_plus_17, +DW_LANG_C_plus_plus_20, DW_LANG_C_plus_plus_23, DW_LANG_Fortran18, +DW_LANG_Fortran23, DW_LANG_Ada2005, DW_LANG_Ada2012 and DW_LANG_Rust. + +https://bugs.kde.org/show_bug.cgi?id=497130 + +(cherry picked from commit 7136316123c54aba37fdab166e1bf860e452a4ae) +--- + NEWS | 1 + + coregrind/m_debuginfo/priv_d3basics.h | 31 +++++++++++++++++++++++++++ + coregrind/m_debuginfo/readdwarf3.c | 27 +++++++++++++++++++++-- + 3 files changed, 57 insertions(+), 2 deletions(-) + +diff --git a/NEWS b/NEWS +index 7f1334aa0f07..a25f9b663098 100644 +--- a/NEWS ++++ b/NEWS +@@ -7,6 +7,7 @@ The following bugs have been fixed or resolved on this branch. + + 489913 WARNING: unhandled amd64-linux syscall: 444 (landlock_create_ruleset) + 494246 syscall fsopen not wrapped ++497130 Recognize new DWARF5 DW_LANG constants + + To see details of a given bug, visit + https://bugs.kde.org/show_bug.cgi?id=XXXXXX +diff --git a/coregrind/m_debuginfo/priv_d3basics.h b/coregrind/m_debuginfo/priv_d3basics.h +index 3f6e5c72c9e4..34c98728711c 100644 +--- a/coregrind/m_debuginfo/priv_d3basics.h ++++ b/coregrind/m_debuginfo/priv_d3basics.h +@@ -179,6 +179,7 @@ typedef enum dwarf_source_language + /* DWARF 4. */ + DW_LANG_Python = 0x0014, + /* DWARF 5. */ ++ DW_LANG_OpenCL = 0x0015, + DW_LANG_Go = 0x0016, + DW_LANG_Modula3 = 0x0017, + DW_LANG_Haskell = 0x0018, +@@ -195,6 +196,36 @@ typedef enum dwarf_source_language + DW_LANG_Fortran08 = 0x0023, + DW_LANG_RenderScript = 0x0024, + DW_LANG_BLISS = 0x0025, ++ /* Language codes added since DWARF 5. ++ https://dwarfstd.org/languages.html */ ++ DW_LANG_Kotlin = 0x0026, ++ DW_LANG_Zig = 0x0027, ++ DW_LANG_Crystal = 0x0028, ++ DW_LANG_C_plus_plus_17 = 0x002a, ++ DW_LANG_C_plus_plus_20 = 0x002b, ++ DW_LANG_C17 = 0x002c, ++ DW_LANG_Fortran18 = 0x002d, ++ DW_LANG_Ada2005 = 0x002e, ++ DW_LANG_Ada2012 = 0x002f, ++ DW_LANG_HIP = 0x0030, ++ DW_LANG_Assembly = 0x0031, ++ DW_LANG_C_sharp = 0x0032, ++ DW_LANG_Mojo = 0x0033, ++ DW_LANG_GLSL = 0x0034, ++ DW_LANG_GLSL_ES = 0x0035, ++ DW_LANG_HLSL = 0x0036, ++ DW_LANG_OpenCL_CPP = 0x0037, ++ DW_LANG_CPP_for_OpenCL = 0x0038, ++ DW_LANG_SYCL = 0x0039, ++ DW_LANG_C_plus_plus_23 = 0x003a, ++ DW_LANG_Odin = 0x003b, ++ DW_LANG_P4 = 0x003c, ++ DW_LANG_Metal = 0x003d, ++ DW_LANG_C23 = 0x003e, ++ DW_LANG_Fortran23 = 0x003f, ++ DW_LANG_Ruby = 0x0040, ++ DW_LANG_Move = 0x0041, ++ DW_LANG_Hylo = 0x0042, + /* MIPS. */ + DW_LANG_Mips_Assembler = 0x8001, + /* UPC. */ +diff --git a/coregrind/m_debuginfo/readdwarf3.c b/coregrind/m_debuginfo/readdwarf3.c +index a4b75a8c532b..735896f7c0d3 100644 +--- a/coregrind/m_debuginfo/readdwarf3.c ++++ b/coregrind/m_debuginfo/readdwarf3.c +@@ -3972,19 +3972,42 @@ static void parse_type_DIE ( /*MOD*/XArray* /* of TyEnt */ tyents, + case DW_LANG_C_plus_plus: case DW_LANG_ObjC: + case DW_LANG_ObjC_plus_plus: case DW_LANG_UPC: + case DW_LANG_Upc: case DW_LANG_C99: case DW_LANG_C11: ++ case DW_LANG_C17: case DW_LANG_C23: + case DW_LANG_C_plus_plus_11: case DW_LANG_C_plus_plus_14: ++ case DW_LANG_C_plus_plus_17: case DW_LANG_C_plus_plus_20: ++ case DW_LANG_C_plus_plus_23: + parser->language = 'C'; break; + case DW_LANG_Fortran77: case DW_LANG_Fortran90: + case DW_LANG_Fortran95: case DW_LANG_Fortran03: +- case DW_LANG_Fortran08: ++ case DW_LANG_Fortran08: case DW_LANG_Fortran18: ++ case DW_LANG_Fortran23: + parser->language = 'F'; break; + case DW_LANG_Ada83: case DW_LANG_Ada95: ++ case DW_LANG_Ada2005: case DW_LANG_Ada2012: + parser->language = 'A'; break; + case DW_LANG_Cobol74: + case DW_LANG_Cobol85: case DW_LANG_Pascal83: + case DW_LANG_Modula2: case DW_LANG_Java: + case DW_LANG_PLI: +- case DW_LANG_D: case DW_LANG_Python: case DW_LANG_Go: ++ case DW_LANG_D: case DW_LANG_Python: ++ case DW_LANG_OpenCL: case DW_LANG_Go: ++ case DW_LANG_Modula3: case DW_LANG_Haskell: ++ case DW_LANG_OCaml: case DW_LANG_Rust: case DW_LANG_Swift: ++ case DW_LANG_Julia: case DW_LANG_Dylan: ++ case DW_LANG_RenderScript: case DW_LANG_BLISS: ++ case DW_LANG_Kotlin: case DW_LANG_Zig: ++ case DW_LANG_Crystal: case DW_LANG_HIP: ++ case DW_LANG_Assembly: case DW_LANG_C_sharp: ++ case DW_LANG_Mojo: case DW_LANG_GLSL: ++ case DW_LANG_GLSL_ES: case DW_LANG_HLSL: ++ case DW_LANG_OpenCL_CPP: case DW_LANG_CPP_for_OpenCL: ++ case DW_LANG_SYCL: ++ case DW_LANG_Odin: ++ case DW_LANG_P4: ++ case DW_LANG_Metal: ++ case DW_LANG_Ruby: ++ case DW_LANG_Move: ++ case DW_LANG_Hylo: + case DW_LANG_Mips_Assembler: + parser->language = '?'; break; + default: +-- +2.47.1 + diff --git a/0013-Bug-498317-FdBadUse-is-not-a-valid-CoreError-type-in.patch b/0013-Bug-498317-FdBadUse-is-not-a-valid-CoreError-type-in.patch new file mode 100644 index 0000000..6c8c3f7 --- /dev/null +++ b/0013-Bug-498317-FdBadUse-is-not-a-valid-CoreError-type-in.patch @@ -0,0 +1,147 @@ +From febe1ccef09f70777b086f938c03f3e71989a7c8 Mon Sep 17 00:00:00 2001 +From: Paul Floyd +Date: Tue, 7 Jan 2025 08:05:20 +0100 +Subject: [PATCH 13/14] Bug 498317 - FdBadUse is not a valid CoreError type in + a suppression even though it's generated by --gen-suppressions=yes + +https://bugs.kde.org/show_bug.cgi?id=498317 + +(cherry picked from commit 47bdc4a6f3de8e2071561d349fdd5f830388c489) +--- + NEWS | 2 ++ + coregrind/m_errormgr.c | 7 +++++-- + coregrind/m_syswrap/syswrap-freebsd.c | 4 ++++ + none/tests/freebsd/Makefile.am | 4 +++- + none/tests/freebsd/bug498317.c | 7 +++++++ + none/tests/freebsd/bug498317.stderr.exp | 0 + none/tests/freebsd/bug498317.supp | 8 ++++++++ + none/tests/freebsd/bug498317.vgtest | 2 ++ + 9 files changed, 32 insertions(+), 3 deletions(-) + create mode 100644 none/tests/freebsd/bug498317.c + create mode 100644 none/tests/freebsd/bug498317.stderr.exp + create mode 100644 none/tests/freebsd/bug498317.supp + create mode 100644 none/tests/freebsd/bug498317.vgtest + +diff --git a/NEWS b/NEWS +index a25f9b663098..2fb8ce5c724b 100644 +--- a/NEWS ++++ b/NEWS +@@ -8,6 +8,8 @@ The following bugs have been fixed or resolved on this branch. + 489913 WARNING: unhandled amd64-linux syscall: 444 (landlock_create_ruleset) + 494246 syscall fsopen not wrapped + 497130 Recognize new DWARF5 DW_LANG constants ++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 +diff --git a/coregrind/m_errormgr.c b/coregrind/m_errormgr.c +index 4bbcea02474c..2ce919482f77 100644 +--- a/coregrind/m_errormgr.c ++++ b/coregrind/m_errormgr.c +@@ -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"); + } +diff --git a/coregrind/m_syswrap/syswrap-freebsd.c b/coregrind/m_syswrap/syswrap-freebsd.c +index 685eb6be076c..a2b79545594e 100644 +--- a/coregrind/m_syswrap/syswrap-freebsd.c ++++ b/coregrind/m_syswrap/syswrap-freebsd.c +@@ -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) +diff --git a/none/tests/freebsd/Makefile.am b/none/tests/freebsd/Makefile.am +index fe4f8db69824..1ccfefb57fe2 100644 +--- a/none/tests/freebsd/Makefile.am ++++ b/none/tests/freebsd/Makefile.am +@@ -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 +index 000000000000..36a1a5a1365e +--- /dev/null ++++ b/none/tests/freebsd/bug498317.c +@@ -0,0 +1,7 @@ ++#include ++ ++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 +index 000000000000..e69de29bb2d1 +diff --git a/none/tests/freebsd/bug498317.supp b/none/tests/freebsd/bug498317.supp +new file mode 100644 +index 000000000000..b3a99447c2a4 +--- /dev/null ++++ b/none/tests/freebsd/bug498317.supp +@@ -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 +index 000000000000..6579ebce8c56 +--- /dev/null ++++ b/none/tests/freebsd/bug498317.vgtest +@@ -0,0 +1,2 @@ ++prog: bug498317 ++vgopts: -q +-- +2.47.1 + diff --git a/0014-linux-support-EVIOCGRAB-ioctl.patch b/0014-linux-support-EVIOCGRAB-ioctl.patch new file mode 100644 index 0000000..8213dc0 --- /dev/null +++ b/0014-linux-support-EVIOCGRAB-ioctl.patch @@ -0,0 +1,60 @@ +From b732f86998e39ca8714330f487804428b54c481c Mon Sep 17 00:00:00 2001 +From: Mark Wielaard +Date: Wed, 8 Jan 2025 16:52:03 +0100 +Subject: [PATCH 14/14] linux: support EVIOCGRAB ioctl + +EVIOCGRAB just takes an int argument. + +https://bugs.kde.org/show_bug.cgi?id=498143 + +(cherry picked from commit 59eb5a4af60d4beb2c6910a1fa6cdf8d1f3a56f2) +--- + NEWS | 1 + + coregrind/m_syswrap/syswrap-linux.c | 4 ++++ + include/vki/vki-linux.h | 3 +++ + 3 files changed, 8 insertions(+) + +diff --git a/NEWS b/NEWS +index 2fb8ce5c724b..7f9e005c59f4 100644 +--- a/NEWS ++++ b/NEWS +@@ -10,6 +10,7 @@ The following bugs have been fixed or resolved on this branch. + 497130 Recognize new DWARF5 DW_LANG constants + 498317 FdBadUse is not a valid CoreError type in a suppression + even though it's generated by --gen-suppressions=yes ++498143 False positive on EVIOCGRAB ioctl + + To see details of a given bug, visit + https://bugs.kde.org/show_bug.cgi?id=XXXXXX +diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c +index 57672f167126..87ab82e6e342 100644 +--- a/coregrind/m_syswrap/syswrap-linux.c ++++ b/coregrind/m_syswrap/syswrap-linux.c +@@ -10397,6 +10397,10 @@ PRE(sys_ioctl) + break; + } + ++ case VKI_EVIOCGRAB: ++ /* This just takes an int argument. */ ++ break; ++ + default: + /* EVIOC* are variable length and return size written on success */ + switch (ARG2 & ~(_VKI_IOC_SIZEMASK << _VKI_IOC_SIZESHIFT)) { +diff --git a/include/vki/vki-linux.h b/include/vki/vki-linux.h +index 006f16d92201..d4e1908e1e9c 100644 +--- a/include/vki/vki-linux.h ++++ b/include/vki/vki-linux.h +@@ -3226,6 +3226,9 @@ struct vki_getcpu_cache { + + #define VKI_EVIOCGBIT(ev,len) _VKI_IOC(_VKI_IOC_READ, 'E', 0x20 + ev, len) /* get event bits */ + ++#define VKI_EVIOCGRAB _VKI_IOW('E', 0x90, int) ++/* grab device */ ++ + /* + * Event types + */ +-- +2.47.1 + diff --git a/valgrind.spec b/valgrind.spec index fed1ba9..dd21a50 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -97,6 +97,9 @@ Patch12: 0008-helgrind-tests-tc17_sembar.c-Remove-bool-typedef.patch Patch13: 0009-drd-tests-swapcontext.c-Rename-typedef-struct-thread.patch Patch14: 0010-none-tests-bug234814.c-sa_handler-take-an-int-as-arg.patch Patch15: 0011-Add-open_tree-move_mount-fsopen-fsconfig-fsmount-fsp.patch +Patch16: 0012-Recognize-new-DWARF5-DW_LANG-constants.patch +Patch17: 0013-Bug-498317-FdBadUse-is-not-a-valid-CoreError-type-in.patch +Patch18: 0014-linux-support-EVIOCGRAB-ioctl.patch BuildRequires: make BuildRequires: glibc-devel @@ -247,6 +250,9 @@ Valgrind User Manual for details. %patch -P13 -p1 %patch -P14 -p1 %patch -P15 -p1 +%patch -P16 -p1 +%patch -P17 -p1 +%patch -P18 -p1 %build # LTO triggers undefined symbols in valgrind. But valgrind has a @@ -463,6 +469,11 @@ echo ===============END TESTING=============== %endif %changelog +* Tue Jan 14 2025 Mark Wielaard +- Add more VALGRIND_3_24_BRANCH patches + 0012-Recognize-new-DWARF5-DW_LANG-constants.patch + 0013-Bug-498317-FdBadUse-is-not-a-valid-CoreError-type-in.patch + 0014-linux-support-EVIOCGRAB-ioctl.patch * Tue Nov 26 2024 Mark Wielaard - 3.24.0-2 - Add VALGRIND_3_24_BRANCH patches 0001-Prepare-NEWS-for-branch-3.24-fixes.patch