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: Mark W. <ma...@kl...> - 2025-01-30 23:57:31
|
Hi, Thanks to RISC-V International we got 3 new buildbot CI workers. One HiFive Premier P550 https://www.sifive.com/boards/hifive-premier-p550 and two Banana Pi BPI-F3 https://wiki.banana-pi.org/Banana_Pi_BPI-F3 They have been used for testing the proposed Valgrind risc-vv backend: https://bugs.kde.org/show_bug.cgi?id=468575 Test results look good, but we can use some help integrating and maintaining it. The P550 now runs a gdb and full testsuite build: https://builder.sourceware.org/buildbot/#/builders/gdb-riscv-full Results look fairly good: === gdb Summary === # of unexpected core files 1 # of expected passes 121159 # of unexpected failures 333 # of expected failures 88 # of known failures 116 # of untested testcases 41 # of unresolved testcases 20 # of unsupported tests 827 # of paths in test names 2 # of duplicate test names 8 There are also gdb full test builds for amd64 and arm64 https://builder.sourceware.org/buildbot/#/builders?tags=gdb-full All results are in bunsen to make it easy to compare https://builder.sourceware.org/testruns/?has_keyvalue_op=glob&has_keyvalue_k=testrun.git_describe&has_keyvalue_v=buildbot/gdb-%2A-full%2A One bpi-f3 runs glibc and the full testsuite. https://builder.sourceware.org/buildbot/#/builders/glibc-fedora-riscv There is one failure rt/tst-clock_nanosleep2 which seems a testsuite issue which is being discussed. And one flaky test stdio-common/tst-fwrite-bz29459 which also occassionally fails on other arches. The other bpi-f3 runs a gcc bootstrap and full testsuite. https://builder.sourceware.org/buildbot/#/builders/gcc-full-spacemit-x60 This takes ~22+ hours (7:30 hours bootstrap, 14:30 hours tests) This is a lot slower than the pioneer box (which has 64 cores) https://builder.sourceware.org/buildbot/#/builders/gcc-full-fedora-riscv but the bpi-f3 has an 8 core SpacemiT K1 supporting rvv 1.0. Test results attached. Cheers, Mark |
From: Paul F. <pj...@wa...> - 2025-01-29 07:50:04
|
On 18-01-25 12:09, Enzo Bonansea wrote: > Hello, > > For my computer science thesis, I need to instrument programs in order > to know which floating point values are being stored to buffers whose > size is greater than a certain threshold. For doing that, I modified the > tool memcheck in this public repository <https://github.com/ > enzobonansea/floating-point-vectors-inspector>; you can find my > modifications by searching for "memlog" in the code. > > The customization works as I expect, giving me the floating point values > that I need. Now, I want to optimize my code since it's CPU intensive > and makes the instrumented applications too slow. For instance, I ran > the memcheck customization against the SPEC2017 tool called lbm which > took originally a few seconds to run, but under the tool it takes more > than 2 minutes with the CPU at 100% all the time. > > If you see the code, the cause of the performance degradation is > evident: for every store I'm calling the dirty helper log_store, which > means that I'm calling that C function millions of times. > > I used Valgrind's memcheck several times as a user, but 2 months ago was > my first time seeing the tool's source code. So, since I'm new on this > and you guys have a lot of experience working on the project, maybe you > find my problem trivial and you can have a good idea of how I can > improve the performance of my customization of memcheck. Hi Do you really need to base your features on memcheck? I imagine that you would get better performance if you wrote a new tool (perhaps starting with lackey). After that, use a cache and write to file as little as possible (but I from what I see you do that already). A+ Paul |
From: Paul F. <pa...@so...> - 2025-01-28 18:26:36
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=a005226db8d59dd5c3b35f1011967891c71d9b28 commit a005226db8d59dd5c3b35f1011967891c71d9b28 Author: Paul Floyd <pj...@wa...> Date: Tue Jan 28 19:25:52 2025 +0100 Bug499183 - FreeBSD: differences in avx-vmovq output Diff: --- NEWS | 1 + none/tests/amd64/avx-vmovq.c | 4 ++-- none/tests/amd64/avx-vmovq.stdout.exp | 24 ++++++++++++------------ 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/NEWS b/NEWS index f6f6e9d88f..ca5bfb23f4 100644 --- a/NEWS +++ b/NEWS @@ -49,6 +49,7 @@ are not entered into bugzilla tend to get forgotten about or ignored. even though it's generated by --gen-suppressions=yes 498143 False positive on EVIOCGRAB ioctl 498492 none/tests/amd64/lzcnt64 crashes on FreeBSD compiled with clang +499183 FreeBSD: differences in avx-vmovq output 499212 mmap() with MAP_ALIGNED() returns unaligned pointer To see details of a given bug, visit diff --git a/none/tests/amd64/avx-vmovq.c b/none/tests/amd64/avx-vmovq.c index da8a1959b3..3512aa53b5 100644 --- a/none/tests/amd64/avx-vmovq.c +++ b/none/tests/amd64/avx-vmovq.c @@ -6,8 +6,8 @@ GEN_test_RandM(VMOVQ_XMM_to_XMM_LOW_HIGH, // xmm0 is scratch GEN_test_RandM(VMOVQ_XMM_to_XMM_LOW_LOW_HIGH, - "vmovq %%xmm0, %%xmm7; vmovq %%xmm8, %%xmm0", - "vmovq %%xmm0, (%%rsi); vmovq %%xmm9, %%xmm0") + "vmovq %%xmm7, %%xmm0; vmovq %%xmm0, %%xmm8", + "vmovq (%%rsi), %%xmm0; vmovq %%xmm0, %%xmm9") int main ( void ) { diff --git a/none/tests/amd64/avx-vmovq.stdout.exp b/none/tests/amd64/avx-vmovq.stdout.exp index f5b45e54de..23070740d0 100644 --- a/none/tests/amd64/avx-vmovq.stdout.exp +++ b/none/tests/amd64/avx-vmovq.stdout.exp @@ -87,8 +87,8 @@ VMOVQ_XMM_to_XMM_LOW_LOW_HIGH(reg) c1fbfd8f4d8698c2.cb9dfb4ea5d18713.6489eab2c96df363.d52c4330a7aae391 9d8e66ea90352a18 after - 0000000000000000.0000000000000000.0000000000000000.2525252525252525 - 22cf5e4cfad1bdf5.8de2b4a9d799ff5f.0c05cb6ebd128663.d7568e3e8a3ac80e + 048612e51a468e36.c51cdd8f87e12ab4.acb722146c6cbfa9.ea4a022e1d3d7dbb + 0000000000000000.0000000000000000.0000000000000000.ea4a022e1d3d7dbb 4288ae612c0dad40.f0733f448390351b.80ddba7e53e42d12.3208cf9b04b0569c c1fbfd8f4d8698c2.cb9dfb4ea5d18713.6489eab2c96df363.d52c4330a7aae391 9d8e66ea90352a18 @@ -100,10 +100,10 @@ VMOVQ_XMM_to_XMM_LOW_LOW_HIGH(mem) 5f706da71bf2425f.9605e2b252c1c868.09217c310baca0c3.837be65197abe268 fbc4208894fdc0f5 after - 66fab2b3db5ce85e.f9754842f9c9ba28.f82a63b15c68b274.2525252525252525 + 66fab2b3db5ce85e.f9754842f9c9ba28.f82a63b15c68b274.14575775bc3a1202 0c3ca578a32bd88e.474289e7cb61501e.54e7f35bc162726a.ec91fe34c7d6c79a 6b1fba2604afb8d5.08aebee85fda964f.bba02737f3c98220.4784d95987cd4ed8 - 5f706da71bf2425f.9605e2b252c1c868.09217c310baca0c3.837be65197abe268 + 0000000000000000.0000000000000000.0000000000000000.14575775bc3a1202 fbc4208894fdc0f5 VMOVQ_XMM_to_XMM_LOW_LOW_HIGH(reg) @@ -114,8 +114,8 @@ VMOVQ_XMM_to_XMM_LOW_LOW_HIGH(reg) 61ff7d4df3b6ca81.31f01866bd76c58f.0a7c7a27fe917447.77e3c0b6a9ec44fc 2c3ffa1aebe6a4d2 after - 0000000000000000.0000000000000000.0000000000000000.2525252525252525 - 0e780c65c22b4ab8.778d9ed6d9eb46ea.8ca3e752c306df00.caab752f630ff07e + 0aaa836b194e242c.c5fc3ae904033357.4e92f1b240a12214.1a366d352714867e + 0000000000000000.0000000000000000.0000000000000000.1a366d352714867e 627bb6e12d1f6d46.51ef145cb9b83843.ac82c1007a7d3cd8.f54b130cdaa89cef 61ff7d4df3b6ca81.31f01866bd76c58f.0a7c7a27fe917447.77e3c0b6a9ec44fc 2c3ffa1aebe6a4d2 @@ -127,10 +127,10 @@ VMOVQ_XMM_to_XMM_LOW_LOW_HIGH(mem) 2d460a61a5dd0f6f.47086cc3da642fa7.130d662777beb4a9.1e61c5ec52f79c60 16559ec50352a3d9 after - f02b3b25bca27a9c.69505d14b27d9d16.f25b26e0042fa9fa.2525252525252525 + f02b3b25bca27a9c.69505d14b27d9d16.f25b26e0042fa9fa.02dd0e32eecfc5fa 9f7301c1392d8087.d4ba52a206ff21b1.70fbbab6a7f19faf.f0f1798fe3c1699c 15e3c8dc7e9273bf.0088596389c893fd.879d51d4c5c764db.3004b7a97cf69dda - 2d460a61a5dd0f6f.47086cc3da642fa7.130d662777beb4a9.1e61c5ec52f79c60 + 0000000000000000.0000000000000000.0000000000000000.02dd0e32eecfc5fa 16559ec50352a3d9 VMOVQ_XMM_to_XMM_LOW_LOW_HIGH(reg) @@ -141,8 +141,8 @@ VMOVQ_XMM_to_XMM_LOW_LOW_HIGH(reg) 89fba268812abdb2.1e4a9e0958fac555.adddf0eb4808f067.04c857e949cc0fac bc3127138b19183c after - 0000000000000000.0000000000000000.0000000000000000.2525252525252525 - 9432a2e46543b956.b819f459105730e9.9a49ac115048d4c4.f987fa170d3ce4dd + 742c3e9e2b92eef2.c569453ccd1b0fc4.0784892e9360315b.f0177599dbe14b46 + 0000000000000000.0000000000000000.0000000000000000.f0177599dbe14b46 d2b3c4044ef23fb2.e22093a48a9d2e0b.5da3cfd6aea6558e.0c28728e28dc3c9c 89fba268812abdb2.1e4a9e0958fac555.adddf0eb4808f067.04c857e949cc0fac bc3127138b19183c @@ -154,9 +154,9 @@ VMOVQ_XMM_to_XMM_LOW_LOW_HIGH(mem) 59a93d4f11d611db.5cce191e65591384.ff4cb613013cc685.918107c43ea20cc0 0194ddb82b49abf0 after - 12305efa0acd1475.1755377e9a786f01.4a6592749579b0f4.2525252525252525 + 12305efa0acd1475.1755377e9a786f01.4a6592749579b0f4.e4450ababbfae0f9 e1917689e3f6bf86.d70f7fb13667914c.413cead25e27ac14.5f2619b1a20662f0 0420edac31a0d599.2573776df1835e3e.de9a220dce0e75e0.7acb193b9abab2f9 - 59a93d4f11d611db.5cce191e65591384.ff4cb613013cc685.918107c43ea20cc0 + 0000000000000000.0000000000000000.0000000000000000.e4450ababbfae0f9 0194ddb82b49abf0 |
From: Philippe W. <phi...@so...> - 2025-01-28 14:45:07
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=388e6732852c3be128af601901447980dfc526b7 commit 388e6732852c3be128af601901447980dfc526b7 Author: Philippe Waroquiers <phi...@sk...> Date: Tue Jan 28 15:33:15 2025 +0100 Let gdbserver the support of 'x' packet by adding binary-upload+ in qSupported. Following the incompatible implementation of the 'x' packet between lldb and gdb, gdb now only uses the x packet if the gdbserver reports binary-upload+ in qSupported. Tested with gdb 16.1, gdb 16 branch and gdb 17 trunk, each time checking the 'x' packet was effectively used. Diff: --- coregrind/m_gdbserver/server.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/coregrind/m_gdbserver/server.c b/coregrind/m_gdbserver/server.c index 939b7f2931..410ebf3bc3 100644 --- a/coregrind/m_gdbserver/server.c +++ b/coregrind/m_gdbserver/server.c @@ -1126,6 +1126,8 @@ void handle_query (char *arg_own_buf, int *new_packet_len_p) /* Note: max packet size including frame and checksum, but without trailing null byte, which is not sent/received. */ + strcat (arg_own_buf, ";binary-upload+"); + strcat (arg_own_buf, ";QStartNoAckMode+"); strcat (arg_own_buf, ";QPassSignals+"); strcat (arg_own_buf, ";QCatchSyscalls+"); |
From: Paul F. <pa...@so...> - 2025-01-28 07:51:47
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=f6118567bc49bd451e5b8232518a894a161f3532 commit f6118567bc49bd451e5b8232518a894a161f3532 Author: Paul Floyd <pj...@wa...> Date: Tue Jan 28 09:47:17 2025 +0100 FreeBSD regtest: update getrlimitusage Different system, diffeent number of allowed pseudo-terminals. So set it to 0. Diff: --- memcheck/tests/freebsd/getrlimitusage.c | 1 + 1 file changed, 1 insertion(+) diff --git a/memcheck/tests/freebsd/getrlimitusage.c b/memcheck/tests/freebsd/getrlimitusage.c index 2006de00da..b601dfdb58 100644 --- a/memcheck/tests/freebsd/getrlimitusage.c +++ b/memcheck/tests/freebsd/getrlimitusage.c @@ -86,6 +86,7 @@ int main(int argc, char *argv[]) { case 7: case 9: + case 11: case 12: case 13: case 14: |
From: Paul F. <pa...@so...> - 2025-01-28 07:46:15
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=13aef508bb5d84cf61940020a05e5f8e79ad7510 commit 13aef508bb5d84cf61940020a05e5f8e79ad7510 Author: Paul Floyd <pj...@wa...> Date: Tue Jan 28 09:44:24 2025 +0100 Bug 499212 - mmap() with MAP_ALIGNED() returns unaligned pointer Diff: --- .gitignore | 1 + NEWS | 1 + coregrind/m_syswrap/syswrap-generic.c | 11 ++++++++++- include/vki/vki-freebsd.h | 11 +++++++++-- none/tests/freebsd/Makefile.am | 7 +++++-- none/tests/freebsd/bug499212.c | 22 ++++++++++++++++++++++ none/tests/freebsd/bug499212.stderr.exp | 0 none/tests/freebsd/bug499212.stdout.exp | 1 + none/tests/freebsd/bug499212.vgtest | 2 ++ 9 files changed, 51 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 4a6874e5c1..483b077ca3 100644 --- a/.gitignore +++ b/.gitignore @@ -2255,6 +2255,7 @@ /none/tests/freebsd/auxv /none/tests/freebsd/bug452274 /none/tests/freebsd/bug498317 +none/tests/freebsd/bug499212 /none/tests/freebsd/osrel /none/tests/freebsd/swapcontext /none/tests/freebsd/fexecve diff --git a/NEWS b/NEWS index 22744917eb..f6f6e9d88f 100644 --- a/NEWS +++ b/NEWS @@ -49,6 +49,7 @@ are not entered into bugzilla tend to get forgotten about or ignored. even though it's generated by --gen-suppressions=yes 498143 False positive on EVIOCGRAB ioctl 498492 none/tests/amd64/lzcnt64 crashes on FreeBSD compiled with clang +499212 mmap() with MAP_ALIGNED() returns unaligned pointer To see details of a given bug, visit https://bugs.kde.org/show_bug.cgi?id=XXXXXX diff --git a/coregrind/m_syswrap/syswrap-generic.c b/coregrind/m_syswrap/syswrap-generic.c index c281021a9f..c3f916a1ed 100644 --- a/coregrind/m_syswrap/syswrap-generic.c +++ b/coregrind/m_syswrap/syswrap-generic.c @@ -2630,7 +2630,7 @@ ML_(generic_PRE_sys_mmap) ( ThreadId tid, if (arg4 & VKI_MAP_FIXED) { mreq.rkind = MFixed; } else -#if defined(VKI_MAP_ALIGN) /* Solaris specific */ +#if defined(VGO_solaris) && defined(VKI_MAP_ALIGN) if (arg4 & VKI_MAP_ALIGN) { mreq.rkind = MAlign; if (mreq.start == 0) { @@ -2639,6 +2639,15 @@ ML_(generic_PRE_sys_mmap) ( ThreadId tid, /* VKI_MAP_FIXED and VKI_MAP_ALIGN don't like each other. */ arg4 &= ~VKI_MAP_ALIGN; } else +#endif +#if defined(VGO_freebsd) + if (arg4 & VKI_MAP_ALIGNMENT_MASK) { + mreq.rkind = MAlign; + if (mreq.start == 0U) { + mreq.start = 1U << (arg4 >> VKI_MAP_ALIGNMENT_SHIFT); + } + arg4 &= ~VKI_MAP_ALIGNMENT_MASK; + } else #endif if (arg1 != 0) { mreq.rkind = MHint; diff --git a/include/vki/vki-freebsd.h b/include/vki/vki-freebsd.h index a49650b2bc..b870025f0f 100644 --- a/include/vki/vki-freebsd.h +++ b/include/vki/vki-freebsd.h @@ -1523,9 +1523,16 @@ typedef enum vki_idtype { #define VKI_MAP_PRIVATE 0x02 /* Changes are private */ #define VKI_MAP_FIXED 0x10 /* Interpret addr exactly */ #define VKI_MAP_NORESERVE 0x0040 /* don't check for reservations */ -#define VKI_MAP_STACK 0x400 +#define VKI_MAP_STACK 0x400 #define VKI_MAP_ANON 0x1000 /* don't use a file */ -#define VKI_MAP_ANONYMOUS VKI_MAP_ANON +#define VKI_MAP_ANONYMOUS VKI_MAP_ANON + +#define VKI_MAP_ALIGNED(n) ((n) << VKI_MAP_ALIGNMENT_SHIFT) +#define VKI_MAP_ALIGNMENT_SHIFT 24 +#define VKI_MAP_ALIGNMENT_MASK VKI_MAP_ALIGNED(0xff) +#define VKI_MAP_ALIGNED_SUPER VKI_MAP_ALIGNED(1) /* align on a superpage */ + + //---------------------------------------------------------------------- // From sys/stat.h diff --git a/none/tests/freebsd/Makefile.am b/none/tests/freebsd/Makefile.am index d4c2474bbc..d1f7759ec9 100644 --- a/none/tests/freebsd/Makefile.am +++ b/none/tests/freebsd/Makefile.am @@ -15,6 +15,9 @@ EXTRA_DIST = \ bug452274.stderr.exp \ bug498317.vgtest bug498317.stderr.exp \ bug498317.supp \ + bug499212.vgtest \ + bug499212.stderr.exp \ + bug499212.stdout.exp \ cp.vgtest \ cp.stderr.exp \ osrel.vgtest \ @@ -63,8 +66,8 @@ EXTRA_DIST = \ usrstack.stdout.exp check_PROGRAMS = \ - auxv bug498317 osrel swapcontext hello_world fexecve bug452274 \ - usrstack proc_pid_file sanity_level_thread umtx_shm_creat + auxv bug452274 bug498317 bug499212 fexecve hello_world osrel \ + proc_pid_file sanity_level_thread swapcontext umtx_shm_creat usrstack AM_CFLAGS += $(AM_FLAG_M3264_PRI) AM_CXXFLAGS += $(AM_FLAG_M3264_PRI) diff --git a/none/tests/freebsd/bug499212.c b/none/tests/freebsd/bug499212.c new file mode 100644 index 0000000000..d6a81ced4f --- /dev/null +++ b/none/tests/freebsd/bug499212.c @@ -0,0 +1,22 @@ +#include <assert.h> +#include <inttypes.h> +#include <stdio.h> +#include <stdlib.h> +#include <sys/mman.h> + +int main(int argc, char **argv) +{ + void *buf = + mmap(NULL, 1 << 20, PROT_WRITE | PROT_READ, MAP_PRIVATE | MAP_NOSYNC | MAP_ALIGNED(20) | MAP_ANON, -1, 0); + if (buf != MAP_FAILED) + { + assert(((uintptr_t)buf & 0xFFFFF) == 0); + if (((uintptr_t)buf & 0xFFFFF) != 0) + { + puts("Failure"); + return EXIT_FAILURE; + } + } + puts("Success"); + return EXIT_SUCCESS; +} diff --git a/none/tests/freebsd/bug499212.stderr.exp b/none/tests/freebsd/bug499212.stderr.exp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/none/tests/freebsd/bug499212.stdout.exp b/none/tests/freebsd/bug499212.stdout.exp new file mode 100644 index 0000000000..35821117c8 --- /dev/null +++ b/none/tests/freebsd/bug499212.stdout.exp @@ -0,0 +1 @@ +Success diff --git a/none/tests/freebsd/bug499212.vgtest b/none/tests/freebsd/bug499212.vgtest new file mode 100644 index 0000000000..1e546766f3 --- /dev/null +++ b/none/tests/freebsd/bug499212.vgtest @@ -0,0 +1,2 @@ +prog: bug499212 +vgopts: -q |
From: Paul F. <pa...@so...> - 2025-01-26 06:22:04
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=de365595060cf454056c166096a9e3ddaf14c8dd commit de365595060cf454056c166096a9e3ddaf14c8dd Author: Paul Floyd <pj...@wa...> Date: Sun Jan 26 07:21:08 2025 +0100 Darwin syscall: add wrapper for mkdirat Diff: --- coregrind/m_syswrap/priv_syswrap-darwin.h | 2 +- coregrind/m_syswrap/syswrap-darwin.c | 18 ++++++++++++++---- include/vki/vki-scnums-darwin.h | 1 + 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/coregrind/m_syswrap/priv_syswrap-darwin.h b/coregrind/m_syswrap/priv_syswrap-darwin.h index c0313fd7ca..4435f8b571 100644 --- a/coregrind/m_syswrap/priv_syswrap-darwin.h +++ b/coregrind/m_syswrap/priv_syswrap-darwin.h @@ -592,7 +592,7 @@ DECL_TEMPLATE(darwin, fstatat64); // 470 // NYI unlinkat // 472 DECL_TEMPLATE(darwin, readlinkat); // 473 // NYI symlinkat // 474 -// NYI mkdirat // 475 +DECL_TEMPLATE(darwin, mkdirat); // 475 // NYI getattrlistat // 476 // NYI proc_trace_log // 477 DECL_TEMPLATE(darwin, bsdthread_ctl); // 478 diff --git a/coregrind/m_syswrap/syswrap-darwin.c b/coregrind/m_syswrap/syswrap-darwin.c index 6b0f591495..8aaf8fc833 100644 --- a/coregrind/m_syswrap/syswrap-darwin.c +++ b/coregrind/m_syswrap/syswrap-darwin.c @@ -2339,7 +2339,7 @@ POST(__pthread_sigmask) PRE(__sigwait) { *flags |= SfMayBlock; - PRINT("sys_sigwait ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", + PRINT("__sigwait ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", ARG1,ARG2); PRE_REG_READ2(int, "sigwait", const vki_sigset_t *, set, int *, sig); @@ -3074,7 +3074,7 @@ PRE(mount) // We are conservative and check everything, except the memory pointed to // by 'data'. *flags |= SfMayBlock; - PRINT("sys_mount( %#lx(%s), %#lx(%s), %#lx, %#lx )", + PRINT("mount( %#lx(%s), %#lx(%s), %#lx, %#lx )", ARG1, (HChar*)ARG1, ARG2, (HChar*)ARG2, ARG3, ARG4); PRE_REG_READ4(long, "mount", const char *, type, const char *, dir, @@ -9979,13 +9979,13 @@ PRE(openat) { if (ARG3 & VKI_O_CREAT) { // 4-arg version - PRINT("sys_openat ( %ld, %#" FMT_REGWORD "x(%s), %ld, %ld )", + PRINT("openat ( %ld, %#" FMT_REGWORD "x(%s), %ld, %ld )", SARG1, ARG2, (HChar*)(Addr)ARG2, SARG3, SARG4); PRE_REG_READ4(long, "openat", int, dfd, const char *, filename, int, flags, int, mode); } else { // 3-arg version - PRINT("sys_openat ( %ld, %#" FMT_REGWORD "x(%s), %ld )", + PRINT("openat ( %ld, %#" FMT_REGWORD "x(%s), %ld )", SARG1, ARG2, (HChar*)(Addr)ARG2, SARG3); PRE_REG_READ3(long, "openat", int, dfd, const char *, filename, int, flags); @@ -10017,6 +10017,15 @@ POST(openat) } } +PRE(mkdirat) +{ + PRINT("mkdirat ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u )", ARG1,ARG2,(char*)ARG2,ARG3); + PRE_REG_READ3(int, "mkdirat", + int, fd, const char *, path, unsigned int, mode); + PRE_MEM_RASCIIZ( "mkdirat(path)", ARG2 ); + *flags |= SfMayBlock; +} + #endif /* DARWIN_VERS >= DARWIN_10_10 */ @@ -11085,6 +11094,7 @@ const SyscallTableEntry ML_(syscall_table)[] = { MACXY(__NR_necp_match_policy, necp_match_policy), // 460 MACXY(__NR_getattrlistbulk, getattrlistbulk), // 461 MACXY(__NR_openat, openat), // 463 + MACX_(__NR_mkdirat, mkdirat), // 475 #if DARWIN_VERS >= DARWIN_10_13 MACXY(__NR_openat_nocancel, openat_nocancel), // 464 #endif diff --git a/include/vki/vki-scnums-darwin.h b/include/vki/vki-scnums-darwin.h index 2abc8aea8b..8eee21ec44 100644 --- a/include/vki/vki-scnums-darwin.h +++ b/include/vki/vki-scnums-darwin.h @@ -776,6 +776,7 @@ #if DARWIN_VERS >= DARWIN_10_10 #define __NR_openat VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(463) +#define __NR_mkdirat VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(475) #if DARWIN_VERS >= DARWIN_10_13 #define __NR_openat_nocancel VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(464) #endif |
From: Paul F. <pa...@so...> - 2025-01-26 06:03:32
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=db2d0ad0821a5a50c7ea1202c185b5a47a89f9aa commit db2d0ad0821a5a50c7ea1202c185b5a47a89f9aa Author: Paul Floyd <pj...@wa...> Date: Sun Jan 26 07:02:22 2025 +0100 regtest: update mcsig[no]pass expecteds Line number change due to adding different signal type to faultstatus test for macOS. Diff: --- gdbserver_tests/mcsignopass.stderr.exp | 2 +- gdbserver_tests/mcsigpass.stderr.exp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gdbserver_tests/mcsignopass.stderr.exp b/gdbserver_tests/mcsignopass.stderr.exp index aa38ac9b61..acbb5f24bb 100644 --- a/gdbserver_tests/mcsignopass.stderr.exp +++ b/gdbserver_tests/mcsignopass.stderr.exp @@ -1,7 +1,7 @@ (action at startup) vgdb me ... Test 1: Invalid write of size 4 at 0x........: test1 (faultstatus.c:121) - by 0x........: main (faultstatus.c:184) + by 0x........: main (faultstatus.c:188) Address 0x........ is not stack'd, malloc'd or (recently) free'd PASS Test 2: PASS diff --git a/gdbserver_tests/mcsigpass.stderr.exp b/gdbserver_tests/mcsigpass.stderr.exp index e1ce143325..35619ae74d 100644 --- a/gdbserver_tests/mcsigpass.stderr.exp +++ b/gdbserver_tests/mcsigpass.stderr.exp @@ -1,7 +1,7 @@ (action at startup) vgdb me ... Test 1: Invalid write of size 4 at 0x........: test1 (faultstatus.c:121) - by 0x........: main (faultstatus.c:184) + by 0x........: main (faultstatus.c:188) Address 0x........ is not stack'd, malloc'd or (recently) free'd PASS Test 2: PASS |
From: Paul F. <pa...@so...> - 2025-01-25 20:24:21
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=a86f8168dc2545f9ceaa429d1df5afecb0f3a166 commit a86f8168dc2545f9ceaa429d1df5afecb0f3a166 Author: Paul Floyd <pj...@wa...> Date: Sat Jan 25 21:03:30 2025 +0100 regtest: slacken timing in none/tests/bug492678 again 5us was still a bit tight. 10us looks a lot more reliable. Diff: --- none/tests/bug492678.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/none/tests/bug492678.c b/none/tests/bug492678.c index c15037bcd5..8c3689fc3c 100644 --- a/none/tests/bug492678.c +++ b/none/tests/bug492678.c @@ -89,7 +89,7 @@ static void try_race_condition(void) ++tries; const struct timeval clk_period = { .tv_sec = 0, - .tv_usec = 5, + .tv_usec = 10, }; sigalrm_timer_setup(&clk_period); sigalrm_timer_destroy(); |
From: Paul F. <pa...@so...> - 2025-01-25 20:17:41
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=3db79fb9e5232349b4e35f8d366b45b013dd9649 commit 3db79fb9e5232349b4e35f8d366b45b013dd9649 Author: Paul Floyd <pj...@wa...> Date: Sat Jan 25 21:16:37 2025 +0100 Darwin regtest: update none faultstatus test Test 2 on Darwin generated SIGBUS not SIGSEGV. Diff: --- none/tests/faultstatus.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/none/tests/faultstatus.c b/none/tests/faultstatus.c index e04bad6081..9e262395bc 100644 --- a/none/tests/faultstatus.c +++ b/none/tests/faultstatus.c @@ -170,7 +170,11 @@ int main() const struct test tests[] = { #define T(n, sig, code, addr) { test##n, sig, code, addr } T(1, SIGSEGV, SEGV_MAPERR, BADADDR), +#if defined(VGO_darwin) + T(2, SIGBUS, SEGV_ACCERR, mapping), +#else T(2, SIGSEGV, SEGV_ACCERR, mapping), +#endif T(3, SIGBUS, BUS_ERROR_SI_CODE, &mapping[FILESIZE+10]), T(4, SIGFPE, DIVISION_BY_ZERO_SI_CODE, 0), #undef T |
From: Paul F. <pa...@so...> - 2025-01-25 19:12:27
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=b890b411bfa59a33e8fa0961fedb00ef7aa174d1 commit b890b411bfa59a33e8fa0961fedb00ef7aa174d1 Author: Paul Floyd <pj...@wa...> Date: Sat Jan 25 20:09:40 2025 +0100 regtest: slacken timing in none/tests/bug492678 With a 1us interval some systems intermittently (but quite frequently) hang. Increasing it to 5us seems to make it consistent. Will keep an eye on this one. Diff: --- none/tests/bug492678.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/none/tests/bug492678.c b/none/tests/bug492678.c index 6e4ca80f4d..c15037bcd5 100644 --- a/none/tests/bug492678.c +++ b/none/tests/bug492678.c @@ -89,7 +89,7 @@ static void try_race_condition(void) ++tries; const struct timeval clk_period = { .tv_sec = 0, - .tv_usec = 1, + .tv_usec = 5, }; sigalrm_timer_setup(&clk_period); sigalrm_timer_destroy(); |
From: Paul F. <pa...@so...> - 2025-01-25 18:56:39
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=961743a71c102aa1e9d2648844b596f9e084d439 commit 961743a71c102aa1e9d2648844b596f9e084d439 Author: Paul Floyd <pj...@wa...> Date: Sat Jan 25 19:55:49 2025 +0100 regtest: get the configure.ac check for timer_delete correct Diff: --- configure.ac | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 2a95597aae..9dec9f3b00 100755 --- a/configure.ac +++ b/configure.ac @@ -4956,7 +4956,8 @@ AC_CHECK_FUNCS([ \ sem_clockwait_np \ fdatasync \ getrandom \ - getrlimitusage + getrlimitusage \ + timer_delete ]) # AC_CHECK_LIB adds any library found to the variable LIBS, and links these |
From: Paul F. <pa...@so...> - 2025-01-25 18:24:59
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=8eda2ae3e7dba6f0d94c3cbfc12821f2cff40018 commit 8eda2ae3e7dba6f0d94c3cbfc12821f2cff40018 Author: Paul Floyd <pj...@wa...> Date: Sat Jan 25 19:24:00 2025 +0100 regtest macOS: macOS has no timer fds, so not timer_create etc. Add a feature test for timer_delete. Diff: --- configure.ac | 3 +++ none/tests/Makefile.am | 9 +++++++-- none/tests/timer_delete.vgtest | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index c595de28b0..2a95597aae 100755 --- a/configure.ac +++ b/configure.ac @@ -4892,6 +4892,7 @@ AC_FUNC_MMAP AC_CHECK_LIB([pthread], [pthread_create]) AC_CHECK_LIB([rt], [clock_gettime]) +AC_CHECK_LIB([rt], [timer_delete]) AC_CHECK_FUNCS([ \ aligned_alloc \ @@ -5011,6 +5012,8 @@ AM_CONDITIONAL([HAVE_GETRANDOM], [test x$ac_cv_func_getrandom = xyes]) AM_CONDITIONAL([HAVE_GETRLIMITUSAGE], [test x$ac_cv_func_getrlimitusage = xyes]) +AM_CONDITIONAL([HAVE_TIMER_DELETE], + [test x$ac_cv_func_timer_delete = xyes]) if test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \ -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \ diff --git a/none/tests/Makefile.am b/none/tests/Makefile.am index 2fa43587e2..7ceb0052b4 100644 --- a/none/tests/Makefile.am +++ b/none/tests/Makefile.am @@ -302,7 +302,6 @@ check_PROGRAMS = \ thread-exits \ threaded-fork \ threadederrno \ - timer_delete \ timestamp \ tls \ tls.so \ @@ -359,6 +358,10 @@ if BUILD_IFUNC_TESTS check_PROGRAMS += ifunc endif +if HAVE_TIMER_DELETE + check_PROGRAMS += timer_delete +endif + AM_CFLAGS += $(AM_FLAG_M3264_PRI) AM_CXXFLAGS += $(AM_FLAG_M3264_PRI) @@ -442,7 +445,9 @@ thread_exits_LDADD = -lpthread threaded_fork_LDADD = -lpthread threadederrno_CFLAGS = $(AM_CFLAGS) threadederrno_LDADD = -lpthread -timer_delete_LDADD = -lrt +if HAVE_TIMER_DELETE + timer_delete_LDADD = -lrt +endif timestamp_CFLAGS = ${AM_CFLAGS} @FLAG_W_NO_USE_AFTER_FREE@ tls_SOURCES = tls.c tls2.c tls_DEPENDENCIES = tls.so tls2.so diff --git a/none/tests/timer_delete.vgtest b/none/tests/timer_delete.vgtest index 389293a690..b12d4c6ff1 100644 --- a/none/tests/timer_delete.vgtest +++ b/none/tests/timer_delete.vgtest @@ -1,3 +1,4 @@ +prereq: test -e timer_delete prog: timer_delete vgopts: -q |
From: Pol M. S. <pol...@gm...> - 2025-01-25 17:14:58
|
Hi, in an application I develop, compilers tend to emit from time to time SSE4a instructions as I target AMD CPUs. I filed a bug (486398) a while ago, but given that I faced this same issue recently, I guessed that there simply hadn't been bandwidth for a more than a decade old niche set of instructions. Given that I still need them, and that there are only 4 instructions, I have already added support for the INSERTQ and EXTRQ into VEX, and I intend to finish the job by implementing MOVNTSD & MOVNTSS. Looking at the documentation, it seems to assume that you need to have write access into the repo to publish code, so I'd like to request some assistance regarding the logistics of submitting a patch (or, if possible, creating a pull request). The documentation also mentions that I should use clang-format, but after applying the formatting all the code changed, making a diff completely unreadable. May I know if this is expected? Maybe VEX has been touched on less, and hasn't had its formatting updated yet? Did I configure something wrong? I'm certain that I'll have gotten some subtleties of Valgrind wrong, so once I do submit a patch, please, review it thoroughly! :D Regards, Pol Marcet Sardà |
From: Paul F. <pa...@so...> - 2025-01-25 16:58:02
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=db16c3a503fb9a1d12910b5c65322213f8d9c71c commit db16c3a503fb9a1d12910b5c65322213f8d9c71c Author: Paul Floyd <pj...@wa...> Date: Sat Jan 25 17:57:35 2025 +0100 Bug 492678 - forgot to add vgtest file Diff: --- none/tests/timer_delete.vgtest | 3 +++ 1 file changed, 3 insertions(+) diff --git a/none/tests/timer_delete.vgtest b/none/tests/timer_delete.vgtest new file mode 100644 index 0000000000..389293a690 --- /dev/null +++ b/none/tests/timer_delete.vgtest @@ -0,0 +1,3 @@ +prog: timer_delete +vgopts: -q + |
From: Paul F. <pa...@so...> - 2025-01-25 16:55:37
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=3a1498f13f1676a20ab80fc553fd4f6b94b3a347 commit 3a1498f13f1676a20ab80fc553fd4f6b94b3a347 Author: Paul Floyd <pj...@wa...> Date: Sat Jan 25 14:54:08 2025 +0100 Bug 492678 - SIGALRM race condition (sighandler called after timer disarmed Diff: --- .gitignore | 2 + coregrind/m_syswrap/syswrap-freebsd.c | 1 + coregrind/m_syswrap/syswrap-generic.c | 8 +++ coregrind/m_syswrap/syswrap-linux.c | 1 + coregrind/m_syswrap/syswrap-solaris.c | 1 + none/tests/Makefile.am | 6 +- none/tests/bug492678.c | 104 ++++++++++++++++++++++++++++++++++ none/tests/bug492678.stderr.exp | 0 none/tests/bug492678.vgtest | 3 + none/tests/timer_delete.c | 102 +++++++++++++++++++++++++++++++++ none/tests/timer_delete.stderr.exp | 0 11 files changed, 227 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index d44246b8bc..4a6874e5c1 100644 --- a/.gitignore +++ b/.gitignore @@ -1534,6 +1534,7 @@ /none/tests/bug129866 /none/tests/bug234814 /none/tests/bug491394 +/none/tests/bug492678 /none/tests/closeall /none/tests/coolo_sigaction /none/tests/coolo_strlen @@ -1645,6 +1646,7 @@ /none/tests/thread-exits /none/tests/threaded-fork /none/tests/threadederrno +/none/tests/timer_delete /none/tests/timestamp /none/tests/tls /none/tests/track-fds-exec-children diff --git a/coregrind/m_syswrap/syswrap-freebsd.c b/coregrind/m_syswrap/syswrap-freebsd.c index d358c90eb0..3397249383 100644 --- a/coregrind/m_syswrap/syswrap-freebsd.c +++ b/coregrind/m_syswrap/syswrap-freebsd.c @@ -2411,6 +2411,7 @@ PRE(sys_timer_delete) { PRINT("sys_timer_delete( %#" FMT_REGWORD "x )", ARG1); PRE_REG_READ1(long, "timer_delete", vki_timer_t, timerid); + *flags |= SfPollAfter; } // SYS_ktimer_settime 237 diff --git a/coregrind/m_syswrap/syswrap-generic.c b/coregrind/m_syswrap/syswrap-generic.c index a74b8f1d21..c281021a9f 100644 --- a/coregrind/m_syswrap/syswrap-generic.c +++ b/coregrind/m_syswrap/syswrap-generic.c @@ -2959,6 +2959,14 @@ PRE(sys_setitimer) &(value->it_interval)); PRE_timeval_READ( "setitimer(&value->it_value)", &(value->it_value)); + // "Setting it_value to 0 disables a timer" + // poll for signals in that case + if (ML_(safe_to_deref)(value, sizeof(*value))) { + if (value->it_value.tv_sec == 0 && + value->it_value.tv_usec == 0) { + *flags |= SfPollAfter; + } + } } if (ARG3 != (Addr)NULL) { struct vki_itimerval *ovalue = (struct vki_itimerval*)(Addr)ARG3; diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c index e8978b5bc1..83af91344e 100644 --- a/coregrind/m_syswrap/syswrap-linux.c +++ b/coregrind/m_syswrap/syswrap-linux.c @@ -3244,6 +3244,7 @@ PRE(sys_timer_delete) { PRINT("sys_timer_delete( %#" FMT_REGWORD "x )", ARG1); PRE_REG_READ1(long, "timer_delete", vki_timer_t, timerid); + *flags |= SfPollAfter; } /* --------------------------------------------------------------------- diff --git a/coregrind/m_syswrap/syswrap-solaris.c b/coregrind/m_syswrap/syswrap-solaris.c index 104a809d3d..9abeb85001 100644 --- a/coregrind/m_syswrap/syswrap-solaris.c +++ b/coregrind/m_syswrap/syswrap-solaris.c @@ -8531,6 +8531,7 @@ PRE(sys_timer_delete) /* int timer_delete(timer_t timerid); */ PRINT("sys_timer_delete ( %ld )", SARG1); PRE_REG_READ1(long, "timer_delete", vki_timer_t, timerid); + *flags |= SfPollAfter; } PRE(sys_timer_settime) diff --git a/none/tests/Makefile.am b/none/tests/Makefile.am index 3dc8762514..2fa43587e2 100644 --- a/none/tests/Makefile.am +++ b/none/tests/Makefile.am @@ -103,6 +103,7 @@ EXTRA_DIST = \ bug129866.vgtest bug129866.stderr.exp bug129866.stdout.exp \ bug234814.vgtest bug234814.stderr.exp bug234814.stdout.exp \ bug491394.vgtest bug491394.stderr.exp \ + bug492678.vgtest bug492678.stderr.exp \ closeall.stderr.exp closeall.vgtest \ cmdline0.stderr.exp cmdline0.stdout.exp cmdline0.vgtest \ cmdline1.stderr.exp cmdline1.stdout.exp cmdline1.vgtest \ @@ -241,6 +242,7 @@ EXTRA_DIST = \ threaded-fork.stderr.exp threaded-fork.stdout.exp threaded-fork.vgtest \ threadederrno.stderr.exp threadederrno.stdout.exp \ threadederrno.vgtest \ + timer_delete.vgtest timer_delete.stderr.exp \ timestamp.stderr.exp timestamp.vgtest \ tls.vgtest tls.stderr.exp tls.stdout.exp \ track-fds-exec-children.vgtest track-fds-exec-children.stderr.exp \ @@ -267,7 +269,7 @@ check_PROGRAMS = \ args \ async-sigs \ bitfield1 \ - bug129866 bug234814 \ + bug129866 bug234814 bug492678\ closeall coolo_strlen \ discard exec-sigmask execve faultstatus fcntl_setown \ fdleak_cmsg fdleak_creat fdleak_dup fdleak_dup2 \ @@ -300,6 +302,7 @@ check_PROGRAMS = \ thread-exits \ threaded-fork \ threadederrno \ + timer_delete \ timestamp \ tls \ tls.so \ @@ -439,6 +442,7 @@ thread_exits_LDADD = -lpthread threaded_fork_LDADD = -lpthread threadederrno_CFLAGS = $(AM_CFLAGS) threadederrno_LDADD = -lpthread +timer_delete_LDADD = -lrt timestamp_CFLAGS = ${AM_CFLAGS} @FLAG_W_NO_USE_AFTER_FREE@ tls_SOURCES = tls.c tls2.c tls_DEPENDENCIES = tls.so tls2.so diff --git a/none/tests/bug492678.c b/none/tests/bug492678.c new file mode 100644 index 0000000000..6e4ca80f4d --- /dev/null +++ b/none/tests/bug492678.c @@ -0,0 +1,104 @@ +#include <errno.h> +#include <signal.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/time.h> + +#define CHECK_RES(res) \ + if (res == -1) \ + { \ + fprintf(stderr, "unexpected error at line %d: %s", __LINE__, strerror(errno)); \ + exit(EXIT_FAILURE); \ + } + +static int tries = 0; + +static void sigalrm_handler(int signum) +{ + (void)signum; + // no need to do anything for the experiment +} + +// using this handler in place of SIG_DFL to monitor when the "default" handler is called +static void sigalrm_default_handler(int signum) +{ + (void)signum; + fprintf(stderr, + "ERROR: unreachable code reached: sigalarm timer was disarmed, but still received SIGALRM (race condition " + "tried %d times)\n", + tries); + exit(EXIT_FAILURE); +} + +void sigalrm_timer_destroy(void) +{ + int res; + + // REMOVE TIMER + const struct itimerval zero = { + .it_interval = + { + .tv_sec = 0, + .tv_usec = 0, + }, + .it_value = + { + .tv_sec = 0, + .tv_usec = 0, + }, + }; + res = setitimer(ITIMER_REAL, &zero, NULL); + CHECK_RES(res) + + // AND THEN REMOVE SIGNAL HANDLER + struct sigaction sigact; + sigact.sa_flags = 0; + sigact.sa_handler = sigalrm_default_handler; // using this handler in place of SIG_DFL to monitor when the "default" + // handler is called + res = sigemptyset(&sigact.sa_mask); + CHECK_RES(res) + res = sigaction(SIGALRM, &sigact, NULL); + CHECK_RES(res) +} + +void sigalrm_timer_setup(const struct timeval *period) +{ + int res; + + // SIGNAL + struct sigaction sigact; + sigact.sa_flags = 0; + sigact.sa_handler = sigalrm_handler; + res = sigemptyset(&sigact.sa_mask); + CHECK_RES(res) + res = sigaction(SIGALRM, &sigact, NULL); + CHECK_RES(res) + + // TIMER + const struct itimerval timer_val = { + .it_interval = *period, + .it_value = *period, + }; + res = setitimer(ITIMER_REAL, &timer_val, NULL); + CHECK_RES(res); +} + +static void try_race_condition(void) +{ + ++tries; + const struct timeval clk_period = { + .tv_sec = 0, + .tv_usec = 1, + }; + sigalrm_timer_setup(&clk_period); + sigalrm_timer_destroy(); +} + +int main(void) +{ + for (int i = 0; i < 10000; ++i) + { + try_race_condition(); + } +} diff --git a/none/tests/bug492678.stderr.exp b/none/tests/bug492678.stderr.exp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/none/tests/bug492678.vgtest b/none/tests/bug492678.vgtest new file mode 100644 index 0000000000..39ff27650a --- /dev/null +++ b/none/tests/bug492678.vgtest @@ -0,0 +1,3 @@ +prog: bug492678 +vgopts: -q + diff --git a/none/tests/timer_delete.c b/none/tests/timer_delete.c new file mode 100644 index 0000000000..4a103d8f88 --- /dev/null +++ b/none/tests/timer_delete.c @@ -0,0 +1,102 @@ +#include <errno.h> +#include <signal.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> + +timer_t timerid; + +#define CHECK_RES(res) \ + if (res == -1) \ + { \ + fprintf(stderr, "unexpected error at line %d: %s", __LINE__, strerror(errno)); \ + exit(EXIT_FAILURE); \ + } + +static int tries = 0; + +static void sigalrm_handler(int signum) +{ + (void)signum; + // no need to do anything for the experiment +} + +// using this handler in place of SIG_DFL to monitor when the "default" handler is called +static void sigalrm_default_handler(int signum) +{ + (void)signum; + fprintf(stderr, + "ERROR: unreachable code reached: sigalarm timer was disarmed, but still received SIGALRM (race condition " + "tried %d times)\n", + tries); + exit(EXIT_FAILURE); +} + +void sigalrm_timer_destroy(void) +{ + int res; + + // REMOVE TIMER + res = timer_delete(timerid); + CHECK_RES(res) + + // AND THEN REMOVE SIGNAL HANDLER + struct sigaction sigact; + sigact.sa_flags = 0; + sigact.sa_handler = sigalrm_default_handler; // using this handler in place of SIG_DFL to monitor when the "default" + // handler is called + res = sigemptyset(&sigact.sa_mask); + CHECK_RES(res) + res = sigaction(SIGALRM, &sigact, NULL); + CHECK_RES(res) +} + +void sigalrm_timer_setup(const struct timespec *period) +{ + int res; + + // SIGNAL + struct sigaction sigact; + sigact.sa_flags = 0; + sigact.sa_handler = sigalrm_handler; + res = sigemptyset(&sigact.sa_mask); + CHECK_RES(res) + res = sigaction(SIGALRM, &sigact, NULL); + CHECK_RES(res) + + // SIGEVENT + struct sigevent sev; + sev.sigev_notify = SIGEV_SIGNAL; + sev.sigev_signo = SIGALRM; + sev.sigev_value.sival_ptr = &timerid; + res = timer_create(CLOCK_REALTIME, &sev, &timerid); + CHECK_RES(res); + + // TIMER + const struct itimerspec timer_val = { + .it_interval = *period, + .it_value = *period, + }; + res = timer_settime(timerid, 0, &timer_val, NULL); + CHECK_RES(res); +} + +static void try_race_condition(void) +{ + ++tries; + const struct timespec clk_period = { + .tv_sec = 0, + .tv_nsec = 20000 + }; + sigalrm_timer_setup(&clk_period); + sigalrm_timer_destroy(); +} + +int main(void) +{ + for (int i = 0; i < 10000; ++i) + { + try_race_condition(); + } +} diff --git a/none/tests/timer_delete.stderr.exp b/none/tests/timer_delete.stderr.exp new file mode 100644 index 0000000000..e69de29bb2 |
From: Mark W. <ma...@so...> - 2025-01-23 22:31:09
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=4dfe5df548d9f70691c9128a0f5f94a1034f591f commit 4dfe5df548d9f70691c9128a0f5f94a1034f591f Author: Mark Wielaard <ma...@kl...> Date: Thu Jan 23 23:29:19 2025 +0100 none/tests/fdleak_cmsg_supp.supp: Add suppressions for older glibc glibc 2.17 used __accept_nocancel and __recvmsg_nocancel as function names for accept and recvmsg. Diff: --- none/tests/fdleak_cmsg_supp.supp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/none/tests/fdleak_cmsg_supp.supp b/none/tests/fdleak_cmsg_supp.supp index a169fd888b..95f0a31de6 100644 --- a/none/tests/fdleak_cmsg_supp.supp +++ b/none/tests/fdleak_cmsg_supp.supp @@ -5,6 +5,13 @@ fun:server fun:main } +{ + sup1-old-glibc + CoreError:FdNotClosed + fun:__accept_nocancel + fun:server + fun:main +} { sup2 CoreError:FdNotClosed @@ -34,6 +41,13 @@ fun:client fun:main } +{ + sup4-old-glibc + CoreError:FdNotClosed + fun:__recvmsg_nocancel + fun:client + fun:main +} { sup5 CoreError:FdNotClosed |
From: Mark W. <ma...@so...> - 2025-01-23 22:03:52
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=fd1608c55b5f1d466536e635ce6805a022a2f8c0 commit fd1608c55b5f1d466536e635ce6805a022a2f8c0 Author: Mark Wielaard <ma...@kl...> Date: Thu Jan 23 22:59:42 2025 +0100 memcheck/tests/amd64/rh2257546_256.c: use xmm instead of ymm in clobbers Older gcc (4.8.5) doesn't recognize yym registers as clobbers. Use xmm instead, as in the AVX configure checks, which are the same register (half) just with a different name. Diff: --- memcheck/tests/amd64/rh2257546_256.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/memcheck/tests/amd64/rh2257546_256.c b/memcheck/tests/amd64/rh2257546_256.c index 4b522c7e46..9f5775cd07 100644 --- a/memcheck/tests/amd64/rh2257546_256.c +++ b/memcheck/tests/amd64/rh2257546_256.c @@ -28,7 +28,7 @@ int main ( void ) "zzz1f:" "\n\t" "mov $88, %0" "\n" "zzzafter:" "\n\t" - : /*OUT*/"=r"(res) : /*IN*/"r"(c1),"r"(c2) : /*TRASH*/"ymm4","ymm5","cc" + : /*OUT*/"=r"(res) : /*IN*/"r"(c1),"r"(c2) : /*TRASH*/"xmm4","xmm5","cc" ); printf("res = %lld\n", res); free(c1); |
From: Mark W. <ma...@kl...> - 2025-01-23 18:49:25
|
Hi, On Thu, 2025-01-16 at 18:05 +0100, Andreas Arnez via Valgrind- developers wrote: > On Wed, Jan 08 2025, Florian Krohm wrote: > > On 08.01.25 06:55, Paul Floyd via Valgrind-developers wrote: > > > I'm all for it. Does the oldest GCC used for the nightlies and buildbot > > > support C11? > > > > We could check this in and see what happens. > > A word from the platform maintainers would be good, too. > > I'm fine with this. Does anybody else have an issue? Otherwise I > suggest to make the change if nobody complains within a week or so. > I made the change just now in: commit 42eb19c0da3bb280de88b7f8fc9b7caaa44aedfe Author: Mark Wielaard <ma...@kl...> Date: Thu Jan 23 19:33:57 2025 +0100 Check for and compile using -std=gnu11 (or higher) Use gnulib m4/std-gnu11.m4 for that. Also update the minimum autoconf version to 2.69. And the minimum automake to 1.13. This lets us clean up configure.ac a little. We would really like 2.70+ so we don't need the gnulib gnu11.m4. But 2.69 still seems in use on various stable systems. autoconf 2.70 was released end of 2020, autoconf 2.69 in 2012. As you can see it was a bit more work than anticipated. The buildbots and nightly builders run ./autogen.sh themselves, so we still need to support some older autoconf and automake versions. Sadly that means we have to ship the actual test for c11 support ourselves (stolen from gnulib). I tested against a rhel7 era setup with gcc 4.8.5, automake 1.13.4 and autoconf 2.69. I do have one followup fixlet/workaround for at least one amd64 avx testcase. Which already didn't compile. So it seems people aren't really testing on such old systems already anymore. Please yell and scream if this doesn't work on your setup and/or if you see a buildbot or nightly builder fail because of this change. Cheers, Mark |
From: Mark W. <ma...@so...> - 2025-01-23 18:38:58
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=42eb19c0da3bb280de88b7f8fc9b7caaa44aedfe commit 42eb19c0da3bb280de88b7f8fc9b7caaa44aedfe Author: Mark Wielaard <ma...@kl...> Date: Thu Jan 23 19:33:57 2025 +0100 Check for and compile using -std=gnu11 (or higher) Use gnulib m4/std-gnu11.m4 for that. Also update the minimum autoconf version to 2.69. And the minimum automake to 1.13. This lets us clean up configure.ac a little. We would really like 2.70+ so we don't need the gnulib gnu11.m4. But 2.69 still seems in use on various stable systems. autoconf 2.70 was released end of 2020, autoconf 2.69 in 2012. Diff: --- Makefile.am | 7 +- autogen.sh | 2 +- configure.ac | 61 +-- m4/std-gnu11.m4 | 845 +++++++++++++++++++++++++++++++++++++++ tests/check_headers_and_includes | 1 + 5 files changed, 864 insertions(+), 52 deletions(-) diff --git a/Makefile.am b/Makefile.am index b3e5be5f46..d745e26bf4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,7 @@ -AUTOMAKE_OPTIONS = 1.10 +AUTOMAKE_OPTIONS = 1.13 + +ACLOCAL_AMFLAGS = -I m4 include $(top_srcdir)/Makefile.all.am @@ -122,7 +124,8 @@ EXTRA_DIST = \ valgrind.pc.in \ valgrind.spec.in \ valgrind.spec \ - autogen.sh + autogen.sh \ + m4 dist-hook: include/vgversion.h cp -p include/vgversion.h $(distdir)/include/vgversion_dist.h diff --git a/autogen.sh b/autogen.sh index 611bb14618..5de086b1a0 100755 --- a/autogen.sh +++ b/autogen.sh @@ -11,7 +11,7 @@ run () fi } -run aclocal +run aclocal -I m4 run autoheader run automake -a run autoconf diff --git a/configure.ac b/configure.ac index cb1dc69d35..c595de28b0 100755 --- a/configure.ac +++ b/configure.ac @@ -8,7 +8,9 @@ ##------------------------------------------------------------## # Process this file with autoconf to produce a configure script. -# +# We would like to have at least autoconf 2.69 +AC_PREREQ(2.69) + # Define major, minor, micro and suffix here once, then reuse them # for version number in valgrind.h and vg-entities (documentation). # suffix must be empty for a release, otherwise it is GIT or RC1, etc. @@ -50,26 +52,15 @@ CXXFLAGS="$CXXFLAGS" #---------------------------------------------------------------------------- AC_PROG_LN_S -m4_version_prereq([2.70], [AC_PROG_CC], [AC_PROG_CC_C99]) -# Make sure we can compile in C99 mode. -if test "$ac_cv_prog_cc_c99" = "no"; then - AC_MSG_ERROR([Valgrind relies on a C compiler supporting C99]) -fi + +# Provided by gnulib's m4/std-gnu11.m4 for autoconf pre 2.70 +# Make sure we can compile in C11 mode. +AC_PROG_CC +AS_IF([test "x$ac_cv_prog_cc_c11" = "xno"], + [AC_MSG_ERROR([Valgrind relies on a C compiler supporting C11])]) + AC_PROG_CPP AC_PROG_CXX -# AC_PROG_OBJC apparently causes problems on older Linux distros (eg. with -# autoconf 2.59). If we ever have any Objective-C code in the Valgrind code -# base (eg. most likely as Darwin-specific tests) we'll need one of the -# following: -# - put AC_PROG_OBJC in a Darwin-specific part of this file -# - Use AC_PROG_OBJC here and up the minimum autoconf version -# - Use the following, which is apparently equivalent: -# m4_ifdef([AC_PROG_OBJC], -# [AC_PROG_OBJC], -# [AC_CHECK_TOOL([OBJC], [gcc]) -# AC_SUBST([OBJC]) -# AC_SUBST([OBJCFLAGS]) -# ]) AC_PROG_RANLIB # Set LTO_RANLIB variable to an lto enabled ranlib if test "x$LTO_RANLIB" = "x"; then @@ -77,12 +68,6 @@ if test "x$LTO_RANLIB" = "x"; then fi AC_ARG_VAR([LTO_RANLIB],[Library indexer command for link time optimisation]) -# provide a very basic definition for AC_PROG_SED if it's not provided by -# autoconf (as e.g. in autoconf 2.59). -m4_ifndef([AC_PROG_SED], - [AC_DEFUN([AC_PROG_SED], - [AC_ARG_VAR([SED]) - AC_CHECK_PROGS([SED],[gsed sed])])]) AC_PROG_SED AC_DEFUN([AC_PROG_SHA256SUM], @@ -110,16 +95,8 @@ AC_PATH_PROG(PERL, perl) AC_PATH_PROG(GDB, gdb, "/no/gdb/was/found/at/configure/time") AC_DEFINE_UNQUOTED(GDB_PATH, "$GDB", [path to GDB]) -# some older automake's don't have it so try something on our own -ifdef([AM_PROG_AS],[AM_PROG_AS], -[ -AS="${CC}" -AC_SUBST(AS) - -ASFLAGS="" -AC_SUBST(ASFLAGS) -]) - +# figure out how to compile assembler sources +AM_PROG_AS # Check if 'diff' supports -u (universal diffs) and use it if possible. @@ -1077,20 +1054,6 @@ AM_CONDITIONAL(VGCONF_OS_IS_DARWIN_OR_FREEBSD, AM_CONDITIONAL(VGCONF_HAVE_PLATFORM_SEC, test x$VGCONF_PLATFORM_SEC_CAPS != x) -dnl automake-1.10 does not have AM_COND_IF (added in 1.11), so we supply a -dnl fallback definition -dnl The macro is courtesy of Dave Hart: -dnl https://lists.gnu.org/archive/html/automake/2010-12/msg00045.html -m4_ifndef([AM_COND_IF], [AC_DEFUN([AM_COND_IF], [ -if test -z "$$1_TRUE"; then : - m4_n([$2])[]dnl -m4_ifval([$3], -[else - $3 -])dnl -fi[]dnl -])]) - #---------------------------------------------------------------------------- # Inner Valgrind? #---------------------------------------------------------------------------- diff --git a/m4/std-gnu11.m4 b/m4/std-gnu11.m4 new file mode 100644 index 0000000000..d61d694297 --- /dev/null +++ b/m4/std-gnu11.m4 @@ -0,0 +1,845 @@ +# std-gnu11.m4 +# serial 3 + +# Prefer GNU C11 and C++11 to earlier versions. -*- coding: utf-8 -*- + +# The std-gnu23 module, which defines _AC_C_C23_OPTIONS, supersedes us. +m4_ifndef([_AC_C_C23_OPTIONS], [ + +# This implementation is taken from GNU Autoconf lib/autoconf/c.m4 +# commit 017d5ddd82854911f0119691d91ea8a1438824d6 +# dated Sun Apr 3 13:57:17 2016 -0700 +# with minor changes to commentary. +# This implementation will be obsolete once we can assume Autoconf 2.70 +# or later is installed everywhere a Gnulib program might be developed. + +m4_version_prereq([2.70], [], [ + + +# Copyright (C) 2001-2024 Free Software Foundation, Inc. + +# This file is part of Autoconf. This program is free +# software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# Under Section 7 of GPL version 3, you are granted additional +# permissions described in the Autoconf Configure Script Exception, +# version 3.0, as published by the Free Software Foundation. +# +# You should have received a copy of the GNU General Public License +# and a copy of the Autoconf Configure Script Exception along with +# this program; see the files COPYINGv3 and COPYING.EXCEPTION +# respectively. If not, see <https://www.gnu.org/licenses/> and +# <https://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=blob_plain;f=COPYING.EXCEPTION>. + +# Written by David MacKenzie, with help from +# Akim Demaille, Paul Eggert, +# François Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor, +# Roland McGrath, Noah Friedman, david d zuhn, and many others. + + +# AC_PROG_CC([COMPILER ...]) +# -------------------------- +# COMPILER ... is a space separated list of C compilers to search for. +# This just gives the user an opportunity to specify an alternative +# search list for the C compiler. +AC_DEFUN([AC_PROG_CC], +[AC_LANG_PUSH(C)dnl +AC_ARG_VAR([CC], [C compiler command])dnl +AC_ARG_VAR([CFLAGS], [C compiler flags])dnl +_AC_ARG_VAR_LDFLAGS()dnl +_AC_ARG_VAR_LIBS()dnl +_AC_ARG_VAR_CPPFLAGS()dnl +m4_ifval([$1], + [AC_CHECK_TOOLS(CC, [$1])], +[AC_CHECK_TOOL(CC, gcc) +if test -z "$CC"; then + dnl Here we want: + dnl AC_CHECK_TOOL(CC, cc) + dnl but without the check for a tool without the prefix. + dnl Until the check is removed from there, copy the code: + if test -n "$ac_tool_prefix"; then + AC_CHECK_PROG(CC, [${ac_tool_prefix}cc], [${ac_tool_prefix}cc]) + fi +fi +if test -z "$CC"; then + AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc) +fi +if test -z "$CC"; then + AC_CHECK_TOOLS(CC, cl.exe) +fi +if test -z "$CC"; then + AC_CHECK_TOOL(CC, clang) +fi +]) + +test -z "$CC" && AC_MSG_FAILURE([no acceptable C compiler found in \$PATH]) + +# Provide some information about the compiler. +_AS_ECHO_LOG([checking for _AC_LANG compiler version]) +set X $ac_compile +ac_compiler=$[2] +for ac_option in --version -v -V -qversion -version; do + _AC_DO_LIMIT([$ac_compiler $ac_option >&AS_MESSAGE_LOG_FD]) +done + +m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl +m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl +_AC_LANG_COMPILER_GNU +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi +_AC_PROG_CC_G +dnl +dnl Set ac_prog_cc_stdc to the supported C version. +dnl Also set the documented variable ac_cv_prog_cc_stdc; +dnl its name was chosen when it was cached, but it is no longer cached. +_AC_PROG_CC_C11([ac_prog_cc_stdc=c11 + ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c11], + [_AC_PROG_CC_C99([ac_prog_cc_stdc=c99 + ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99], + [_AC_PROG_CC_C89([ac_prog_cc_stdc=c89 + ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89], + [ac_prog_cc_stdc=no + ac_cv_prog_cc_stdc=no])])]) +dnl +AC_LANG_POP(C)dnl +])# AC_PROG_CC + + + +# AC_PROG_CXX([LIST-OF-COMPILERS]) +# -------------------------------- +# LIST-OF-COMPILERS is a space separated list of C++ compilers to search +# for (if not specified, a default list is used). This just gives the +# user an opportunity to specify an alternative search list for the C++ +# compiler. +# aCC HP-UX C++ compiler much better than `CC', so test before. +# FCC Fujitsu C++ compiler +# KCC KAI C++ compiler +# RCC Rational C++ +# xlC_r AIX C Set++ (with support for reentrant code) +# xlC AIX C Set++ +AC_DEFUN([AC_PROG_CXX], +[AC_LANG_PUSH(C++)dnl +AC_ARG_VAR([CXX], [C++ compiler command])dnl +AC_ARG_VAR([CXXFLAGS], [C++ compiler flags])dnl +_AC_ARG_VAR_LDFLAGS()dnl +_AC_ARG_VAR_LIBS()dnl +_AC_ARG_VAR_CPPFLAGS()dnl +_AC_ARG_VAR_PRECIOUS([CCC])dnl +if test -z "$CXX"; then + if test -n "$CCC"; then + CXX=$CCC + else + AC_CHECK_TOOLS(CXX, + [m4_default([$1], + [g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC clang++])], + g++) + fi +fi +# Provide some information about the compiler. +_AS_ECHO_LOG([checking for _AC_LANG compiler version]) +set X $ac_compile +ac_compiler=$[2] +for ac_option in --version -v -V -qversion; do + _AC_DO_LIMIT([$ac_compiler $ac_option >&AS_MESSAGE_LOG_FD]) +done + +m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl +m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl +_AC_LANG_COMPILER_GNU +if test $ac_compiler_gnu = yes; then + GXX=yes +else + GXX= +fi +_AC_PROG_CXX_G +_AC_PROG_CXX_CXX11([ac_prog_cxx_stdcxx=cxx11 + ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx11 + ac_cv_prog_cxx_cxx98=$ac_cv_prog_cxx_cxx11], + [_AC_PROG_CXX_CXX98([ac_prog_cxx_stdcxx=cxx98 + ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx98], + [ac_prog_cxx_stdcxx=no + ac_cv_prog_cxx_stdcxx=no])]) +AC_LANG_POP(C++)dnl +])# AC_PROG_CXX + + +# _AC_C_STD_TRY(STANDARD, TEST-PROLOGUE, TEST-BODY, OPTION-LIST, +# ACTION-IF-AVAILABLE, ACTION-IF-UNAVAILABLE) +# -------------------------------------------------------------- +# Check whether the C compiler accepts features of STANDARD (e.g `c89', `c99') +# by trying to compile a program of TEST-PROLOGUE and TEST-BODY. If this fails, +# try again with each compiler option in the space-separated OPTION-LIST; if one +# helps, append it to CC. If eventually successful, run ACTION-IF-AVAILABLE, +# else ACTION-IF-UNAVAILABLE. +AC_DEFUN([_AC_C_STD_TRY], +[AC_MSG_CHECKING([for $CC option to enable ]m4_translit($1, [c], [C])[ features]) +AC_CACHE_VAL(ac_cv_prog_cc_$1, +[ac_cv_prog_cc_$1=no +ac_save_CC=$CC +AC_LANG_CONFTEST([AC_LANG_PROGRAM([$2], [$3])]) +for ac_arg in '' $4 +do + CC="$ac_save_CC $ac_arg" + _AC_COMPILE_IFELSE([], [ac_cv_prog_cc_$1=$ac_arg]) + test "x$ac_cv_prog_cc_$1" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC +])# AC_CACHE_VAL +ac_prog_cc_stdc_options= +case "x$ac_cv_prog_cc_$1" in + x) + AC_MSG_RESULT([none needed]) ;; + xno) + AC_MSG_RESULT([unsupported]) ;; + *) + ac_prog_cc_stdc_options=" $ac_cv_prog_cc_$1" + CC=$CC$ac_prog_cc_stdc_options + AC_MSG_RESULT([$ac_cv_prog_cc_$1]) ;; +esac +AS_IF([test "x$ac_cv_prog_cc_$1" != xno], [$5], [$6]) +])# _AC_C_STD_TRY + +# _AC_C_C99_TEST_HEADER +# --------------------- +# A C header suitable for testing for C99. +AC_DEFUN([_AC_C_C99_TEST_HEADER], +[[#include <stdarg.h> +#include <stdbool.h> +#include <stddef.h> +#include <stdlib.h> +#include <wchar.h> +#include <stdio.h> + +// Check varargs macros. These examples are taken from C99 6.10.3.5. +#define debug(...) fprintf (stderr, __VA_ARGS__) +#define showlist(...) puts (#__VA_ARGS__) +#define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__)) +static void +test_varargs_macros (void) +{ + int x = 1234; + int y = 5678; + debug ("Flag"); + debug ("X = %d\n", x); + showlist (The first, second, and third items.); + report (x>y, "x is %d but y is %d", x, y); +} + +// Check long long types. +#define BIG64 18446744073709551615ull +#define BIG32 4294967295ul +#define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0) +#if !BIG_OK + your preprocessor is broken; +#endif +#if BIG_OK +#else + your preprocessor is broken; +#endif +static long long int bignum = -9223372036854775807LL; +static unsigned long long int ubignum = BIG64; + +struct incomplete_array +{ + int datasize; + double data[]; +}; + +struct named_init { + int number; + const wchar_t *name; + double average; +}; + +typedef const char *ccp; + +static inline int +test_restrict (ccp restrict text) +{ + // See if C++-style comments work. + // Iterate through items via the restricted pointer. + // Also check for declarations in for loops. + for (unsigned int i = 0; *(text+i) != '\0'; ++i) + continue; + return 0; +} + +// Check varargs and va_copy. +static bool +test_varargs (const char *format, ...) +{ + va_list args; + va_start (args, format); + va_list args_copy; + va_copy (args_copy, args); + + const char *str = ""; + int number = 0; + float fnumber = 0; + + while (*format) + { + switch (*format++) + { + case 's': // string + str = va_arg (args_copy, const char *); + break; + case 'd': // int + number = va_arg (args_copy, int); + break; + case 'f': // float + fnumber = va_arg (args_copy, double); + break; + default: + break; + } + } + va_end (args_copy); + va_end (args); + + return *str && number && fnumber; +}]])# _AC_C_C99_TEST_HEADER + +# _AC_C_C99_TEST_BODY +# ------------------- +# A C body suitable for testing for C99, assuming the corresponding header. +AC_DEFUN([_AC_C_C99_TEST_BODY], +[[ + // Check bool. + _Bool success = false; + + // Check restrict. + if (test_restrict ("String literal") == 0) + success = true; + char *restrict newvar = "Another string"; + + // Check varargs. + success &= test_varargs ("s, d' f .", "string", 65, 34.234); + test_varargs_macros (); + + // Check flexible array members. + struct incomplete_array *ia = + malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10)); + ia->datasize = 10; + for (int i = 0; i < ia->datasize; ++i) + ia->data[i] = i * 1.234; + + // Check named initializers. + struct named_init ni = { + .number = 34, + .name = L"Test wide string", + .average = 543.34343, + }; + + ni.number = 58; + + int dynamic_array[ni.number]; + dynamic_array[ni.number - 1] = 543; + + // work around unused variable warnings + return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x' + || dynamic_array[ni.number - 1] != 543); +]]) + +# _AC_PROG_CC_C99 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE]) +# ---------------------------------------------------------------- +# If the C compiler is not in ISO C99 mode by default, try to add an +# option to output variable CC to make it so. This macro tries +# various options that select ISO C99 on some system or another. It +# considers the compiler to be in ISO C99 mode if it handles _Bool, +# // comments, flexible array members, inline, long long int, mixed +# code and declarations, named initialization of structs, restrict, +# va_copy, varargs macros, variable declarations in for loops and +# variable length arrays. +AC_DEFUN([_AC_PROG_CC_C99], +[_AC_C_STD_TRY([c99], +[_AC_C_C99_TEST_HEADER], +[_AC_C_C99_TEST_BODY], +dnl Try +dnl GCC -std=gnu99 (unused restrictive modes: -std=c99 -std=iso9899:1999) +dnl IBM XL C -qlanglvl=extc1x (V12.1; does not pass C11 test) +dnl IBM XL C -qlanglvl=extc99 +dnl (pre-V12.1; unused restrictive mode: -qlanglvl=stdc99) +dnl HP cc -AC99 +dnl Intel ICC -std=c99, -c99 (deprecated) +dnl IRIX -c99 +dnl Solaris -D_STDC_C99= +dnl cc's -xc99 option uses linker magic to define the external +dnl symbol __xpg4 as if by "int __xpg4 = 1;", which enables C99 +dnl behavior for C library functions. This is not wanted here, +dnl because it means that a single module compiled with -xc99 +dnl alters C runtime behavior for the entire program, not for +dnl just the module. Instead, define the (private) symbol +dnl _STDC_C99, which suppresses a bogus failure in <stdbool.h>. +dnl The resulting compiler passes the test case here, and that's +dnl good enough. For more, please see the thread starting at: +dnl https://lists.gnu.org/r/autoconf/2010-12/msg00059.html +dnl Tru64 -c99 +dnl with extended modes being tried first. +[[-std=gnu99 -std=c99 -c99 -AC99 -D_STDC_C99= -qlanglvl=extc1x -qlanglvl=extc99]], [$1], [$2])[]dnl +])# _AC_PROG_CC_C99 + + +# _AC_PROG_CC_C11 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE]) +# ---------------------------------------------------------------- +# If the C compiler is not in ISO C11 mode by default, try to add an +# option to output variable CC to make it so. This macro tries +# various options that select ISO C11 on some system or another. It +# considers the compiler to be in ISO C11 mode if it handles _Alignas, +# _Alignof, _Noreturn, _Static_assert, UTF-8 string literals, +# duplicate typedefs, and anonymous structures and unions. +AC_DEFUN([_AC_PROG_CC_C11], +[_AC_C_STD_TRY([c11], +[_AC_C_C99_TEST_HEADER[ +// Check _Alignas. +char _Alignas (double) aligned_as_double; +char _Alignas (0) no_special_alignment; +extern char aligned_as_int; +char _Alignas (0) _Alignas (int) aligned_as_int; + +// Check _Alignof. +enum +{ + int_alignment = _Alignof (int), + int_array_alignment = _Alignof (int[100]), + char_alignment = _Alignof (char) +}; +_Static_assert (0 < -_Alignof (int), "_Alignof is signed"); + +// Check _Noreturn. +int _Noreturn does_not_return (void) { for (;;) continue; } + +// Check _Static_assert. +struct test_static_assert +{ + int x; + _Static_assert (sizeof (int) <= sizeof (long int), + "_Static_assert does not work in struct"); + long int y; +}; + +// Check UTF-8 literals. +#define u8 syntax error! +char const utf8_literal[] = u8"happens to be ASCII" "another string"; + +// Check duplicate typedefs. +typedef long *long_ptr; +typedef long int *long_ptr; +typedef long_ptr long_ptr; + +// Anonymous structures and unions -- taken from C11 6.7.2.1 Example 1. +struct anonymous +{ + union { + struct { int i; int j; }; + struct { int k; long int l; } w; + }; + int m; +} v1; +]], +[_AC_C_C99_TEST_BODY[ + v1.i = 2; + v1.w.k = 5; + _Static_assert ((offsetof (struct anonymous, i) + == offsetof (struct anonymous, w.k)), + "Anonymous union alignment botch"); +]], +dnl Try +dnl GCC -std=gnu11 (unused restrictive mode: -std=c11) +dnl with extended modes being tried first. +dnl +dnl Do not try -qlanglvl=extc1x, because IBM XL C V12.1 (the latest version as +dnl of September 2012) does not pass the C11 test. For now, try extc1x when +dnl compiling the C99 test instead, since it enables _Static_assert and +dnl _Noreturn, which is a win. If -qlanglvl=extc11 or -qlanglvl=extc1x passes +dnl the C11 test in some future version of IBM XL C, we'll add it here, +dnl preferably extc11. +[[-std=gnu11]], [$1], [$2])[]dnl +])# _AC_PROG_CC_C11 + + +# AC_PROG_CC_C89 +# -------------- +# Do not use AU_ALIAS here and in AC_PROG_CC_C99 and AC_PROG_CC_STDC, +# as that'd be incompatible with how Automake redefines AC_PROG_CC. See +# <https://lists.gnu.org/r/autoconf/2012-10/msg00048.html>. +AU_DEFUN([AC_PROG_CC_C89], + [AC_REQUIRE([AC_PROG_CC])], + [$0 is obsolete; use AC_PROG_CC] +) + +# AC_PROG_CC_C99 +# -------------- +AU_DEFUN([AC_PROG_CC_C99], + [AC_REQUIRE([AC_PROG_CC])], + [$0 is obsolete; use AC_PROG_CC] +) + +# AC_PROG_CC_STDC +# --------------- +AU_DEFUN([AC_PROG_CC_STDC], + [AC_REQUIRE([AC_PROG_CC])], + [$0 is obsolete; use AC_PROG_CC] +) + + +# AC_C_PROTOTYPES +# --------------- +# Check if the C compiler supports prototypes, included if it needs +# options. +AC_DEFUN([AC_C_PROTOTYPES], +[AC_REQUIRE([AC_PROG_CC])dnl +if test "$ac_prog_cc_stdc" != no; then + AC_DEFINE(PROTOTYPES, 1, + [Define to 1 if the C compiler supports function prototypes.]) + AC_DEFINE(__PROTOTYPES, 1, + [Define like PROTOTYPES; this can be used by system headers.]) +fi +])# AC_C_PROTOTYPES + + +# _AC_CXX_STD_TRY(STANDARD, TEST-PROLOGUE, TEST-BODY, OPTION-LIST, +# ACTION-IF-AVAILABLE, ACTION-IF-UNAVAILABLE) +# ---------------------------------------------------------------- +# Check whether the C++ compiler accepts features of STANDARD (e.g +# `cxx98', `cxx11') by trying to compile a program of TEST-PROLOGUE +# and TEST-BODY. If this fails, try again with each compiler option +# in the space-separated OPTION-LIST; if one helps, append it to CXX. +# If eventually successful, run ACTION-IF-AVAILABLE, else +# ACTION-IF-UNAVAILABLE. +AC_DEFUN([_AC_CXX_STD_TRY], +[AC_MSG_CHECKING([for $CXX option to enable ]m4_translit(m4_translit($1, [x], [+]), [a-z], [A-Z])[ features]) +AC_LANG_PUSH(C++)dnl +AC_CACHE_VAL(ac_cv_prog_cxx_$1, +[ac_cv_prog_cxx_$1=no +ac_save_CXX=$CXX +AC_LANG_CONFTEST([AC_LANG_PROGRAM([$2], [$3])]) +for ac_arg in '' $4 +do + CXX="$ac_save_CXX $ac_arg" + _AC_COMPILE_IFELSE([], [ac_cv_prog_cxx_$1=$ac_arg]) + test "x$ac_cv_prog_cxx_$1" != "xno" && break +done +rm -f conftest.$ac_ext +CXX=$ac_save_CXX +])# AC_CACHE_VAL +ac_prog_cxx_stdcxx_options= +case "x$ac_cv_prog_cxx_$1" in + x) + AC_MSG_RESULT([none needed]) ;; + xno) + AC_MSG_RESULT([unsupported]) ;; + *) + ac_prog_cxx_stdcxx_options=" $ac_cv_prog_cxx_$1" + CXX=$CXX$ac_prog_cxx_stdcxx_options + AC_MSG_RESULT([$ac_cv_prog_cxx_$1]) ;; +esac +AC_LANG_POP(C++)dnl +AS_IF([test "x$ac_cv_prog_cxx_$1" != xno], [$5], [$6]) +])# _AC_CXX_STD_TRY + +# _AC_CXX_CXX98_TEST_HEADER +# ------------------------- +# A C++ header suitable for testing for CXX98. +AC_DEFUN([_AC_CXX_CXX98_TEST_HEADER], +[[ +#include <algorithm> +#include <cstdlib> +#include <fstream> +#include <iomanip> +#include <iostream> +#include <list> +#include <map> +#include <set> +#include <sstream> +#include <stdexcept> +#include <string> +#include <utility> +#include <vector> + +namespace test { + typedef std::vector<std::string> string_vec; + typedef std::pair<int,bool> map_value; + typedef std::map<std::string,map_value> map_type; + typedef std::set<int> set_type; + + template<typename T> + class printer { + public: + printer(std::ostringstream& os): os(os) {} + void operator() (T elem) { os << elem << std::endl; } + private: + std::ostringstream& os; + }; +} +]])# _AC_CXX_CXX98_TEST_HEADER + +# _AC_CXX_CXX98_TEST_BODY +# ----------------------- +# A C++ body suitable for testing for CXX98, assuming the corresponding header. +AC_DEFUN([_AC_CXX_CXX98_TEST_BODY], +[[ + +try { + // Basic string. + std::string teststr("ASCII text"); + teststr += " string"; + + // Simple vector. + test::string_vec testvec; + testvec.push_back(teststr); + testvec.push_back("foo"); + testvec.push_back("bar"); + if (testvec.size() != 3) { + throw std::runtime_error("vector size is not 1"); + } + + // Dump vector into stringstream and obtain string. + std::ostringstream os; + for (test::string_vec::const_iterator i = testvec.begin(); + i != testvec.end(); ++i) { + if (i + 1 != testvec.end()) { + os << teststr << '\n'; + } + } + // Check algorithms work. + std::for_each(testvec.begin(), testvec.end(), test::printer<std::string>(os)); + std::string os_out = os.str(); + + // Test pair and map. + test::map_type testmap; + testmap.insert(std::make_pair(std::string("key"), + std::make_pair(53,false))); + + // Test set. + int values[] = {9, 7, 13, 15, 4, 18, 12, 10, 5, 3, 14, 19, 17, 8, 6, 20, 16, 2, 11, 1}; + test::set_type testset(values, values + sizeof(values)/sizeof(values[0])); + std::list<int> testlist(testset.begin(), testset.end()); + std::copy(testset.begin(), testset.end(), std::back_inserter(testlist)); +} catch (const std::exception& e) { + std::cerr << "Caught exception: " << e.what() << std::endl; + + // Test fstream + std::ofstream of("test.txt"); + of << "Test ASCII text\n" << std::flush; + of << "N= " << std::hex << std::setw(8) << std::left << 534 << std::endl; + of.close(); +} +std::exit(0); +]]) + +# _AC_CXX_CXX11_TEST_HEADER +# ------------------------- +# A C++ header suitable for testing for CXX11. +AC_DEFUN([_AC_CXX_CXX11_TEST_HEADER], +[[ +#include <deque> +#include <functional> +#include <memory> +#include <tuple> +#include <array> +#include <regex> +#include <iostream> + +namespace cxx11test +{ + typedef std::shared_ptr<std::string> sptr; + typedef std::weak_ptr<std::string> wptr; + + typedef std::tuple<std::string,int,double> tp; + typedef std::array<int, 20> int_array; + + constexpr int get_val() { return 20; } + + struct testinit + { + int i; + double d; + }; + + class delegate { + public: + delegate(int n) : n(n) {} + delegate(): delegate(2354) {} + + virtual int getval() { return this->n; }; + protected: + int n; + }; + + class overridden : public delegate { + public: + overridden(int n): delegate(n) {} + virtual int getval() override final { return this->n * 2; } + }; + + class nocopy { + public: + nocopy(int i): i(i) {} + nocopy() = default; + nocopy(const nocopy&) = delete; + nocopy & operator=(const nocopy&) = delete; + private: + int i; + }; +} +]])# _AC_CXX_CXX11_TEST_HEADER + +# _AC_CXX_CXX11_TEST_BODY +# ----------------------- +# A C++ body suitable for testing for CXX11, assuming the corresponding header. +AC_DEFUN([_AC_CXX_CXX11_TEST_BODY], +[[ +{ + // Test auto and decltype + std::deque<int> d; + d.push_front(43); + d.push_front(484); + d.push_front(3); + d.push_front(844); + int total = 0; + for (auto i = d.begin(); i != d.end(); ++i) { total += *i; } + + auto a1 = 6538; + auto a2 = 48573953.4; + auto a3 = "String literal"; + + decltype(a2) a4 = 34895.034; +} +{ + // Test constexpr + short sa[cxx11test::get_val()] = { 0 }; +} +{ + // Test initializer lists + cxx11test::testinit il = { 4323, 435234.23544 }; +} +{ + // Test range-based for and lambda + cxx11test::int_array array = {9, 7, 13, 15, 4, 18, 12, 10, 5, 3, 14, 19, 17, 8, 6, 20, 16, 2, 11, 1}; + for (int &x : array) { x += 23; } + std::for_each(array.begin(), array.end(), [](int v1){ std::cout << v1; }); +} +{ + using cxx11test::sptr; + using cxx11test::wptr; + + sptr sp(new std::string("ASCII string")); + wptr wp(sp); + sptr sp2(wp); +} +{ + cxx11test::tp tuple("test", 54, 45.53434); + double d = std::get<2>(tuple); + std::string s; + int i; + std::tie(s,i,d) = tuple; +} +{ + static std::regex filename_regex("^_?([a-z0-9_.]+-)+[a-z0-9]+$"); + std::string testmatch("Test if this string matches"); + bool match = std::regex_search(testmatch, filename_regex); +} +{ + cxx11test::int_array array = {9, 7, 13, 15, 4, 18, 12, 10, 5, 3, 14, 19, 17, 8, 6, 20, 16, 2, 11, 1}; + cxx11test::int_array::size_type size = array.size(); +} +{ + // Test constructor delegation + cxx11test::delegate d1; + cxx11test::delegate d2(); + cxx11test::delegate d3(45); +} +{ + // Test override and final + cxx11test::overridden o1(55464); +} +{ + // Test nullptr + char *c = nullptr; +} +{ + // Test template brackets + std::vector<std::pair<int,char*>> v1; +} +{ + // Unicode literals + char const *utf8 = u8"UTF-8 string \u2500"; + char16_t const *utf16 = u"UTF-8 string \u2500"; + char32_t const *utf32 = U"UTF-32 string \u2500"; +} +]]) + +# _AC_PROG_CXX_CXX98 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE]) +# ------------------------------------------------------------------- + +# If the C++ compiler is not in ISO C++98 mode by default, try to add +# an option to output variable CXX to make it so. This macro tries +# various options that select ISO C++98 on some system or another. It +# considers the compiler to be in ISO C++98 mode if it handles basic +# features of the std namespace including: string, containers (list, +# map, set, vector), streams (fstreams, iostreams, stringstreams, +# iomanip), pair, exceptions and algorithms. + + +AC_DEFUN([_AC_PROG_CXX_CXX98], +[_AC_CXX_STD_TRY([cxx98], +[_AC_CXX_CXX98_TEST_HEADER], +[_AC_CXX_CXX98_TEST_BODY], +dnl Try +dnl GCC -std=gnu++98 (unused restrictive mode: -std=c++98) +dnl IBM XL C -qlanglvl=extended +dnl HP aC++ -AA +dnl Intel ICC -std=gnu++98 +dnl Solaris N/A (default) +dnl Tru64 N/A (default, but -std gnu could be used) +dnl with extended modes being tried first. +[[-std=gnu++98 -std=c++98 -qlanglvl=extended -AA]], [$1], [$2])[]dnl +])# _AC_PROG_CXX_CXX98 + +# _AC_PROG_CXX_CXX11 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE]) +# ------------------------------------------------------------------- +# If the C++ compiler is not in ISO CXX11 mode by default, try to add +# an option to output variable CXX to make it so. This macro tries +# various options that select ISO C++11 on some system or another. It +# considers the compiler to be in ISO C++11 mode if it handles all the +# tests from the C++98 checks, plus the following: Language features +# (auto, constexpr, decltype, default/deleted constructors, delegate +# constructors, final, initializer lists, lambda functions, nullptr, +# override, range-based for loops, template brackets without spaces, +# unicode literals) and library features (array, memory (shared_ptr, +# weak_ptr), regex and tuple types). +AC_DEFUN([_AC_PROG_CXX_CXX11], +[_AC_CXX_STD_TRY([cxx11], +[_AC_CXX_CXX11_TEST_HEADER +_AC_CXX_CXX98_TEST_HEADER], +[_AC_CXX_CXX11_TEST_BODY +_AC_CXX_CXX98_TEST_BODY], +dnl Try +dnl GCC -std=gnu++11 (unused restrictive mode: -std=c++11) [and 0x variants] +dnl IBM XL C -qlanglvl=extended0x +dnl (pre-V12.1; unused restrictive mode: -qlanglvl=stdcxx11) +dnl HP aC++ -AA +dnl Intel ICC -std=c++11 -std=c++0x +dnl Solaris N/A (no support) +dnl Tru64 N/A (no support) +dnl with extended modes being tried first. +[[-std=gnu++11 -std=c++11 -std=gnu++0x -std=c++0x -qlanglvl=extended0x -AA]], [$1], [$2])[]dnl +])# _AC_PROG_CXX_CXX11 + + +])# m4_version_prereq +])# !_AC_C_C23_OPTIONS diff --git a/tests/check_headers_and_includes b/tests/check_headers_and_includes index 70e134896d..6e2238e9d3 100755 --- a/tests/check_headers_and_includes +++ b/tests/check_headers_and_includes @@ -64,6 +64,7 @@ my %dirs_to_ignore = ( "docs" => 1, "auxprogs" => 1, "autom4te.cache" => 1, + "m4" => 1, "nightly" => 1, "perf" => 1, "tests" => 1, |
From: Mark W. <ma...@so...> - 2025-01-23 14:57:40
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=9f0e4107c140b47ea2a9c097afcac73a8454e17f commit 9f0e4107c140b47ea2a9c097afcac73a8454e17f Author: Mark Wielaard <ma...@kl...> Date: Thu Jan 23 15:50:52 2025 +0100 Treat all inherited file descriptors the same with --track-fds. We used to special case 0, 1, 2 (stdin/out/err) specially even when they were not inherited (anymore). Now the --track-fds=[yes|all] option treats all inherited file descriptors the same. And if any inherited file descriptor gets closed and reopened then they are now treated as normal non-inherited file descriptors. https://bugs.kde.org/show_bug.cgi?id=487296 Diff: --- NEWS | 7 +++++++ coregrind/m_main.c | 2 +- coregrind/m_syswrap/syswrap-generic.c | 14 +++++++------- memcheck/tests/freebsd/pdfork_pdkill.stderr.exp | 2 +- memcheck/tests/freebsd/timerfd.stderr.exp | 2 +- none/tests/cmdline1.stdout.exp | 2 +- none/tests/cmdline1.stdout.exp-non-linux | 2 +- none/tests/cmdline2.stdout.exp | 2 +- none/tests/cmdline2.stdout.exp-non-linux | 2 +- none/tests/fdleak_cmsg.stderr.exp | 4 ++-- none/tests/fdleak_cmsg_supp.stderr.exp | 4 ++-- none/tests/fdleak_creat.stderr.exp | 2 +- none/tests/fdleak_creat_sup.stderr.exp | 2 +- none/tests/fdleak_dup.stderr.exp | 2 +- none/tests/fdleak_dup2.stderr.exp | 2 +- none/tests/fdleak_fcntl.stderr.exp | 2 +- none/tests/fdleak_ipv4.stderr.exp | 4 ++-- none/tests/fdleak_open.stderr.exp | 2 +- none/tests/fdleak_pipe.stderr.exp | 2 +- none/tests/fdleak_socketpair.stderr.exp | 2 +- none/tests/freebsd/umtx_shm_creat1.stderr.exp | 2 +- none/tests/freebsd/umtx_shm_creat2.stderr.exp | 2 +- 22 files changed, 37 insertions(+), 30 deletions(-) diff --git a/NEWS b/NEWS index 5c576ff33e..22744917eb 100644 --- a/NEWS +++ b/NEWS @@ -18,6 +18,11 @@ AMD64/macOS 10.13 and nanoMIPS/Linux. * ==================== TOOL CHANGES =================== +* The --track-fds=yes and --track-fds=all options now treat all + inherited file descriptors the same as 0, 1, 2 (stdin/out/err). + And when the stdin/out/err descriptors are reassigned they are + now treated as normal (non-inherited) file descriptors. + * ==================== FIXED BUGS ==================== The following bugs have been fixed or resolved. Note that "n-i-bz" @@ -27,6 +32,8 @@ bugzilla (https://bugs.kde.org/enter_bug.cgi?product=valgrind) rather than mailing the developers (or mailing lists) directly -- bugs that are not entered into bugzilla tend to get forgotten about or ignored. +487296 --track-fds=yes and --track-fds=all report erroneous information + when fds 0, 1, or 2 are used as non-std 489913 WARNING: unhandled amd64-linux syscall: 444 (landlock_create_ruleset) 494246 syscall fsopen not wrapped 494327 Crash when running Helgrind built with #define TRACE_PTH_FNS 1 diff --git a/coregrind/m_main.c b/coregrind/m_main.c index 3eba026cc5..3f07e57a91 100644 --- a/coregrind/m_main.c +++ b/coregrind/m_main.c @@ -114,7 +114,7 @@ static void usage_NORETURN ( int need_help ) " where event is one of:\n" " startup exit abexit valgrindabexit all none\n" " --track-fds=no|yes|all track open file descriptors? [no]\n" -" all includes reporting stdin, stdout and stderr\n" +" all includes reporting inherited file descriptors\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" diff --git a/coregrind/m_syswrap/syswrap-generic.c b/coregrind/m_syswrap/syswrap-generic.c index bfe4c6fe06..a74b8f1d21 100644 --- a/coregrind/m_syswrap/syswrap-generic.c +++ b/coregrind/m_syswrap/syswrap-generic.c @@ -941,30 +941,30 @@ HChar *getsockdetails(Int fd, UInt len, HChar *buf) void VG_(show_open_fds) (const HChar* when) { OpenFd *i; - int non_std = 0; + int inherited = 0; for (i = allocated_fds; i; i = i->next) { - if (i->fd > 2 && i->fd_closed != True) - non_std++; + if (i->where == NULL) + inherited++; } /* If we are running quiet and there are either no open file descriptors or not tracking all fds, then don't report anything. */ if ((fd_count == 0 - || ((non_std == 0) && (VG_(clo_track_fds) < 2))) + || ((fd_count - inherited == 0) && (VG_(clo_track_fds) < 2))) && (VG_(clo_verbosity) == 0)) return; if (!VG_(clo_xml)) { - VG_(umsg)("FILE DESCRIPTORS: %d open (%d std) %s.\n", - fd_count, fd_count - non_std, when); + VG_(umsg)("FILE DESCRIPTORS: %d open (%d inherited) %s.\n", + fd_count, inherited, when); } for (i = allocated_fds; i; i = i->next) { if (i->fd_closed) continue; - if (i->fd <= 2 && VG_(clo_track_fds) < 2) + if (i->where == NULL && VG_(clo_track_fds) < 2) continue; struct NotClosedExtra nce; diff --git a/memcheck/tests/freebsd/pdfork_pdkill.stderr.exp b/memcheck/tests/freebsd/pdfork_pdkill.stderr.exp index 018489c62f..bab0469bad 100644 --- a/memcheck/tests/freebsd/pdfork_pdkill.stderr.exp +++ b/memcheck/tests/freebsd/pdfork_pdkill.stderr.exp @@ -28,7 +28,7 @@ Syscall param pdfork(flags) contains uninitialised byte(s) ... by 0x........: main (pdfork_pdkill.c:96) -FILE DESCRIPTORS: 3 open (3 std) at exit. +FILE DESCRIPTORS: 3 open (3 inherited) at exit. Open file descriptor ... <inherited from parent> diff --git a/memcheck/tests/freebsd/timerfd.stderr.exp b/memcheck/tests/freebsd/timerfd.stderr.exp index 4831ec8061..beff4e6fc3 100644 --- a/memcheck/tests/freebsd/timerfd.stderr.exp +++ b/memcheck/tests/freebsd/timerfd.stderr.exp @@ -32,7 +32,7 @@ Syscall param timerfd_settime(fd) contains uninitialised byte(s) at 0x........: timerfd_settime (in /...libc...) by 0x........: main (timerfd.c:141) -FILE DESCRIPTORS: 4 open (3 std) at exit. +FILE DESCRIPTORS: 4 open (3 inherited) at exit. Open file descriptor 3: at 0x........: timerfd_create (in /...libc...) by 0x........: main (timerfd.c:115) diff --git a/none/tests/cmdline1.stdout.exp b/none/tests/cmdline1.stdout.exp index c7b7536856..464c58f42a 100644 --- a/none/tests/cmdline1.stdout.exp +++ b/none/tests/cmdline1.stdout.exp @@ -29,7 +29,7 @@ usage: valgrind [options] prog-and-args where event is one of: startup exit abexit valgrindabexit all none --track-fds=no|yes|all track open file descriptors? [no] - all includes reporting stdin, stdout and stderr + all includes reporting inherited file descriptors --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/cmdline1.stdout.exp-non-linux b/none/tests/cmdline1.stdout.exp-non-linux index 6650cc5b90..f0534f824c 100644 --- a/none/tests/cmdline1.stdout.exp-non-linux +++ b/none/tests/cmdline1.stdout.exp-non-linux @@ -29,7 +29,7 @@ usage: valgrind [options] prog-and-args where event is one of: startup exit abexit valgrindabexit all none --track-fds=no|yes|all track open file descriptors? [no] - all includes reporting stdin, stdout and stderr + all includes reporting inherited file descriptors --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 24ca407f80..fe526855d8 100644 --- a/none/tests/cmdline2.stdout.exp +++ b/none/tests/cmdline2.stdout.exp @@ -29,7 +29,7 @@ usage: valgrind [options] prog-and-args where event is one of: startup exit abexit valgrindabexit all none --track-fds=no|yes|all track open file descriptors? [no] - all includes reporting stdin, stdout and stderr + all includes reporting inherited file descriptors --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 e13d196954..e518644ab5 100644 --- a/none/tests/cmdline2.stdout.exp-non-linux +++ b/none/tests/cmdline2.stdout.exp-non-linux @@ -29,7 +29,7 @@ usage: valgrind [options] prog-and-args where event is one of: startup exit abexit valgrindabexit all none --track-fds=no|yes|all track open file descriptors? [no] - all includes reporting stdin, stdout and stderr + all includes reporting inherited file descriptors --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/fdleak_cmsg.stderr.exp b/none/tests/fdleak_cmsg.stderr.exp index 0fe56eaeed..6b3b53fc7c 100644 --- a/none/tests/fdleak_cmsg.stderr.exp +++ b/none/tests/fdleak_cmsg.stderr.exp @@ -1,6 +1,6 @@ -FILE DESCRIPTORS: 7 open (3 std) at exit. +FILE DESCRIPTORS: 7 open (3 inherited) at exit. Open AF_UNIX socket ...: /tmp/sock ... @@ -24,7 +24,7 @@ Open file descriptor ...: /dev/null -FILE DESCRIPTORS: 6 open (3 std) at exit. +FILE DESCRIPTORS: 6 open (3 inherited) at exit. Open file descriptor ...: /tmp/data2 ... diff --git a/none/tests/fdleak_cmsg_supp.stderr.exp b/none/tests/fdleak_cmsg_supp.stderr.exp index a7d8cc42e2..f2636d2da4 100644 --- a/none/tests/fdleak_cmsg_supp.stderr.exp +++ b/none/tests/fdleak_cmsg_supp.stderr.exp @@ -1,6 +1,6 @@ -FILE DESCRIPTORS: 7 open (3 std) at exit. +FILE DESCRIPTORS: 7 open (3 inherited) at exit. Open file descriptor ...: ... <inherited from parent> @@ -12,7 +12,7 @@ Open file descriptor ...: /dev/null -FILE DESCRIPTORS: 6 open (3 std) at exit. +FILE DESCRIPTORS: 6 open (3 inherited) at exit. Open file descriptor ...: ... <inherited from parent> diff --git a/none/tests/fdleak_creat.stderr.exp b/none/tests/fdleak_creat.stderr.exp index 7b70478b9d..b4954bc0e1 100644 --- a/none/tests/fdleak_creat.stderr.exp +++ b/none/tests/fdleak_creat.stderr.exp @@ -1,6 +1,6 @@ -FILE DESCRIPTORS: 4 open (3 std) at exit. +FILE DESCRIPTORS: 4 open (3 inherited) at exit. Open file descriptor ...: /tmp/file ... diff --git a/none/tests/fdleak_creat_sup.stderr.exp b/none/tests/fdleak_creat_sup.stderr.exp index c02a807356..094b516ce5 100644 --- a/none/tests/fdleak_creat_sup.stderr.exp +++ b/none/tests/fdleak_creat_sup.stderr.exp @@ -1,6 +1,6 @@ -FILE DESCRIPTORS: 4 open (3 std) at exit. +FILE DESCRIPTORS: 4 open (3 inherited) at exit. Open file descriptor ...: ... <inherited from parent> diff --git a/none/tests/fdleak_dup.stderr.exp b/none/tests/fdleak_dup.stderr.exp index 8ceada9230..1ed7d8c26b 100644 --- a/none/tests/fdleak_dup.stderr.exp +++ b/none/tests/fdleak_dup.stderr.exp @@ -1,6 +1,6 @@ -FILE DESCRIPTORS: 5 open (3 std) at exit. +FILE DESCRIPTORS: 5 open (3 inherited) at exit. Open file descriptor ...: /dev/null ... diff --git a/none/tests/fdleak_dup2.stderr.exp b/none/tests/fdleak_dup2.stderr.exp index 4576a578b3..8c2cbefa18 100644 --- a/none/tests/fdleak_dup2.stderr.exp +++ b/none/tests/fdleak_dup2.stderr.exp @@ -1,6 +1,6 @@ -FILE DESCRIPTORS: 6 open (3 std) at exit. +FILE DESCRIPTORS: 6 open (3 inherited) at exit. Open file descriptor ...: /dev/null ... diff --git a/none/tests/fdleak_fcntl.stderr.exp b/none/tests/fdleak_fcntl.stderr.exp index 8ceada9230..1ed7d8c26b 100644 --- a/none/tests/fdleak_fcntl.stderr.exp +++ b/none/tests/fdleak_fcntl.stderr.exp @@ -1,6 +1,6 @@ -FILE DESCRIPTORS: 5 open (3 std) at exit. +FILE DESCRIPTORS: 5 open (3 inherited) at exit. Open file descriptor ...: /dev/null ... diff --git a/none/tests/fdleak_ipv4.stderr.exp b/none/tests/fdleak_ipv4.stderr.exp index 801b0279f8..4560caf69c 100644 --- a/none/tests/fdleak_ipv4.stderr.exp +++ b/none/tests/fdleak_ipv4.stderr.exp @@ -12,7 +12,7 @@ File descriptor ...: ... is already closed by 0x........: client (fdleak_ipv4.c:68) by 0x........: main -FILE DESCRIPTORS: 5 open (3 std) at exit. +FILE DESCRIPTORS: 5 open (3 inherited) at exit. Open AF_INET socket 4: 127.0.0.1:... <-> 127.0.0.1:... ... @@ -21,7 +21,7 @@ Open AF_INET socket 3: 127.0.0.1:... <-> <unbound> -FILE DESCRIPTORS: 4 open (3 std) at exit. +FILE DESCRIPTORS: 4 open (3 inherited) at exit. Open AF_INET socket 3: 127.0.0.1:... <-> 127.0.0.1:... ... diff --git a/none/tests/fdleak_open.stderr.exp b/none/tests/fdleak_open.stderr.exp index f3f51167f1..348f99edcd 100644 --- a/none/tests/fdleak_open.stderr.exp +++ b/none/tests/fdleak_open.stderr.exp @@ -1,6 +1,6 @@ -FILE DESCRIPTORS: 4 open (3 std) at exit. +FILE DESCRIPTORS: 4 open (3 inherited) at exit. Open file descriptor ...: /dev/null ... diff --git a/none/tests/fdleak_pipe.stderr.exp b/none/tests/fdleak_pipe.stderr.exp index 5f92ea69c2..34b6a8f8cd 100644 --- a/none/tests/fdleak_pipe.stderr.exp +++ b/none/tests/fdleak_pipe.stderr.exp @@ -1,6 +1,6 @@ -FILE DESCRIPTORS: 5 open (3 std) at exit. +FILE DESCRIPTORS: 5 open (3 inherited) at exit. Open file descriptor ...: ... diff --git a/none/tests/fdleak_socketpair.stderr.exp b/none/tests/fdleak_socketpair.stderr.exp index 73832a108b..d6f6d10c6e 100644 --- a/none/tests/fdleak_socketpair.stderr.exp +++ b/none/tests/fdleak_socketpair.stderr.exp @@ -1,6 +1,6 @@ -FILE DESCRIPTORS: 5 open (3 std) at exit. +FILE DESCRIPTORS: 5 open (3 inherited) at exit. Open AF_UNIX socket ...: <unknown> ... diff --git a/none/tests/freebsd/umtx_shm_creat1.stderr.exp b/none/tests/freebsd/umtx_shm_creat1.stderr.exp index 4e918760ff..d7f9503061 100644 --- a/none/tests/freebsd/umtx_shm_creat1.stderr.exp +++ b/none/tests/freebsd/umtx_shm_creat1.stderr.exp @@ -1,4 +1,4 @@ -FILE DESCRIPTORS: 3 open (3 std) at exit. +FILE DESCRIPTORS: 3 open (3 inherited) at exit. Open file descriptor ...: ... <inherited from parent> diff --git a/none/tests/freebsd/umtx_shm_creat2.stderr.exp b/none/tests/freebsd/umtx_shm_creat2.stderr.exp index 4acc5e4122..1504b8d18f 100644 --- a/none/tests/freebsd/umtx_shm_creat2.stderr.exp +++ b/none/tests/freebsd/umtx_shm_creat2.stderr.exp @@ -1,4 +1,4 @@ -FILE DESCRIPTORS: 4 open (3 std) at exit. +FILE DESCRIPTORS: 4 open (3 inherited) at exit. Open file descriptor ...: ... |
From: Enzo B. <enz...@gm...> - 2025-01-18 11:10:10
|
Hello, For my computer science thesis, I need to instrument programs in order to know which floating point values are being stored to buffers whose size is greater than a certain threshold. For doing that, I modified the tool memcheck in this public repository <https://github.com/enzobonansea/floating-point-vectors-inspector>; you can find my modifications by searching for "memlog" in the code. The customization works as I expect, giving me the floating point values that I need. Now, I want to optimize my code since it's CPU intensive and makes the instrumented applications too slow. For instance, I ran the memcheck customization against the SPEC2017 tool called lbm which took originally a few seconds to run, but under the tool it takes more than 2 minutes with the CPU at 100% all the time. If you see the code, the cause of the performance degradation is evident: for every store I'm calling the dirty helper log_store, which means that I'm calling that C function millions of times. I used Valgrind's memcheck several times as a user, but 2 months ago was my first time seeing the tool's source code. So, since I'm new on this and you guys have a lot of experience working on the project, maybe you find my problem trivial and you can have a good idea of how I can improve the performance of my customization of memcheck. Any ideas will be welcomed, thanks! |
From: Andreas A. <ar...@li...> - 2025-01-16 17:06:08
|
On Wed, Jan 08 2025, Florian Krohm wrote: > On 08.01.25 06:55, Paul Floyd via Valgrind-developers wrote: >> I'm all for it. Does the oldest GCC used for the nightlies and buildbot >> support C11? >> > > We could check this in and see what happens. > A word from the platform maintainers would be good, too. I'm fine with this. Does anybody else have an issue? Otherwise I suggest to make the change if nobody complains within a week or so. -- Andreas |
From: Mark W. <ma...@so...> - 2025-01-16 16:33:15
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=090f8ce59b5f3d3ec39e032ee5e9524ce4f51a44 commit 090f8ce59b5f3d3ec39e032ee5e9524ce4f51a44 Author: Mark Wielaard <ma...@kl...> Date: Thu Jan 16 17:30:37 2025 +0100 gdbserver_tests: filter out new Missing rpms message As seen on the fedora 40 s390x tester. GDB now might output something like: Missing rpms, try: dnf --enablerepo='*debug*' install glibc-debuginfo-2.39-33.fc40.s390x Filter those messages out to get zero fail test results again. Diff: --- gdbserver_tests/filter_gdb.in | 1 + gdbserver_tests/filter_memcheck_monitor.in | 1 + 2 files changed, 2 insertions(+) diff --git a/gdbserver_tests/filter_gdb.in b/gdbserver_tests/filter_gdb.in index 094ea933ec..2bef9f3ee5 100755 --- a/gdbserver_tests/filter_gdb.in +++ b/gdbserver_tests/filter_gdb.in @@ -265,6 +265,7 @@ s/^0x........ in \(\w\+ (\)/\1/ # delete any missing debuginfo messages /^Missing debuginfo.*/d +/^Missing rpms.*/d EOF diff --git a/gdbserver_tests/filter_memcheck_monitor.in b/gdbserver_tests/filter_memcheck_monitor.in index 6e8a49a303..e407e7b921 100755 --- a/gdbserver_tests/filter_memcheck_monitor.in +++ b/gdbserver_tests/filter_memcheck_monitor.in @@ -31,6 +31,7 @@ $dir/filter_vgdb | $SED -e '/Cannot access memory at address 0x......../d' \ -e '/^[1-9][0-9]* \.\.\/sysdeps\/powerpc\/powerpc32\/dl-start\.S: No such file or directory\./d' \ -e '/^Missing separate debuginfo/d' \ + -e '/^Missing rpms/d' \ -e '/^Try: zypper install -C/d' \ -e 's/Test 3: FAIL: expected si_code==2, not 128/Test 3: PASS/' \ -e 's/in use at exit: [0-9][0-9,]* bytes in [0-9][0-9]* blocks/in use at exit: ... bytes in ... blocks/' \ |
From: D. J. B. <aut...@bo...> - 2025-01-15 22:21:11
|
Paul Floyd via Valgrind-developers writes: > On 26-10-24 16:58, D. J. Bernstein wrote: > > Paul Floyd via Valgrind-developers writes: > > > 1. Using a / in environment variables doesn't work with most (all?) shells. > > Also hyphens; but, as noted in my previous message, this is only a minor > > disadvantage since one can set the variables using env rather than shell > > builtins. This is also what the tests in the patch do, and it works for > > the intended use case of simplifying scripts. > Sorry to be so difficult, but I think that it's best to get things > like this right before letting them out into the wild. Of course! But please note that valgrind-env-patch-20241026.txt already switched to being sh-builtin-compatible, using VALGRIND__x_y=z for --x-y=z. > How about just having VALGRIND_TRYOPTS or VALGRIND_TRY_OPTS. That would be > the same as VALGRIND_OPTS but not result in failure if there's an > unrecognized option. This would create the following unnecessary usability issue: if a script does an opportunistic env VALGRIND_TRY_OPTS='--leak-check=yes' valgrind ... and the user has set an independent opportunistic export VALGRIND_TRY_OPTS='--time-stamp=yes' then the script's VALGRIND_TRY_OPTS will wipe out the user's VALGRIND_TRY_OPTS, unless the script author thinks of doing env VALGRIND_TRY_OPTS="$VALGRIND_TRY_OPTS --leak-check=yes" valgrind ... instead. You can see from, e.g., the use of VALGRIND_OPTS in https://github.com/apache/subversion/blob/trunk/subversion/tests/README that people often miss these composability issues. For comparison, with valgrind-env-patch-20241026.txt, a script doing env VALGRIND__leak_check=yes valgrind ... won't interfere with a user setting an independent opportunistic option: export VALGRIND__time_stamp=yes It's also clear what the conciseness winner is in these examples; what makes it easier for scripts to check whether an option is set, if that's desired; etc. In terms of purity, VALGRIND_OPTS has punctuation issues with user data (what happens if an option value needs an embedded space?), while the analysis of collisions for valgrind-env-patch-20241026.txt is determined entirely by the valgrind-controlled list of option names. I also think that analogies to VALGRIND_CLO_CHANGE, which already has the feature of being opportunistic, are more useful than analogies to VALGRIND_OPTS. ---D. J. Bernstein |