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
(32) |
Oct
|
Nov
|
Dec
|
|
From: Paul F. <pa...@so...> - 2023-03-11 15:33:16
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=036bf06734321b352e1069b561a4730e5daff52f commit 036bf06734321b352e1069b561a4730e5daff52f Author: Paul Floyd <pj...@wa...> Date: Sat Mar 11 16:31:43 2023 +0100 Refactor: reorder a few structs to make them more compact Used pahole to find candidates. Don't have any performance measurements, but it won't do any harm. Diff: --- coregrind/m_errormgr.c | 4 ++-- coregrind/m_hashtable.c | 2 +- memcheck/mc_include.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/coregrind/m_errormgr.c b/coregrind/m_errormgr.c index 52505ba5b2..6be637190a 100644 --- a/coregrind/m_errormgr.c +++ b/coregrind/m_errormgr.c @@ -130,9 +130,9 @@ struct _Error { // which it can be referred to afterwords. Currently only used for // XML printing. UInt unique; + Int count; // NULL if unsuppressed; or ptr to suppression record. Supp* supp; - Int count; // The tool-specific part ThreadId tid; // Initialised by core @@ -225,8 +225,8 @@ typedef (0..)) for 'skind'. */ struct _Supp { struct _Supp* next; - Int count; // The number of times this error has been suppressed. HChar* sname; // The name by which the suppression is referred to. + Int count; // The number of times this error has been suppressed. // Index in VG_(clo_suppressions) giving filename from which suppression // was read, and the lineno in this file where sname was read. diff --git a/coregrind/m_hashtable.c b/coregrind/m_hashtable.c index 19c604d3a6..586cfcc4f3 100644 --- a/coregrind/m_hashtable.c +++ b/coregrind/m_hashtable.c @@ -45,8 +45,8 @@ struct _VgHashTable { UInt n_elements; VgHashNode* iterNode; // current iterator node UInt iterChain; // next chain to be traversed by the iterator - VgHashNode** chains; // expanding array of hash chains Bool iterOK; // table safe to iterate over? + VgHashNode** chains; // expanding array of hash chains const HChar* name; // name of table (for debugging only) }; diff --git a/memcheck/mc_include.h b/memcheck/mc_include.h index 3c1b1a7cd4..c30ec48efb 100644 --- a/memcheck/mc_include.h +++ b/memcheck/mc_include.h @@ -455,9 +455,9 @@ typedef SizeT szB; // Sum of all MC_Chunk.szB values. SizeT indirect_szB; // Sum of all LC_Extra.indirect_szB values. UInt num_blocks; // Number of blocks represented by the record. + UInt old_num_blocks; // output only the changed/new loss records SizeT old_szB; // old_* values are the values found during the SizeT old_indirect_szB; // previous leak search. old_* values are used to - UInt old_num_blocks; // output only the changed/new loss records } LossRecord; |
|
From: Paul F. <pa...@so...> - 2023-03-11 07:08:07
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=678b685c7b0d982a5a1142ff598ab0f2eab8e794 commit 678b685c7b0d982a5a1142ff598ab0f2eab8e794 Author: Paul Floyd <pj...@wa...> Date: Sat Mar 11 08:07:06 2023 +0100 regtest: update one expected after fixing realloc_size_zero_mismatch.cpp Diff: --- memcheck/tests/realloc_size_zero_mismatch.stderr.exp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/memcheck/tests/realloc_size_zero_mismatch.stderr.exp b/memcheck/tests/realloc_size_zero_mismatch.stderr.exp index f7c535574b..141ab8b7ad 100644 --- a/memcheck/tests/realloc_size_zero_mismatch.stderr.exp +++ b/memcheck/tests/realloc_size_zero_mismatch.stderr.exp @@ -1,28 +1,28 @@ realloc() with size 0 at 0x........: realloc (vg_replace_malloc.c:...) - by 0x........: main (realloc_size_zero_mismatch.cpp:15) + by 0x........: main (realloc_size_zero_mismatch.cpp:16) Address 0x........ is 0 bytes inside a block of size 1,024 alloc'd at 0x........: ...operator new[]... (vg_replace_malloc.c:...) - by 0x........: main (realloc_size_zero_mismatch.cpp:11) + by 0x........: main (realloc_size_zero_mismatch.cpp:12) Mismatched free() / delete / delete [] at 0x........: realloc (vg_replace_malloc.c:...) - by 0x........: main (realloc_size_zero_mismatch.cpp:15) + by 0x........: main (realloc_size_zero_mismatch.cpp:16) Address 0x........ is 0 bytes inside a block of size 1,024 alloc'd at 0x........: ...operator new[]... (vg_replace_malloc.c:...) - by 0x........: main (realloc_size_zero_mismatch.cpp:11) + by 0x........: main (realloc_size_zero_mismatch.cpp:12) Mismatched free() / delete / delete [] at 0x........: ...operator delete[]... (vg_replace_malloc.c:...) - by 0x........: main (realloc_size_zero_mismatch.cpp:25) + by 0x........: main (realloc_size_zero_mismatch.cpp:26) Address 0x........ is 0 bytes inside a block of size 1 alloc'd at 0x........: realloc (vg_replace_malloc.c:...) - by 0x........: main (realloc_size_zero_mismatch.cpp:15) + by 0x........: main (realloc_size_zero_mismatch.cpp:16) Mismatched free() / delete / delete [] at 0x........: ...operator delete[]... (vg_replace_malloc.c:...) - by 0x........: main (realloc_size_zero_mismatch.cpp:40) + by 0x........: main (realloc_size_zero_mismatch.cpp:41) Address 0x........ is 0 bytes after a block of size 0 alloc'd at 0x........: realloc (vg_replace_malloc.c:...) - by 0x........: main (realloc_size_zero_mismatch.cpp:30) + by 0x........: main (realloc_size_zero_mismatch.cpp:31) |
|
From: Paul F. <pa...@so...> - 2023-03-11 05:50:13
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=d9a8c601af8182f5b0b11da6a6e0f657fa087405 commit d9a8c601af8182f5b0b11da6a6e0f657fa087405 Author: Paul Floyd <pj...@wa...> Date: Sat Mar 11 06:49:13 2023 +0100 regtest: build failure on Linux ppc64le, missing header Diff: --- memcheck/tests/realloc_size_zero_mismatch.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/memcheck/tests/realloc_size_zero_mismatch.cpp b/memcheck/tests/realloc_size_zero_mismatch.cpp index 13d1e58832..ba809ee17b 100644 --- a/memcheck/tests/realloc_size_zero_mismatch.cpp +++ b/memcheck/tests/realloc_size_zero_mismatch.cpp @@ -1,5 +1,6 @@ #include <iostream> #include <cstdlib> +#include <cstdio> #include <cerrno> using std::realloc; |
|
From: Paul F. <pa...@so...> - 2023-03-10 21:00:41
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=50bded71b23cb11a8b6c1b6eaf6e3abcc05a06c2 commit 50bded71b23cb11a8b6c1b6eaf6e3abcc05a06c2 Author: Paul Floyd <pj...@wa...> Date: Fri Mar 10 21:55:14 2023 +0100 Bug 436413 - Warn about realloc of size zero Adds a new warning to memcheck when realloc is used with a size of 0. For a long time this has been "implementation defined" and so non-portable. With C23 it will become UB. Also adds a switch to turn off the error generation and a second switch to select between the most common "implementation" behaviours. The defaults for this second switch are baked in at build time. Diff: --- .gitignore | 2 + NEWS | 26 +++++++++ coregrind/m_main.c | 4 ++ coregrind/m_replacemalloc/replacemalloc_core.c | 6 ++ coregrind/m_replacemalloc/vg_replace_malloc.c | 60 ++++++++------------ coregrind/m_scheduler/scheduler.c | 1 + coregrind/pub_core_replacemalloc.h | 1 + dhat/dh_main.c | 7 ++- docs/xml/manual-core.xml | 18 ++++++ drd/drd_malloc_wrappers.c | 8 ++- drd/tests/memory_allocation.c | 7 +-- helgrind/hg_main.c | 19 +++++++ include/pub_tool_replacemalloc.h | 2 + massif/ms_main.c | 14 +++++ massif/tests/realloc.post.exp | 2 +- massif/tests/realloc.vgtest | 3 +- memcheck/docs/mc-manual.xml | 27 +++++++++ memcheck/mc_errors.c | 65 ++++++++++++++++++---- memcheck/mc_include.h | 4 ++ memcheck/mc_main.c | 4 ++ memcheck/mc_malloc_wrappers.c | 19 +++++++ memcheck/tests/Makefile.am | 18 ++++++ memcheck/tests/amd64-freebsd/reallocf.c | 1 + memcheck/tests/amd64-freebsd/reallocf.stderr.exp | 11 +++- memcheck/tests/freebsd/static_allocs.stderr.exp | 14 ++++- memcheck/tests/realloc_size_zero.c | 39 +++++++++++++ memcheck/tests/realloc_size_zero.stderr.exp | 7 +++ memcheck/tests/realloc_size_zero.stdout.exp-glibc | 2 + memcheck/tests/realloc_size_zero.stdout.exp-other | 2 + memcheck/tests/realloc_size_zero.supp | 7 +++ memcheck/tests/realloc_size_zero.vgtest | 2 + memcheck/tests/realloc_size_zero_mismatch.cpp | 41 ++++++++++++++ .../tests/realloc_size_zero_mismatch.stderr.exp | 28 ++++++++++ .../tests/realloc_size_zero_mismatch.stdout.exp | 2 + memcheck/tests/realloc_size_zero_mismatch.vgtest | 2 + memcheck/tests/realloc_size_zero_no.stderr.exp | 7 +++ memcheck/tests/realloc_size_zero_no.stdout.exp | 2 + memcheck/tests/realloc_size_zero_no.vgtest | 2 + memcheck/tests/realloc_size_zero_off.stderr.exp | 0 memcheck/tests/realloc_size_zero_off.stdout.exp | 2 + memcheck/tests/realloc_size_zero_off.vgtest | 2 + memcheck/tests/realloc_size_zero_supp.stderr.exp | 0 memcheck/tests/realloc_size_zero_supp.stdout.exp | 2 + memcheck/tests/realloc_size_zero_supp.vgtest | 2 + memcheck/tests/realloc_size_zero_yes.stderr.exp | 7 +++ memcheck/tests/realloc_size_zero_yes.stdout.exp | 2 + memcheck/tests/realloc_size_zero_yes.vgtest | 2 + none/tests/cmdline1.stdout.exp | 4 ++ none/tests/cmdline1.stdout.exp-non-linux | 4 ++ none/tests/cmdline2.stdout.exp | 4 ++ none/tests/cmdline2.stdout.exp-non-linux | 4 ++ 51 files changed, 457 insertions(+), 64 deletions(-) diff --git a/.gitignore b/.gitignore index d5e341063e..a88ab4dd43 100644 --- a/.gitignore +++ b/.gitignore @@ -947,6 +947,8 @@ /memcheck/tests/posix_memalign /memcheck/tests/post-syscall /memcheck/tests/reach_thread_register +/memcheck/tests/realloc_size_zero +/memcheck/tests/realloc_size_zero_mismatch /memcheck/tests/realloc1 /memcheck/tests/realloc2 /memcheck/tests/realloc3 diff --git a/NEWS b/NEWS index bc3f4a363b..cd20f7773a 100644 --- a/NEWS +++ b/NEWS @@ -37,6 +37,25 @@ AMD64/macOS 10.13 and nanoMIPS/Linux. $3 = 40 (gdb) monitor who_point_at 0x1130a0 40 +* The behaviour of realloc with a size of zero can now + be changed for tools that intercept malloc. Those + tools are memcheck, helgrind, drd, massif and dhat. + Realloc implementations generally do one of two things + - free the memory like free() and return NULL + (GNU libc and ptmalloc). + - either free the memory and then allocate a + minumum siized block or just return the + original pointer. Return NULL if the + allocation of the minimum sized block fails + (jemalloc, musl, snmalloc, Solaris, macOS). + When Valgrind is configured and built it will + try to match the OS and libc behaviour. However + if you are using a non-default library to replace + malloc and family (e.g., musl on a glibc Linux or + tcmalloc on FreeBSD) then you can use a command line + option to change the behaviour of Valgrind: + --realloc-zero-bytes-frees=yes|no [yes on Linux glibc, no otherwise] + * ==================== TOOL CHANGES =================== * Memcheck: @@ -50,6 +69,13 @@ AMD64/macOS 10.13 and nanoMIPS/Linux. the new loss records have a "new" marker. - Valgrind now contains python code that defines GDB memcheck front end monitor commands. See CORE CHANGES. + - Performs checks for the use of realloc with a size of zero. + This is non-portable and a source of errors. If memcheck + detects such a usage it will generate an error + realloc() with size 0 + followed by the usual callstacks. + A switch has been added to allow this to be turned off: + --show-realloc-size-zero=yes|no [yes] * Helgrind: - The option ---history-backtrace-size=<number> allows to configure diff --git a/coregrind/m_main.c b/coregrind/m_main.c index b5501b5f31..0a7d81389e 100644 --- a/coregrind/m_main.c +++ b/coregrind/m_main.c @@ -243,6 +243,10 @@ static void usage_NORETURN ( int need_help ) " attempt to avoid expensive address-space-resync operations\n" " --max-threads=<number> maximum number of threads that valgrind can\n" " handle [%d]\n" +" --realloc-zero-bytes-frees=yes|no [yes on Linux glibc, no otherwise]\n" +" should calls to realloc with a size of 0\n" +" free memory and return NULL or\n" +" allocate/resize and return non-NULL\n" "\n"; const HChar usage2[] = diff --git a/coregrind/m_replacemalloc/replacemalloc_core.c b/coregrind/m_replacemalloc/replacemalloc_core.c index 4b7d8ae609..6c86a8ce17 100644 --- a/coregrind/m_replacemalloc/replacemalloc_core.c +++ b/coregrind/m_replacemalloc/replacemalloc_core.c @@ -45,6 +45,11 @@ /* DEBUG: print malloc details? default: NO */ Bool VG_(clo_trace_malloc) = False; +#if defined(VGO_linux) && !defined(MUSL_LIBC) +Bool VG_(clo_realloc_zero_bytes_frees) = True; +#else +Bool VG_(clo_realloc_zero_bytes_frees) = False; +#endif /* Minimum alignment in functions that don't specify alignment explicitly. default: 0, i.e. use VG_MIN_MALLOC_SZB. */ @@ -75,6 +80,7 @@ Bool VG_(replacement_malloc_process_cmd_line_option)(const HChar* arg) VG_(clo_xtree_compress_strings)) {} else if VG_BOOL_CLO(arg, "--trace-malloc", VG_(clo_trace_malloc)) {} + else if VG_BOOL_CLO(arg, "--realloc-zero-bytes-frees", VG_(clo_realloc_zero_bytes_frees)) {} else return False; diff --git a/coregrind/m_replacemalloc/vg_replace_malloc.c b/coregrind/m_replacemalloc/vg_replace_malloc.c index 3379aa96f7..c46e719c94 100644 --- a/coregrind/m_replacemalloc/vg_replace_malloc.c +++ b/coregrind/m_replacemalloc/vg_replace_malloc.c @@ -1460,20 +1460,16 @@ extern int *___errno (void) __attribute__((weak)); void* v; \ \ DO_INIT; \ + TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED(ptrV); \ + TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED(new_size); \ MALLOC_TRACE("zone_realloc(%p,%p,%llu)", zone, ptrV, (ULong)new_size ); \ - \ - if (ptrV == NULL) \ - /* We need to call a malloc-like function; so let's use \ - one which we know exists. GrP fixme use zonemalloc instead? */ \ - return VG_REPLACE_FUNCTION_EZU(10010,VG_Z_LIBC_SONAME,malloc) \ - (new_size); \ - if (new_size <= 0) { \ - VG_REPLACE_FUNCTION_EZU(10050,VG_Z_LIBC_SONAME,free)(ptrV); \ - MALLOC_TRACE(" = 0\n"); \ - return NULL; \ - } \ v = (void*)VALGRIND_NON_SIMD_CALL2( info.tl_realloc, ptrV, new_size ); \ MALLOC_TRACE(" = %p\n", v ); \ + if (v == NULL) { \ + if (!(new_size == 0U && info.clo_realloc_zero_bytes_frees == True)) {\ + SET_ERRNO_ENOMEM; \ + } \ + } \ return v; \ } @@ -1487,21 +1483,16 @@ extern int *___errno (void) __attribute__((weak)); void* v; \ \ DO_INIT; \ + TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED(ptrV); \ + TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED(new_size); \ MALLOC_TRACE("realloc(%p,%llu)", ptrV, (ULong)new_size ); \ - \ - if (ptrV == NULL) \ - /* We need to call a malloc-like function; so let's use \ - one which we know exists. */ \ - return VG_REPLACE_FUNCTION_EZU(10010,VG_Z_LIBC_SONAME,malloc) \ - (new_size); \ - if (new_size <= 0) { \ - VG_REPLACE_FUNCTION_EZU(10050,VG_Z_LIBC_SONAME,free)(ptrV); \ - MALLOC_TRACE(" = 0\n"); \ - return NULL; \ - } \ v = (void*)VALGRIND_NON_SIMD_CALL2( info.tl_realloc, ptrV, new_size ); \ MALLOC_TRACE(" = %p\n", v ); \ - if (!v) SET_ERRNO_ENOMEM; \ + if (v == NULL) { \ + if (!(new_size == 0U && info.clo_realloc_zero_bytes_frees == True)) {\ + SET_ERRNO_ENOMEM; \ + } \ + } \ return v; \ } @@ -1514,24 +1505,17 @@ extern int *___errno (void) __attribute__((weak)); { \ void* v; \ \ - if (!init_done) init(); \ + DO_INIT; \ + TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED(ptrV); \ + TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED(new_size); \ MALLOC_TRACE("reallocf(%p,%llu)", ptrV, (ULong)new_size ); \ - \ - if (ptrV == NULL) \ - /* We need to call a malloc-like function; so let's use \ - one which we know exists. */ \ - return VG_REPLACE_FUNCTION_EZU(10010,VG_Z_LIBC_SONAME,malloc) \ - (new_size); \ - if (new_size == 0) { \ - VG_REPLACE_FUNCTION_EZU(10050,VG_Z_LIBC_SONAME,free)(ptrV); \ - MALLOC_TRACE(" = 0\n"); \ - return ptrV; \ - } \ v = (void*)VALGRIND_NON_SIMD_CALL2( info.tl_realloc, ptrV, new_size ); \ MALLOC_TRACE(" = %p\n", v ); \ - if (v == NULL) {\ - VG_REPLACE_FUNCTION_EZU(10050,VG_Z_LIBC_SONAME,free)(ptrV); \ - SET_ERRNO_ENOMEM; \ + if (v == NULL) { \ + if (!(new_size == 0U && info.clo_realloc_zero_bytes_frees == True)) {\ + VG_REPLACE_FUNCTION_EZU(10050,VG_Z_LIBC_SONAME,free)(ptrV); \ + SET_ERRNO_ENOMEM; \ + } \ } \ MALLOC_TRACE(" = %p\n", v ); \ return v; \ diff --git a/coregrind/m_scheduler/scheduler.c b/coregrind/m_scheduler/scheduler.c index 788018c3e9..3062c1afc3 100644 --- a/coregrind/m_scheduler/scheduler.c +++ b/coregrind/m_scheduler/scheduler.c @@ -2109,6 +2109,7 @@ void do_client_request ( ThreadId tid ) info->mallinfo = VG_(mallinfo); info->clo_trace_malloc = VG_(clo_trace_malloc); + info->clo_realloc_zero_bytes_frees = VG_(clo_realloc_zero_bytes_frees); SET_CLREQ_RETVAL( tid, 0 ); /* return value is meaningless */ diff --git a/coregrind/pub_core_replacemalloc.h b/coregrind/pub_core_replacemalloc.h index cbf7f8ecdd..bfd137a8b2 100644 --- a/coregrind/pub_core_replacemalloc.h +++ b/coregrind/pub_core_replacemalloc.h @@ -55,6 +55,7 @@ struct vg_mallocfunc_info { SizeT (*tl_malloc_usable_size) (ThreadId tid, void* payload); void (*mallinfo) (ThreadId tid, struct vg_mallinfo* mi); Bool clo_trace_malloc; + Bool clo_realloc_zero_bytes_frees; }; #endif // __PUB_CORE_REPLACEMALLOC_H diff --git a/dhat/dh_main.c b/dhat/dh_main.c index 6f15ae82e3..57d94237c5 100644 --- a/dhat/dh_main.c +++ b/dhat/dh_main.c @@ -818,8 +818,11 @@ static void* dh_realloc ( ThreadId tid, void* p_old, SizeT new_szB ) return dh_malloc(tid, new_szB); } if (new_szB == 0) { - dh_free(tid, p_old); - return NULL; + if (VG_(clo_realloc_zero_bytes_frees) == True) { + dh_free(tid, p_old); + return NULL; + } + new_szB = 1; } return renew_block(tid, p_old, new_szB); } diff --git a/docs/xml/manual-core.xml b/docs/xml/manual-core.xml index 3a91c930fa..20886fe49e 100644 --- a/docs/xml/manual-core.xml +++ b/docs/xml/manual-core.xml @@ -1787,6 +1787,24 @@ that can report errors, e.g. Memcheck, but not Cachegrind.</para> </listitem> </varlistentry> + <varlistentry id="opt.realloc-zero-bytes-frees" xreflabel="--realloc-zero-bytes-frees"> + <term> + <option><![CDATA[--realloc-zero-bytes-frees=yes|no [default: yes for glibc no otherwise] ]]></option> + </term> + <listitem> + <para>The behaviour of <computeroutput>realloc()</computeroutput> is + implementation defined (in C17, in C23 it is likely to become + undefined). Valgrind tries to work in the same way as the + underlying OS and C runtime library. However, if you use a + different C runtime library then this default may be wrong. + For instance, if you use Valgrind on Linux installed via a package + and use the musl C runtime or the JEMalloc library then + consider using + <computeroutput>--realloc-zero-bytes-frees=no</computeroutput>. + </para> + </listitem> + </varlistentry> + </variablelist> <!-- end of xi:include in the manpage --> diff --git a/drd/drd_malloc_wrappers.c b/drd/drd_malloc_wrappers.c index 991fb845a0..b1be605832 100644 --- a/drd/drd_malloc_wrappers.c +++ b/drd/drd_malloc_wrappers.c @@ -184,8 +184,12 @@ static void* drd_realloc(ThreadId tid, void* p_old, SizeT new_size) if (new_size == 0) { - drd_free(tid, p_old); - return NULL; + if (VG_(clo_realloc_zero_bytes_frees) == True) + { + drd_free(tid, p_old); + return NULL; + } + new_size = 1; } s_cmalloc_n_mallocs++; diff --git a/drd/tests/memory_allocation.c b/drd/tests/memory_allocation.c index d6d6388236..ec8578514d 100644 --- a/drd/tests/memory_allocation.c +++ b/drd/tests/memory_allocation.c @@ -25,13 +25,12 @@ int main() * glibc returns a NULL pointer when the size argument passed to realloc() * is zero, while Darwin's C library returns a non-NULL pointer. Both are * allowed by POSIX. + * + * Other platforms also tend not to free. To make things simpler just + * free it if it is not NULL. */ -#if defined(VGO_darwin) if (p) free(p); -#else - assert(! p); -#endif } return 0; diff --git a/helgrind/hg_main.c b/helgrind/hg_main.c index 26a37ead5e..cebc2bd2a1 100644 --- a/helgrind/hg_main.c +++ b/helgrind/hg_main.c @@ -4323,12 +4323,31 @@ static void* hg_cli__realloc ( ThreadId tid, void* payloadV, SizeT new_size ) if (((SSizeT)new_size) < 0) return NULL; + if (payloadV == NULL) { + return handle_alloc ( tid, new_size, VG_(clo_alignment), + /*is_zeroed*/False ); + } + md = (MallocMeta*) VG_(HT_lookup)( hg_mallocmeta_table, (UWord)payload ); if (!md) return NULL; /* apparently realloc-ing a bogus address. Oh well. */ tl_assert(md->payload == payload); + if (new_size == 0U ) { + if (VG_(clo_realloc_zero_bytes_frees) == True) { + md_tmp = VG_(HT_remove)( hg_mallocmeta_table, payload ); + tl_assert(md_tmp); + tl_assert(md_tmp == md); + + VG_(cli_free)((void*)md->payload); + delete_MallocMeta(md); + + return NULL; + } + new_size = 1U; + } + if (md->szB == new_size) { /* size unchanged */ md->where = VG_(record_ExeContext)(tid, 0); diff --git a/include/pub_tool_replacemalloc.h b/include/pub_tool_replacemalloc.h index f9f39b7d64..d59027f3e2 100644 --- a/include/pub_tool_replacemalloc.h +++ b/include/pub_tool_replacemalloc.h @@ -67,6 +67,8 @@ extern Bool VG_(clo_trace_malloc); /* Minimum alignment in functions that don't specify alignment explicitly. default: VG_MIN_MALLOC_SZB */ extern UInt VG_(clo_alignment); +/* Controls the behaviour of realloc(ptr, 0) */ +extern Bool VG_(clo_realloc_zero_bytes_frees); extern Bool VG_(replacement_malloc_process_cmd_line_option) ( const HChar* arg ); diff --git a/massif/ms_main.c b/massif/ms_main.c index 1ebbe4f29f..f3500c367d 100644 --- a/massif/ms_main.c +++ b/massif/ms_main.c @@ -1268,6 +1268,20 @@ void* realloc_block ( ThreadId tid, void* p_old, SizeT new_req_szB ) Xecu old_where; Bool is_ignored = False; + if (p_old == NULL) { + return alloc_and_record_block( tid, new_req_szB, VG_(clo_alignment), /*is_zeroed*/False ); + } + + if (new_req_szB == 0U) { + if (VG_(clo_realloc_zero_bytes_frees) == True) { + /* like ms_free */ + unrecord_block(p_old, /*maybe_snapshot*/True, /*exclude_first_entry*/True); + VG_(cli_free)(p_old); + return NULL; + } + new_req_szB = 1U; + } + // Remove the old block hc = VG_(HT_remove)(malloc_list, (UWord)p_old); if (hc == NULL) { diff --git a/massif/tests/realloc.post.exp b/massif/tests/realloc.post.exp index 779cfc16f7..c343c93b1b 100644 --- a/massif/tests/realloc.post.exp +++ b/massif/tests/realloc.post.exp @@ -1,6 +1,6 @@ -------------------------------------------------------------------------------- Command: ./realloc -Massif arguments: --stacks=no --heap-admin=0 --time-unit=B --threshold=0 --massif-out-file=massif.out --ignore-fn=__part_load_locale --ignore-fn=__time_load_locale --ignore-fn=dwarf2_unwind_dyld_add_image_hook --ignore-fn=get_or_create_key_element +Massif arguments: --stacks=no --heap-admin=0 --time-unit=B --threshold=0 --massif-out-file=massif.out --realloc-zero-bytes-frees=yes --ignore-fn=__part_load_locale --ignore-fn=__time_load_locale --ignore-fn=dwarf2_unwind_dyld_add_image_hook --ignore-fn=get_or_create_key_element ms_print arguments: --threshold=0 massif.out -------------------------------------------------------------------------------- diff --git a/massif/tests/realloc.vgtest b/massif/tests/realloc.vgtest index bdb38d839e..01e06f0853 100644 --- a/massif/tests/realloc.vgtest +++ b/massif/tests/realloc.vgtest @@ -1,5 +1,6 @@ prog: realloc -vgopts: -v -v --stats=yes --stacks=no --heap-admin=0 --time-unit=B --threshold=0 --massif-out-file=massif.out +# use --realloc-zero-bytes-frees=yes to get the same results on all platforms +vgopts: -v -v --stats=yes --stacks=no --heap-admin=0 --time-unit=B --threshold=0 --massif-out-file=massif.out --realloc-zero-bytes-frees=yes vgopts: --ignore-fn=__part_load_locale --ignore-fn=__time_load_locale --ignore-fn=dwarf2_unwind_dyld_add_image_hook --ignore-fn=get_or_create_key_element stderr_filter: filter_verbose post: perl ../../massif/ms_print --threshold=0 massif.out | ../../tests/filter_addresses diff --git a/memcheck/docs/mc-manual.xml b/memcheck/docs/mc-manual.xml index e8f48d112d..414c3a2393 100644 --- a/memcheck/docs/mc-manual.xml +++ b/memcheck/docs/mc-manual.xml @@ -51,6 +51,11 @@ problems that are common in C and C++ programs.</para> allocation function.</para> </listitem> + <listitem> + <para>Using a <computeroutput>size</computeroutput> value of 0 + with realloc.</para> + </listitem> + <listitem> <para>Memory leaks.</para> </listitem> @@ -431,6 +436,28 @@ as "silly arguments" and no back-trace was included. </sect2> +<sect2 id="mc-manual.realocsizezero" + xreflabel="Realloc size zero"> +<title>Realloc size zero</title> + +<para>The (ab)use or realloc to also do the job of <function>free</function> +has been poorly understood for a long time. In the C17 standard +ISO/IEC 9899:2017] the behaviour of realloc when the size argument +is zero is specified as implementation defined. Memcheck warns about +the non-portable use or realloc.</para> + +<para>For example:</para> +<programlisting><![CDATA[ +==77609== realloc() with size 0 +==77609== at 0x48502B8: realloc (vg_replace_malloc.c:1450) +==77609== by 0x201989: main (realloczero.c:8) +==77609== Address 0x5464040 is 0 bytes inside a block of size 4 alloc'd +==77609== at 0x484CBB4: malloc (vg_replace_malloc.c:397) +==77609== by 0x201978: main (realloczero.c:7) +]]></programlisting> + +</sect2> + <sect2 id="mc-manual.leaks" xreflabel="Memory leak detection"> <title>Memory leak detection</title> diff --git a/memcheck/mc_errors.c b/memcheck/mc_errors.c index ee5533a632..00d6ec301e 100644 --- a/memcheck/mc_errors.c +++ b/memcheck/mc_errors.c @@ -75,6 +75,7 @@ typedef Err_Leak, Err_IllegalMempool, Err_FishyValue, + Err_ReallocSizeZero, } MC_ErrorTag; @@ -159,6 +160,10 @@ struct _MC_Error { AddrInfo ai; } FreeMismatch; + struct { + AddrInfo ai; + } ReallocSizeZero; + // Call to strcpy, memcpy, etc, with overlapping blocks. struct { Addr src; // Source block @@ -714,6 +719,21 @@ void MC_(pp_Error) ( const Error* err ) } break; + case Err_ReallocSizeZero: + if (xml) { + emit( " <kind>ReallocSizeZero</kind>\n" ); + emit( " <what>realloc() with size 0</what>\n" ); + VG_(pp_ExeContext)( VG_(get_error_where)(err) ); + VG_(pp_addrinfo_mc)(VG_(get_error_address)(err), + &extra->Err.ReallocSizeZero.ai, False); + } else { + emit( "realloc() with size 0\n" ); + VG_(pp_ExeContext)( VG_(get_error_where)(err) ); + VG_(pp_addrinfo_mc)(VG_(get_error_address)(err), + &extra->Err.ReallocSizeZero.ai, False); + } + break; + default: VG_(printf)("Error:\n unknown Memcheck error code %d\n", VG_(get_error_kind)(err)); @@ -868,6 +888,15 @@ void MC_(record_freemismatch_error) ( ThreadId tid, MC_Chunk* mc ) &extra ); } +void MC_(record_realloc_size_zero) ( ThreadId tid, Addr a ) +{ + MC_Error extra; + tl_assert(VG_INVALID_THREADID != tid); + extra.Err.ReallocSizeZero.ai.tag = Addr_Undescribed; + VG_(maybe_record_error)( tid, Err_ReallocSizeZero, a, /*s*/NULL, &extra ); +} + + void MC_(record_illegal_mempool_error) ( ThreadId tid, Addr a ) { MC_Error extra; @@ -1231,6 +1260,10 @@ UInt MC_(update_Error_extra)( const Error* err ) &extra->Err.FreeMismatch.ai ); return sizeof(MC_Error); } + case Err_ReallocSizeZero: + describe_addr ( ep, VG_(get_error_address)(err), + &extra->Err.ReallocSizeZero.ai ); + return sizeof(MC_Error); default: VG_(tool_panic)("mc_update_extra: bad errkind"); } @@ -1324,6 +1357,7 @@ typedef LeakSupp, // Something to be suppressed in a leak check. MempoolSupp, // Memory pool suppression. FishyValueSupp,// Fishy value suppression. + ReallocSizeZeroSupp, // realloc size 0 suppression } MC_SuppKind; @@ -1354,6 +1388,7 @@ Bool MC_(is_recognised_suppression) ( const HChar* name, Supp* su ) else if (VG_STREQ(name, "Value16")) skind = Value16Supp; else if (VG_STREQ(name, "Value32")) skind = Value32Supp; else if (VG_STREQ(name, "FishyValue")) skind = FishyValueSupp; + else if (VG_STREQ(name, "ReallocZero")) skind = ReallocSizeZeroSupp; else return False; @@ -1531,6 +1566,11 @@ Bool MC_(error_matches_suppression) ( const Error* err, const Supp* su ) supp_extra->argument_name); } + case ReallocSizeZeroSupp: { + + return (ekind == Err_ReallocSizeZero); + } + default: VG_(printf)("Error:\n" " unknown suppression type %d\n", @@ -1543,18 +1583,19 @@ Bool MC_(error_matches_suppression) ( const Error* err, const Supp* su ) const HChar* MC_(get_error_name) ( const Error* err ) { switch (VG_(get_error_kind)(err)) { - case Err_RegParam: return "Param"; - case Err_MemParam: return "Param"; - case Err_User: return "User"; - case Err_FreeMismatch: return "Free"; - case Err_IllegalMempool: return "Mempool"; - case Err_Free: return "Free"; - case Err_Jump: return "Jump"; - case Err_CoreMem: return "CoreMem"; - case Err_Overlap: return "Overlap"; - case Err_Leak: return "Leak"; - case Err_Cond: return "Cond"; - case Err_FishyValue: return "FishyValue"; + case Err_RegParam: return "Param"; + case Err_MemParam: return "Param"; + case Err_User: return "User"; + case Err_FreeMismatch: return "Free"; + case Err_IllegalMempool: return "Mempool"; + case Err_Free: return "Free"; + case Err_Jump: return "Jump"; + case Err_CoreMem: return "CoreMem"; + case Err_Overlap: return "Overlap"; + case Err_Leak: return "Leak"; + case Err_Cond: return "Cond"; + case Err_FishyValue: return "FishyValue"; + case Err_ReallocSizeZero: return "ReallocZero"; case Err_Addr: { MC_Error* extra = VG_(get_error_extra)(err); switch ( extra->Err.Addr.szB ) { diff --git a/memcheck/mc_include.h b/memcheck/mc_include.h index 30d0affdb2..3c1b1a7cd4 100644 --- a/memcheck/mc_include.h +++ b/memcheck/mc_include.h @@ -555,6 +555,7 @@ void MC_(record_jump_error) ( ThreadId tid, Addr a ); void MC_(record_free_error) ( ThreadId tid, Addr a ); void MC_(record_illegal_mempool_error) ( ThreadId tid, Addr a ); void MC_(record_freemismatch_error) ( ThreadId tid, MC_Chunk* mc ); +void MC_(record_realloc_size_zero) ( ThreadId tid, Addr a ); void MC_(record_overlap_error) ( ThreadId tid, const HChar* function, Addr src, Addr dst, SizeT szB ); @@ -727,6 +728,9 @@ extern Int MC_(clo_mc_level); /* Should we show mismatched frees? Default: YES */ extern Bool MC_(clo_show_mismatched_frees); +/* Should we warn about deprecated realloc() of size 0 ? Default : YES */ +extern Bool MC_(clo_show_realloc_size_zero); + /* Indicates the level of detail for Vbit tracking through integer add, subtract, and some integer comparison operations. */ typedef diff --git a/memcheck/mc_main.c b/memcheck/mc_main.c index 8efd7cb40c..3619dd1f92 100644 --- a/memcheck/mc_main.c +++ b/memcheck/mc_main.c @@ -6064,6 +6064,7 @@ Int MC_(clo_free_fill) = -1; KeepStacktraces MC_(clo_keep_stacktraces) = KS_alloc_and_free; Int MC_(clo_mc_level) = 2; Bool MC_(clo_show_mismatched_frees) = True; +Bool MC_(clo_show_realloc_size_zero) = True; ExpensiveDefinednessChecks MC_(clo_expensive_definedness_checks) = EdcAUTO; @@ -6256,6 +6257,8 @@ static Bool mc_process_cmd_line_options(const HChar* arg) else if VG_BOOL_CLOM(cloPD, arg, "--show-mismatched-frees", MC_(clo_show_mismatched_frees)) {} + else if VG_BOOL_CLOM(cloPD, arg, "--show-realloc-size-zero", + MC_(clo_show_realloc_size_zero)) {} else if VG_XACT_CLO(arg, "--expensive-definedness-checks=no", MC_(clo_expensive_definedness_checks), EdcNO) {} @@ -6320,6 +6323,7 @@ static void mc_print_usage(void) " --keep-stacktraces=alloc|free|alloc-and-free|alloc-then-free|none\n" " stack trace(s) to keep for malloc'd/free'd areas [alloc-and-free]\n" " --show-mismatched-frees=no|yes show frees that don't match the allocator? [yes]\n" +" --show-realloc-size-zero=no|yes show realocs with a size of zero? [yes]\n" ); } diff --git a/memcheck/mc_malloc_wrappers.c b/memcheck/mc_malloc_wrappers.c index d6775bd1d3..87cf4d8f54 100644 --- a/memcheck/mc_malloc_wrappers.c +++ b/memcheck/mc_malloc_wrappers.c @@ -573,6 +573,25 @@ void* MC_(realloc) ( ThreadId tid, void* p_old, SizeT new_szB ) if (MC_(record_fishy_value_error)(tid, "realloc", "size", new_szB)) return NULL; + if (p_old == NULL) { + return MC_(new_block) ( tid, 0, new_szB, VG_(clo_alignment), + /*is_zeroed*/False, MC_AllocMalloc, MC_(malloc_list)); + } + + if (new_szB == 0U) { + if (MC_(clo_show_realloc_size_zero)) { + MC_(record_realloc_size_zero)(tid, (Addr)p_old); + } + + if (VG_(clo_realloc_zero_bytes_frees) == True) { + MC_(handle_free)( + tid, (Addr)p_old, MC_(Malloc_Redzone_SzB), MC_AllocMalloc ); + + return NULL; + } + new_szB = 1U; + } + cmalloc_n_frees ++; cmalloc_n_mallocs ++; cmalloc_bs_mallocd += (ULong)new_szB; diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am index a3b9332b53..7600981687 100644 --- a/memcheck/tests/Makefile.am +++ b/memcheck/tests/Makefile.am @@ -286,6 +286,21 @@ EXTRA_DIST = \ reach_thread_register.stderr.exp reach_thread_register.vgtest \ reach_thread_register.stderr.exp-mips32 \ reach_thread_register.stderr.exp-mips64 \ + realloc_size_zero.stderr.exp realloc_size_zero.stdout.exp-glibc \ + realloc_size_zero.stdout.exp-other \ + realloc_size_zero.vgtest \ + realloc_size_zero_yes.stderr.exp realloc_size_zero_yes.stdout.exp \ + realloc_size_zero_yes.vgtest \ + realloc_size_zero_no.stderr.exp realloc_size_zero_no.stdout.exp \ + realloc_size_zero_no.vgtest \ + realloc_size_zero_off.stderr.exp realloc_size_zero_off.stdout.exp \ + realloc_size_zero_off.vgtest \ + realloc_size_zero_mismatch.stderr.exp \ + realloc_size_zero_mismatch.stdout.exp \ + realloc_size_zero_mismatch.vgtest \ + realloc_size_zero_supp.stderr.exp realloc_size_zero_supp.stdout.exp \ + realloc_size_zero_supp.vgtest \ + realloc_size_zero.supp \ realloc1.stderr.exp realloc1.vgtest \ realloc2.stderr.exp realloc2.vgtest \ realloc3.stderr.exp realloc3.vgtest \ @@ -442,6 +457,7 @@ check_PROGRAMS = \ pipe pointer-trace \ posix_memalign \ post-syscall \ + realloc_size_zero realloc_size_zero_mismatch \ realloc1 realloc2 realloc3 \ recursive-merge \ resvn_stack \ @@ -636,6 +652,8 @@ partial_load_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_USE_AFTER_FREE@ reach_thread_register_CFLAGS = $(AM_CFLAGS) -O2 reach_thread_register_LDADD = -lpthread +realloc_size_zero_mismatch_SOURCES = realloc_size_zero_mismatch.cpp + resvn_stack_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_UNINITIALIZED@ sendmsg_CFLAGS = $(AM_CFLAGS) diff --git a/memcheck/tests/amd64-freebsd/reallocf.c b/memcheck/tests/amd64-freebsd/reallocf.c index 043d0d6d7a..04ab4ccfce 100644 --- a/memcheck/tests/amd64-freebsd/reallocf.c +++ b/memcheck/tests/amd64-freebsd/reallocf.c @@ -10,6 +10,7 @@ int main(void) pi = reallocf(pi, 10*sizeof(int)); VALGRIND_DO_ADDED_LEAK_CHECK; pi = reallocf(pi, 0); + free(pi); VALGRIND_DO_CHANGED_LEAK_CHECK; pi = NULL; pi = realloc(pi, 10*sizeof(int)); diff --git a/memcheck/tests/amd64-freebsd/reallocf.stderr.exp b/memcheck/tests/amd64-freebsd/reallocf.stderr.exp index b3e6658b78..4ec2f2ef01 100644 --- a/memcheck/tests/amd64-freebsd/reallocf.stderr.exp +++ b/memcheck/tests/amd64-freebsd/reallocf.stderr.exp @@ -10,6 +10,13 @@ LEAK SUMMARY: Reachable blocks (those to which a pointer was found) are not shown. To see them, rerun with: --leak-check=full --show-leak-kinds=all +realloc() with size 0 + at 0x........: reallocf (vg_replace_malloc.c:...) + by 0x........: main (reallocf.c:12) + Address 0x........ is 0 bytes inside a block of size 40 alloc'd + at 0x........: reallocf (vg_replace_malloc.c:...) + by 0x........: main (reallocf.c:10) + All heap blocks were freed -- no leaks are possible LEAK SUMMARY: @@ -26,9 +33,9 @@ All heap blocks were freed -- no leaks are possible HEAP SUMMARY: in use at exit: 0 bytes in 0 blocks - total heap usage: 3 allocs, 3 frees, 562,949,953,421,392 bytes allocated + total heap usage: 4 allocs, 4 frees, 562,949,953,421,393 bytes allocated For a detailed leak analysis, rerun with: --leak-check=full For lists of detected and suppressed errors, rerun with: -s -ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) +ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0) diff --git a/memcheck/tests/freebsd/static_allocs.stderr.exp b/memcheck/tests/freebsd/static_allocs.stderr.exp index 132976cbb6..b6e6d328d5 100644 --- a/memcheck/tests/freebsd/static_allocs.stderr.exp +++ b/memcheck/tests/freebsd/static_allocs.stderr.exp @@ -1,5 +1,15 @@ +realloc() with size 0 + at 0x........: reallocf (vg_replace_malloc.c:...) + by 0x........: main (static_allocs.c:36) + Address 0x........ is 0 bytes inside a block of size 160 alloc'd + at 0x........: calloc (vg_replace_malloc.c:...) + by 0x........: main (static_allocs.c:35) + +1 bytes in 1 blocks are definitely lost in loss record ... of ... + at 0x........: reallocf (vg_replace_malloc.c:...) + by 0x........: main (static_allocs.c:36) + 10 bytes in 1 blocks are definitely lost in loss record ... of ... - at 0x........: malloc (vg_replace_malloc.c:...) - by 0x........: realloc (vg_replace_malloc.c:...) + at 0x........: realloc (vg_replace_malloc.c:...) by 0x........: main (static_allocs.c:34) diff --git a/memcheck/tests/realloc_size_zero.c b/memcheck/tests/realloc_size_zero.c new file mode 100644 index 0000000000..afe2a76680 --- /dev/null +++ b/memcheck/tests/realloc_size_zero.c @@ -0,0 +1,39 @@ +#include <stdio.h> +#include <stdlib.h> +#include <errno.h> + +int main(void) +{ + int i; + char* p = malloc(1024); + p[0] = '\0'; + errno = 0; + p = realloc(p, 0); + if (p) { + printf("p not NULL after realloc 0\n"); + } else { + printf("p is NULL after realloc 0\n"); + } + if (errno) { + perror("realloc(something, 0):"); + } + if (p) { + free(p); + } + + errno = 0; + volatile void *ptr = NULL; + volatile size_t size = 0U; + char *p2 = realloc(ptr, size); + if (p2) { + printf("p2 not NULL after realloc 0\n"); + } else { + printf("p2 is NULL after realloc 0\n"); + } + if (errno) { + perror("realloc(NULL, 0):"); + } + if (p2) { + free(p2); + } +} diff --git a/memcheck/tests/realloc_size_zero.stderr.exp b/memcheck/tests/realloc_size_zero.stderr.exp new file mode 100644 index 0000000000..6204deecdd --- /dev/null +++ b/memcheck/tests/realloc_size_zero.stderr.exp @@ -0,0 +1,7 @@ +realloc() with size 0 + at 0x........: realloc (vg_replace_malloc.c:...) + by 0x........: main (realloc_size_zero.c:11) + Address 0x........ is 0 bytes inside a block of size 1,024 alloc'd + at 0x........: malloc (vg_replace_malloc.c:...) + by 0x........: main (realloc_size_zero.c:8) + diff --git a/memcheck/tests/realloc_size_zero.stdout.exp-glibc b/memcheck/tests/realloc_size_zero.stdout.exp-glibc new file mode 100644 index 0000000000..ed2bcf0cd4 --- /dev/null +++ b/memcheck/tests/realloc_size_zero.stdout.exp-glibc @@ -0,0 +1,2 @@ +p is NULL after realloc 0 +p2 not NULL after realloc 0 diff --git a/memcheck/tests/realloc_size_zero.stdout.exp-other b/memcheck/tests/realloc_size_zero.stdout.exp-other new file mode 100644 index 0000000000..103f1d5ebc --- /dev/null +++ b/memcheck/tests/realloc_size_zero.stdout.exp-other @@ -0,0 +1,2 @@ +p not NULL after realloc 0 +p2 not NULL after realloc 0 diff --git a/memcheck/tests/realloc_size_zero.supp b/memcheck/tests/realloc_size_zero.supp new file mode 100644 index 0000000000..42e5f8d811 --- /dev/null +++ b/memcheck/tests/realloc_size_zero.supp @@ -0,0 +1,7 @@ +{ + Test for realoc zero suppression + Memcheck:ReallocZero + fun:realloc + fun:main +} + diff --git a/memcheck/tests/realloc_size_zero.vgtest b/memcheck/tests/realloc_size_zero.vgtest new file mode 100644 index 0000000000..e39d9c0725 --- /dev/null +++ b/memcheck/tests/realloc_size_zero.vgtest @@ -0,0 +1,2 @@ +prog: realloc_size_zero +vgopts: -q diff --git a/memcheck/tests/realloc_size_zero_mismatch.cpp b/memcheck/tests/realloc_size_zero_mismatch.cpp new file mode 100644 index 0000000000..13d1e58832 --- /dev/null +++ b/memcheck/tests/realloc_size_zero_mismatch.cpp @@ -0,0 +1,41 @@ +#include <iostream> +#include <cstdlib> +#include <cerrno> + +using std::realloc; +using std::cout; +using std::perror; + +int main(void) +{ + char* p = new char[1024]; + p[0] = '\0'; + errno = 0; + // mismatch + p = static_cast<char *>(realloc(p, 0)); + if (p) { + cout << "p not nullptr after realloc 0\n"; + } else { + cout << "p is nullptr after realloc 0\n"; + } + if (errno) { + perror("realloc(something, 0):"); + } + // mismatch again + delete [] p; + + errno = 0; + volatile void *ptr = NULL; + volatile size_t size = 0U; + char *p2 = static_cast<char *>(realloc(const_cast<void*>(ptr), size)); + if (p2) { + cout << "p2 not nullptr after realloc 0\n"; + } else { + cout << "p2 is nullptr after realloc 0\n"; + } + if (errno) { + perror("realloc(NULL, 0):"); + } + // mismatch + delete [] p2; +} diff --git a/memcheck/tests/realloc_size_zero_mismatch.stderr.exp b/memcheck/tests/realloc_size_zero_mismatch.stderr.exp new file mode 100644 index 0000000000..f7c535574b --- /dev/null +++ b/memcheck/tests/realloc_size_zero_mismatch.stderr.exp @@ -0,0 +1,28 @@ +realloc() with size 0 + at 0x........: realloc (vg_replace_malloc.c:...) + by 0x........: main (realloc_size_zero_mismatch.cpp:15) + Address 0x........ is 0 bytes inside a block of size 1,024 alloc'd + at 0x........: ...operator new[]... (vg_replace_malloc.c:...) + by 0x........: main (realloc_size_zero_mismatch.cpp:11) + +Mismatched free() / delete / delete [] + at 0x........: realloc (vg_replace_malloc.c:...) + by 0x........: main (realloc_size_zero_mismatch.cpp:15) + Address 0x........ is 0 bytes inside a block of size 1,024 alloc'd + at 0x........: ...operator new[]... (vg_replace_malloc.c:...) + by 0x........: main (realloc_size_zero_mismatch.cpp:11) + +Mismatched free() / delete / delete [] + at 0x........: ...operator delete[]... (vg_replace_malloc.c:...) + by 0x........: main (realloc_size_zero_mismatch.cpp:25) + Address 0x........ is 0 bytes inside a block of size 1 alloc'd + at 0x........: realloc (vg_replace_malloc.c:...) + by 0x........: main (realloc_size_zero_mismatch.cpp:15) + +Mismatched free() / delete / delete [] + at 0x........: ...operator delete[]... (vg_replace_malloc.c:...) + by 0x........: main (realloc_size_zero_mismatch.cpp:40) + Address 0x........ is 0 bytes after a block of size 0 alloc'd + at 0x........: realloc (vg_replace_malloc.c:...) + by 0x........: main (realloc_size_zero_mismatch.cpp:30) + diff --git a/memcheck/tests/realloc_size_zero_mismatch.stdout.exp b/memcheck/tests/realloc_size_zero_mismatch.stdout.exp new file mode 100644 index 0000000000..60b2ebd9e6 --- /dev/null +++ b/memcheck/tests/realloc_size_zero_mismatch.stdout.exp @@ -0,0 +1,2 @@ +p not nullptr after realloc 0 +p2 not nullptr after realloc 0 diff --git a/memcheck/tests/realloc_size_zero_mismatch.vgtest b/memcheck/tests/realloc_size_zero_mismatch.vgtest new file mode 100644 index 0000000000..4aad69190e --- /dev/null +++ b/memcheck/tests/realloc_size_zero_mismatch.vgtest @@ -0,0 +1,2 @@ +prog: realloc_size_zero_mismatch +vgopts: -q --realloc-zero-bytes-frees=no diff --git a/memcheck/tests/realloc_size_zero_no.stderr.exp b/memcheck/tests/realloc_size_zero_no.stderr.exp new file mode 100644 index 0000000000..00ffada247 --- /dev/null +++ b/memcheck/tests/realloc_size_zero_no.stderr.exp @@ -0,0 +1,7 @@ +realloc() with size 0 + at 0x........: realloc (vg_replace_malloc.c:...) + ... + Address 0x........ is 0 bytes inside a block of size 1,024 alloc'd + at 0x........: malloc (vg_replace_malloc.c:...) + ... + diff --git a/memcheck/tests/realloc_size_zero_no.stdout.exp b/memcheck/tests/realloc_size_zero_no.stdout.exp new file mode 100644 index 0000000000..103f1d5ebc --- /dev/null +++ b/memcheck/tests/realloc_size_zero_no.stdout.exp @@ -0,0 +1,2 @@ +p not NULL after realloc 0 +p2 not NULL after realloc 0 diff --git a/memcheck/tests/realloc_size_zero_no.vgtest b/memcheck/tests/realloc_size_zero_no.vgtest new file mode 100644 index 0000000000..80bf9e53d6 --- /dev/null +++ b/memcheck/tests/realloc_size_zero_no.vgtest @@ -0,0 +1,2 @@ +prog: realloc_size_zero +vgopts: -q --realloc-zero-bytes-frees=no diff --git a/memcheck/tests/realloc_size_zero_off.stderr.exp b/memcheck/tests/realloc_size_zero_off.stderr.exp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/memcheck/tests/realloc_size_zero_off.stdout.exp b/memcheck/tests/realloc_size_zero_off.stdout.exp new file mode 100644 index 0000000000..103f1d5ebc --- /dev/null +++ b/memcheck/tests/realloc_size_zero_off.stdout.exp @@ -0,0 +1,2 @@ +p not NULL after realloc 0 +p2 not NULL after realloc 0 diff --git a/memcheck/tests/realloc_size_zero_off.vgtest b/memcheck/tests/realloc_size_zero_off.vgtest new file mode 100644 index 0000000000..a376ce755f --- /dev/null +++ b/memcheck/tests/realloc_size_zero_off.vgtest @@ -0,0 +1,2 @@ +prog: realloc_size_zero +vgopts: -q --realloc-zero-bytes-frees=no --show-realloc-size-zero=no diff --git a/memcheck/tests/realloc_size_zero_supp.stderr.exp b/memcheck/tests/realloc_size_zero_supp.stderr.exp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/memcheck/tests/realloc_size_zero_supp.stdout.exp b/memcheck/tests/realloc_size_zero_supp.stdout.exp new file mode 100644 index 0000000000..103f1d5ebc --- /dev/null +++ b/memcheck/tests/realloc_size_zero_supp.stdout.exp @@ -0,0 +1,2 @@ +p not NULL after realloc 0 +p2 not NULL after realloc 0 diff --git a/memcheck/tests/realloc_size_zero_supp.vgtest b/memcheck/tests/realloc_size_zero_supp.vgtest new file mode 100644 index 0000000000..ea8886deb1 --- /dev/null +++ b/memcheck/tests/realloc_size_zero_supp.vgtest @@ -0,0 +1,2 @@ +prog: realloc_size_zero +vgopts: -q --realloc-zero-bytes-frees=no --suppressions=realloc_size_zero.supp diff --git a/memcheck/tests/realloc_size_zero_yes.stderr.exp b/memcheck/tests/realloc_size_zero_yes.stderr.exp new file mode 100644 index 0000000000..00ffada247 --- /dev/null +++ b/memcheck/tests/realloc_size_zero_yes.stderr.exp @@ -0,0 +1,7 @@ +realloc() with size 0 + at 0x........: realloc (vg_replace_malloc.c:...) + ... + Address 0x........ is 0 bytes inside a block of size 1,024 alloc'd + at 0x........: malloc (vg_replace_malloc.c:...) + ... + diff --git a/memcheck/tests/realloc_size_zero_yes.stdout.exp b/memcheck/tests/realloc_size_zero_yes.stdout.exp new file mode 100644 index 0000000000..ed2bcf0cd4 --- /dev/null +++ b/memcheck/tests/realloc_size_zero_yes.stdout.exp @@ -0,0 +1,2 @@ +p is NULL after realloc 0 +p2 not NULL after realloc 0 diff --git a/memcheck/tests/realloc_size_zero_yes.vgtest b/memcheck/tests/realloc_size_zero_yes.vgtest new file mode 100644 index 0000000000..16310f2a95 --- /dev/null +++ b/memcheck/tests/realloc_size_zero_yes.vgtest @@ -0,0 +1,2 @@ +prog: realloc_size_zero +vgopts: -q --realloc-zero-bytes-frees=yes diff --git a/none/tests/cmdline1.stdout.exp b/none/tests/cmdline1.stdout.exp index c3e91bfcde..3b6c116094 100644 --- a/none/tests/cmdline1.stdout.exp +++ b/none/tests/cmdline1.stdout.exp @@ -154,6 +154,10 @@ usage: valgrind [options] prog-and-args attempt to avoid expensive address-space-resync operations --max-threads=<number> maximum number of threads that valgrind can handle [500] + --realloc-zero-bytes-frees=yes|no [yes on Linux glibc, no otherwise] + should calls to realloc with a size of 0 + free memory and return NULL or + allocate/resize and return non-NULL user options for Nulgrind: (none) diff --git a/none/tests/cmdline1.stdout.exp-non-linux b/none/tests/cmdline1.stdout.exp-non-linux index c0e71fa576..e67183efe4 100644 --- a/none/tests/cmdline1.stdout.exp-non-linux +++ b/none/tests/cmdline1.stdout.exp-non-linux @@ -152,6 +152,10 @@ usage: valgrind [options] prog-and-args attempt to avoid expensive address-space-resync operations --max-threads=<number> maximum number of threads that valgrind can handle [500] + --realloc-zero-bytes-frees=yes|no [yes on Linux glibc, no otherwise] + should calls to realloc with a size of 0 + free memory and return NULL or + allocate/resize and return non-NULL user options for Nulgrind: (none) diff --git a/none/tests/cmdline2.stdout.exp b/none/tests/cmdline2.stdout.exp index 3158c267a9..241d33afa5 100644 --- a/none/tests/cmdline2.stdout.exp +++ b/none/tests/cmdline2.stdout.exp @@ -154,6 +154,10 @@ usage: valgrind [options] prog-and-args attempt to avoid expensive address-space-resync operations --max-threads=<number> maximum number of threads that valgrind can handle [500] + --realloc-zero-bytes-frees=yes|no [yes on Linux glibc, no otherwise] + should calls to realloc with a size of 0 + free memory and return NULL or + allocate/resize and return non-NULL user options for Nulgrind: (none) diff --git a/none/tests/cmdline2.stdout.exp-non-linux b/none/tests/cmdline2.stdout.exp-non-linux index c19fa72597..63af17bf74 100644 --- a/none/tests/cmdline2.stdout.exp-non-linux +++ b/none/tests/cmdline2.stdout.exp-non-linux @@ -152,6 +152,10 @@ usage: valgrind [options] prog-and-args attempt to avoid expensive address-space-resync operations --max-threads=<number> maximum number of threads that valgrind can handle [500] + --realloc-zero-bytes-frees=yes|no [yes on Linux glibc, no otherwise] + should calls to realloc with a size of 0 + free memory and return NULL or + allocate/resize and return non-NULL user options for Nulgrind: (none) |
|
From: Paul F. <pa...@so...> - 2023-03-10 17:42:08
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=4af62304d95701ed110f4ba89c5a9ceeb0255393 commit 4af62304d95701ed110f4ba89c5a9ceeb0255393 Author: Paul Floyd <pj...@wa...> Date: Fri Mar 10 18:41:26 2023 +0100 Rename memcheck/tests/sized_aligned_new_delete_args.stderr.exp-glibc It's for GCC / libstdc++ really Diff: --- memcheck/tests/Makefile.am | 2 +- ...gs.stderr.exp-glibc => sized_aligned_new_delete_args.stderr.exp-gcc} | 0 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am index 70c0a46d58..a3b9332b53 100644 --- a/memcheck/tests/Makefile.am +++ b/memcheck/tests/Makefile.am @@ -142,7 +142,7 @@ EXTRA_DIST = \ sized_aligned_new_delete_args.stderr.exp \ sized_aligned_new_delete_args.vgtest \ sized_aligned_new_delete_args.stderr.exp_32 \ - sized_aligned_new_delete_args.stderr.exp-glibc \ + sized_aligned_new_delete_args.stderr.exp-gcc \ sized_aligned_new_delete_misaligned.stderr.exp \ sized_aligned_new_delete_misaligned.vgtest \ deep-backtrace.vgtest deep-backtrace.stderr.exp \ diff --git a/memcheck/tests/sized_aligned_new_delete_args.stderr.exp-glibc b/memcheck/tests/sized_aligned_new_delete_args.stderr.exp-gcc similarity index 100% rename from memcheck/tests/sized_aligned_new_delete_args.stderr.exp-glibc rename to memcheck/tests/sized_aligned_new_delete_args.stderr.exp-gcc |
|
From: Paul F. <pa...@so...> - 2023-03-10 17:40:10
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=c2a0cd6e11670a80975bb83a740a006233f58075 commit c2a0cd6e11670a80975bb83a740a006233f58075 Author: Paul Floyd <pj...@wa...> Date: Fri Mar 10 18:39:05 2023 +0100 darwin regtest: fix unused variable warning Copied and paster from old posix_memalign test Diff: --- memcheck/tests/darwin/aligned_alloc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/memcheck/tests/darwin/aligned_alloc.c b/memcheck/tests/darwin/aligned_alloc.c index f8d580538f..1c2fdb78cb 100644 --- a/memcheck/tests/darwin/aligned_alloc.c +++ b/memcheck/tests/darwin/aligned_alloc.c @@ -4,7 +4,6 @@ int main(void) { char* p = NULL; - int res; // zero size p = aligned_alloc(0, 8); |
|
From: Paul F. <pa...@so...> - 2023-03-10 07:42:30
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=28e4efb2b11afa79249fd72e49f20524e900e497 commit 28e4efb2b11afa79249fd72e49f20524e900e497 Author: Paul Floyd <pj...@wa...> Date: Fri Mar 10 08:40:40 2023 +0100 Mised one aligned alloc wrapper on Linux Need different expected for GCC / libstdc++ And I think that the 32bit expected will also need updating. Diff: --- coregrind/m_replacemalloc/vg_replace_malloc.c | 2 +- memcheck/tests/Makefile.am | 1 + .../sized_aligned_new_delete_args.stderr.exp-glibc | 80 ++++++++++++++++++++++ 3 files changed, 82 insertions(+), 1 deletion(-) diff --git a/coregrind/m_replacemalloc/vg_replace_malloc.c b/coregrind/m_replacemalloc/vg_replace_malloc.c index 8781645e85..3379aa96f7 100644 --- a/coregrind/m_replacemalloc/vg_replace_malloc.c +++ b/coregrind/m_replacemalloc/vg_replace_malloc.c @@ -1073,7 +1073,7 @@ extern int *___errno (void) __attribute__((weak)); DELETE_ALIGNED(VG_Z_LIBSTDCXX_SONAME, _ZdlPvSt11align_val_t, __builtin_delete_aligned ); DELETE_ALIGNED(VG_Z_LIBCXX_SONAME, _ZdlPvSt11align_val_t, __builtin_delete_aligned ); DELETE_ALIGNED(VG_Z_LIBC_SONAME, _ZdlPvSt11align_val_t, __builtin_delete_aligned ); - FREE(SO_SYN_MALLOC, _ZdlPvSt11align_val_t, __builtin_delete_aligned ); + DELETE_ALIGNED(SO_SYN_MALLOC, _ZdlPvSt11align_val_t, __builtin_delete_aligned ); // operator delete(void*, unsigned int, std::align_val_t), GNU mangling #if __SIZEOF_SIZE_T__ == 4 diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am index c9008ec5e7..70c0a46d58 100644 --- a/memcheck/tests/Makefile.am +++ b/memcheck/tests/Makefile.am @@ -142,6 +142,7 @@ EXTRA_DIST = \ sized_aligned_new_delete_args.stderr.exp \ sized_aligned_new_delete_args.vgtest \ sized_aligned_new_delete_args.stderr.exp_32 \ + sized_aligned_new_delete_args.stderr.exp-glibc \ sized_aligned_new_delete_misaligned.stderr.exp \ sized_aligned_new_delete_misaligned.vgtest \ deep-backtrace.vgtest deep-backtrace.stderr.exp \ diff --git a/memcheck/tests/sized_aligned_new_delete_args.stderr.exp-glibc b/memcheck/tests/sized_aligned_new_delete_args.stderr.exp-glibc new file mode 100644 index 0000000000..03eded9016 --- /dev/null +++ b/memcheck/tests/sized_aligned_new_delete_args.stderr.exp-glibc @@ -0,0 +1,80 @@ +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator new(unsigned long, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_args.cpp:16) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator new(unsigned long, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_args.cpp:16) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator delete(void*, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_args.cpp:17) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator new[](unsigned long, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_args.cpp:19) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator new[](unsigned long, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_args.cpp:19) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator delete[](void*, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_args.cpp:20) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator new(unsigned long, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_args.cpp:24) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator new(unsigned long, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_args.cpp:24) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator new(unsigned long, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_args.cpp:24) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator delete(void*, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_args.cpp:25) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator new[](unsigned long, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_args.cpp:27) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator new[](unsigned long, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_args.cpp:27) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator new[](unsigned long, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_args.cpp:27) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator delete[](void*, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_args.cpp:28) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: ...operator delete... (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_args.cpp:31) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator delete[](void*, unsigned long) (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_args.cpp:34) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator delete(void*, unsigned long, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_args.cpp:37) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator delete(void*, unsigned long, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_args.cpp:37) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator delete[](void*, unsigned long, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_args.cpp:40) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator delete[](void*, unsigned long, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_args.cpp:40) + |
|
From: Paul F. <pa...@so...> - 2023-03-09 19:59:59
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=f6ee38b419ee0e26e39fcf4a528ca60e3e5802d2 commit f6ee38b419ee0e26e39fcf4a528ca60e3e5802d2 Author: Paul Floyd <pj...@wa...> Date: Thu Mar 9 20:58:12 2023 +0100 Malloc replacements: add some C++14/17 comments Rearrange the code to group C++ 14 operator deeltes together. Diff: --- coregrind/m_replacemalloc/vg_replace_malloc.c | 124 +++++++++++++++++--------- 1 file changed, 80 insertions(+), 44 deletions(-) diff --git a/coregrind/m_replacemalloc/vg_replace_malloc.c b/coregrind/m_replacemalloc/vg_replace_malloc.c index 05bc9a4f61..8781645e85 100644 --- a/coregrind/m_replacemalloc/vg_replace_malloc.c +++ b/coregrind/m_replacemalloc/vg_replace_malloc.c @@ -114,6 +114,23 @@ mid-06: could be improved, since we can now intercept in the main executable too. + + 2023-03: + + There seem to be an ever increasing number of C++ new and delete + oveloads. + + See + https://en.cppreference.com/w/cpp/memory/new/operator_new + https://en.cppreference.com/w/cpp/memory/new/operator_delete + + We need to redirect the "replaceable" versions. + + Anything "user-defined" or "class-specific" we can't know + about and the user needs to use memory pool annotation. + + "non-alocating placement" as the name implies does not + allocate. Placement deletes are no-ops. */ @@ -938,6 +955,35 @@ extern int *___errno (void) __attribute__((weak)); /*---------------------- delete ----------------------*/ +#if defined(VGO_linux) + // operator delete(void*), not mangled (for gcc 2.96) + FREE(VG_Z_LIBSTDCXX_SONAME, __builtin_delete, __builtin_delete ); + FREE(VG_Z_LIBC_SONAME, __builtin_delete, __builtin_delete ); + // operator delete(void*), GNU mangling + FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPv, __builtin_delete ); + FREE(VG_Z_LIBCXX_SONAME, _ZdlPv, __builtin_delete ); + FREE(VG_Z_LIBC_SONAME, _ZdlPv, __builtin_delete ); + FREE(SO_SYN_MALLOC, _ZdlPv, __builtin_delete ); + +#elif defined(VGO_freebsd) + FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPv, __builtin_delete ); + FREE(VG_Z_LIBCXX_SONAME, _ZdlPv, __builtin_delete ); + FREE(SO_SYN_MALLOC, _ZdlPv, __builtin_delete ); + +#elif defined(VGO_darwin) + // operator delete(void*), GNU mangling + //FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPv, __builtin_delete ); + //FREE(VG_Z_LIBC_SONAME, _ZdlPv, __builtin_delete ); + +#elif defined(VGO_solaris) + // operator delete(void*), GNU mangling + FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPv, __builtin_delete ); + FREE(SO_SYN_MALLOC, _ZdlPv, __builtin_delete ); + +#endif + + /*------------------- C++14 delete sized -------------------*/ + #define DELETE_SIZED(soname, fnname, vg_replacement) \ \ void VG_REPLACE_FUNCTION_EZU(10050,soname,fnname) (void *p, SizeT size); \ @@ -952,21 +998,13 @@ extern int *___errno (void) __attribute__((weak)); } #if defined(VGO_linux) - // operator delete(void*), not mangled (for gcc 2.96) - FREE(VG_Z_LIBSTDCXX_SONAME, __builtin_delete, __builtin_delete ); - FREE(VG_Z_LIBC_SONAME, __builtin_delete, __builtin_delete ); - // operator delete(void*), GNU mangling - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPv, __builtin_delete ); - FREE(VG_Z_LIBCXX_SONAME, _ZdlPv, __builtin_delete ); - FREE(VG_Z_LIBC_SONAME, _ZdlPv, __builtin_delete ); - FREE(SO_SYN_MALLOC, _ZdlPv, __builtin_delete ); - // operator delete(void*, unsigned int), C++14, GNU mangling + // operator delete(void*, unsigned int) #if __SIZEOF_SIZE_T__ == 4 DELETE_SIZED(VG_Z_LIBSTDCXX_SONAME, _ZdlPvj, __builtin_delete ); DELETE_SIZED(VG_Z_LIBCXX_SONAME, _ZdlPvj, __builtin_delete ); DELETE_SIZED(VG_Z_LIBC_SONAME, _ZdlPvj, __builtin_delete ); DELETE_SIZED(SO_SYN_MALLOC, _ZdlPvj, __builtin_delete ); - // operator delete(void*, unsigned long), C++14, GNU mangling + // operator delete(void*, unsigned long) #elif __SIZEOF_SIZE_T__ == 8 DELETE_SIZED(VG_Z_LIBSTDCXX_SONAME, _ZdlPvm, __builtin_delete ); DELETE_SIZED(VG_Z_LIBCXX_SONAME, _ZdlPvm, __builtin_delete ); @@ -974,33 +1012,23 @@ extern int *___errno (void) __attribute__((weak)); DELETE_SIZED(SO_SYN_MALLOC, _ZdlPvm, __builtin_delete ); #endif - #elif defined(VGO_freebsd) - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPv, __builtin_delete ); - FREE(VG_Z_LIBCXX_SONAME, _ZdlPv, __builtin_delete ); - FREE(SO_SYN_MALLOC, _ZdlPv, __builtin_delete ); - // operator delete(void*, unsigned long), C++14, GNU mangling + // operator delete(void*, unsigned int) #if __SIZEOF_SIZE_T__ == 4 DELETE_SIZED(VG_Z_LIBSTDCXX_SONAME, _ZdlPvj, __builtin_delete ); DELETE_SIZED(VG_Z_LIBCXX_SONAME, _ZdlPvj, __builtin_delete ); DELETE_SIZED(SO_SYN_MALLOC, _ZdlPvj, __builtin_delete ); #elif __SIZEOF_SIZE_T__ == 8 + // operator delete(void*, unsigned long) DELETE_SIZED(VG_Z_LIBSTDCXX_SONAME, _ZdlPvm, __builtin_delete ); DELETE_SIZED(VG_Z_LIBCXX_SONAME, _ZdlPvm, __builtin_delete ); DELETE_SIZED(SO_SYN_MALLOC, _ZdlPvm, __builtin_delete ); #endif #elif defined(VGO_darwin) - // operator delete(void*), GNU mangling - //FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPv, __builtin_delete ); - //FREE(VG_Z_LIBC_SONAME, _ZdlPv, __builtin_delete ); #elif defined(VGO_solaris) - // operator delete(void*), GNU mangling - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPv, __builtin_delete ); - FREE(SO_SYN_MALLOC, _ZdlPv, __builtin_delete ); - - // operator delete(void*, unsigned long), C++14, GNU mangling + // operator delete(void*, unsigned long) #if __SIZEOF_SIZE_T__ == 4 DELETE_SIZED(VG_Z_LIBSTDCXX_SONAME, _ZdlPvj, __builtin_delete ); DELETE_SIZED(SO_SYN_MALLOC, _ZdlPvj, __builtin_delete ); @@ -1009,7 +1037,6 @@ extern int *___errno (void) __attribute__((weak)); DELETE_SIZED(SO_SYN_MALLOC, _ZdlPvm, __builtin_delete ); #endif - #endif /*------------------- C++17 delete aligned -------------------*/ @@ -1168,7 +1195,31 @@ extern int *___errno (void) __attribute__((weak)); FREE(VG_Z_LIBC_SONAME, _ZdaPv, __builtin_vec_delete ); FREE(SO_SYN_MALLOC, _ZdaPv, __builtin_vec_delete ); -// operator delete[](void*, unsigned long), C++14, GNU mangling +#elif defined(VGO_freebsd) + // operator delete[](void*), GNU mangling + FREE(VG_Z_LIBSTDCXX_SONAME, _ZdaPv, __builtin_vec_delete ); + FREE(VG_Z_LIBCXX_SONAME, _ZdaPv, __builtin_vec_delete ); + FREE(SO_SYN_MALLOC, _ZdaPv, __builtin_vec_delete ); + +#elif defined(VGO_darwin) + // operator delete[](void*), not mangled (for gcc 2.96) + //FREE(VG_Z_LIBSTDCXX_SONAME, __builtin_vec_delete, __builtin_vec_delete ); + //FREE(VG_Z_LIBC_SONAME, __builtin_vec_delete, __builtin_vec_delete ); + // operator delete[](void*), GNU mangling + //FREE(VG_Z_LIBSTDCXX_SONAME, _ZdaPv, __builtin_vec_delete ); + //FREE(VG_Z_LIBC_SONAME, _ZdaPv, __builtin_vec_delete ); + +#elif defined(VGO_solaris) + // operator delete[](void*), GNU mangling + FREE(VG_Z_LIBSTDCXX_SONAME, _ZdaPv, __builtin_vec_delete ); + FREE(SO_SYN_MALLOC, _ZdaPv, __builtin_vec_delete ); + +#endif + +/*---------------------- C++14 delete sized [] ----------------------*/ + +#if defined(VGO_linux) +// operator delete[](void*, unsigned int) #if __SIZEOF_SIZE_T__ == 4 DELETE_SIZED(VG_Z_LIBSTDCXX_SONAME, _ZdaPvj, __builtin_vec_delete ); DELETE_SIZED(VG_Z_LIBCXX_SONAME, _ZdaPvj, __builtin_vec_delete ); @@ -1183,11 +1234,7 @@ extern int *___errno (void) __attribute__((weak)); #endif #elif defined(VGO_freebsd) - // operator delete[](void*), GNU mangling - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdaPv, __builtin_vec_delete ); - FREE(VG_Z_LIBCXX_SONAME, _ZdaPv, __builtin_vec_delete ); - FREE(SO_SYN_MALLOC, _ZdaPv, __builtin_vec_delete ); - // operator delete[](void*, unsigned long), C++14, GNU mangling + // operator delete[](void*, unsigned int) #if __SIZEOF_SIZE_T__ == 4 DELETE_SIZED(VG_Z_LIBSTDCXX_SONAME, _ZdaPvj, __builtin_vec_delete ); DELETE_SIZED(VG_Z_LIBCXX_SONAME, _ZdaPvj, __builtin_vec_delete ); @@ -1199,23 +1246,13 @@ extern int *___errno (void) __attribute__((weak)); #endif #elif defined(VGO_darwin) - // operator delete[](void*), not mangled (for gcc 2.96) - //FREE(VG_Z_LIBSTDCXX_SONAME, __builtin_vec_delete, __builtin_vec_delete ); - //FREE(VG_Z_LIBC_SONAME, __builtin_vec_delete, __builtin_vec_delete ); - // operator delete[](void*), GNU mangling - //FREE(VG_Z_LIBSTDCXX_SONAME, _ZdaPv, __builtin_vec_delete ); - //FREE(VG_Z_LIBC_SONAME, _ZdaPv, __builtin_vec_delete ); #elif defined(VGO_solaris) - // operator delete[](void*), GNU mangling - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdaPv, __builtin_vec_delete ); - FREE(SO_SYN_MALLOC, _ZdaPv, __builtin_vec_delete ); - - // operator delete[](void*, unsigned int), C++14, GNU mangling + // operator delete[](void*, unsigned int) #if __SIZEOF_SIZE_T__ == 4 DELETE_SIZED(VG_Z_LIBSTDCXX_SONAME, _ZdaPvj, __builtin_vec_delete ); DELETE_SIZED(SO_SYN_MALLOC, _ZdaPvj, __builtin_vec_delete ); - // operator delete[](void*, unsigned long), C++14, GNU mangling + // operator delete[](void*, unsigned long) #elif __SIZEOF_SIZE_T__ == 8 DELETE_SIZED(VG_Z_LIBSTDCXX_SONAME, _ZdaPvm, __builtin_vec_delete ); DELETE_SIZED(SO_SYN_MALLOC, _ZdaPvm, __builtin_vec_delete ); @@ -1608,7 +1645,6 @@ extern int *___errno (void) __attribute__((weak)); #endif - #if defined(VGO_linux) && !defined(MUSL_LIBC) #define MEMALIGN(soname, fnname) \ @@ -1925,7 +1961,7 @@ extern int *___errno (void) __attribute__((weak)); * alignment is greater than MAX_ALIGN (whatever that is). * Wrapper function that just calls memalign * - * Darwin. Does enforce size bing an integer multiple of + * Darwin. Does enforce size being an integer multiple of * alignment. * */ |
|
From: Paul F. <pa...@so...> - 2023-03-09 07:31:57
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=294894459a3c02505bbfa47a4f0326faad44632b commit 294894459a3c02505bbfa47a4f0326faad44632b Author: Paul Floyd <pj...@wa...> Date: Thu Mar 9 08:31:12 2023 +0100 regtest: try to fix bad merge of memalign_args expected on ppc64 Diff: --- memcheck/tests/memalign_args.stderr.exp-ppc64 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/memcheck/tests/memalign_args.stderr.exp-ppc64 b/memcheck/tests/memalign_args.stderr.exp-ppc64 index 2e289e86e7..bc3c0aba46 100644 --- a/memcheck/tests/memalign_args.stderr.exp-ppc64 +++ b/memcheck/tests/memalign_args.stderr.exp-ppc64 @@ -6,6 +6,10 @@ Conditional jump or move depends on uninitialised value(s) at 0x........: memalign (vg_replace_malloc.c:...) by 0x........: main (memalign_args.c:19) +Conditional jump or move depends on uninitialised value(s) + at 0x........: memalign (vg_replace_malloc.c:...) + by 0x........: main (memalign_args.c:19) + Conditional jump or move depends on uninitialised value(s) at 0x........: posix_memalign (vg_replace_malloc.c:...) by 0x........: main (memalign_args.c:23) @@ -28,7 +32,7 @@ Conditional jump or move depends on uninitialised value(s) Conditional jump or move depends on uninitialised value(s) at 0x........: memalign (vg_replace_malloc.c:...) - by 0x........: main (memalign_args.c:23) + by 0x........: main (memalign_args.c:26) Conditional jump or move depends on uninitialised value(s) at 0x........: memalign (vg_replace_malloc.c:...) |
|
From: Paul F. <pa...@so...> - 2023-03-09 07:04:58
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=e29bf11d87f3cd35ce49418b4e6c7d1e6d480a47 commit e29bf11d87f3cd35ce49418b4e6c7d1e6d480a47 Author: Paul Floyd <pj...@wa...> Date: Thu Mar 9 08:02:19 2023 +0100 regtest: update sized_aligned_new_delete_args expected Don't quite understand how I managed to generate the original expected. Diff: --- memcheck/tests/sized_aligned_new_delete_args.stderr.exp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/memcheck/tests/sized_aligned_new_delete_args.stderr.exp b/memcheck/tests/sized_aligned_new_delete_args.stderr.exp index 27047ef810..f79314a9f4 100644 --- a/memcheck/tests/sized_aligned_new_delete_args.stderr.exp +++ b/memcheck/tests/sized_aligned_new_delete_args.stderr.exp @@ -6,6 +6,10 @@ Conditional jump or move depends on uninitialised value(s) at 0x........: operator new(unsigned long, std::align_val_t) (vg_replace_malloc.c:...) by 0x........: main (sized_aligned_new_delete_args.cpp:16) +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator delete(void*, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_args.cpp:17) + Conditional jump or move depends on uninitialised value(s) at 0x........: operator new[](unsigned long, std::align_val_t) (vg_replace_malloc.c:...) by 0x........: main (sized_aligned_new_delete_args.cpp:19) |
|
From: Paul F. <pa...@so...> - 2023-03-08 22:12:32
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=d4affb0ab725a59da786fee4b918b338eec615fe commit d4affb0ab725a59da786fee4b918b338eec615fe Author: Paul Floyd <pj...@wa...> Date: Wed Mar 8 23:10:22 2023 +0100 Make operator new aligned more like the standalone versions If the alignment is not a power of two return nullptr for the nothrow overload and bomb for the throwing overload. Diff: --- .gitignore | 1 + coregrind/m_replacemalloc/vg_replace_malloc.c | 20 +++-- memcheck/tests/Makefile.am | 7 +- .../tests/sized_aligned_new_delete_misaligned.cpp | 86 ++++++++++++++++++++++ .../sized_aligned_new_delete_misaligned.stderr.exp | 10 +++ .../sized_aligned_new_delete_misaligned.vgtest | 3 + 6 files changed, 120 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index a4c7b510ba..d5e341063e 100644 --- a/.gitignore +++ b/.gitignore @@ -962,6 +962,7 @@ /memcheck/tests/sh-mem /memcheck/tests/sh-mem-random /memcheck/tests/sized_aligned_new_delete_args +/memcheck/tests/sized_aligned_new_delete_misaligned /memcheck/tests/sigaltstack /memcheck/tests/sigkill /memcheck/tests/signal2 diff --git a/coregrind/m_replacemalloc/vg_replace_malloc.c b/coregrind/m_replacemalloc/vg_replace_malloc.c index 2b0879cd86..05bc9a4f61 100644 --- a/coregrind/m_replacemalloc/vg_replace_malloc.c +++ b/coregrind/m_replacemalloc/vg_replace_malloc.c @@ -294,13 +294,15 @@ extern int *___errno (void) __attribute__((weak)); TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED(n); \ MALLOC_TRACE(#fnname "(size %llu, al %llu)", (ULong)n, (ULong)alignment ); \ \ + if ((alignment == 0) \ + || ((alignment & (alignment - 1)) != 0)) { \ + return 0; \ + } \ + \ /* Round up to minimum alignment if necessary. */ \ if (alignment < VG_MIN_MALLOC_SZB) \ alignment = VG_MIN_MALLOC_SZB; \ \ - /* Round up to nearest power-of-two if necessary (like glibc). */ \ - while (0 != (alignment & (alignment - 1))) alignment++; \ - \ v = (void*)VALGRIND_NON_SIMD_CALL2( info.tl_##vg_replacement, n, alignment ); \ MALLOC_TRACE(" = %p\n", v ); \ if (!v) SET_ERRNO_ENOMEM; \ @@ -367,13 +369,19 @@ extern int *___errno (void) __attribute__((weak)); TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED(n); \ MALLOC_TRACE(#fnname "(size %llu, al %llu)", (ULong)n, (ULong)alignment ); \ \ + if ((alignment == 0) \ + || ((alignment & (alignment - 1)) != 0)) { \ + VALGRIND_PRINTF( \ + "new/new[] aligned failed and should throw an exception, but Valgrind\n"); \ + VALGRIND_PRINTF_BACKTRACE( \ + " cannot throw exceptions and so is aborting instead. Sorry.\n"); \ + my_exit(1); \ + } \ + \ /* Round up to minimum alignment if necessary. */ \ if (alignment < VG_MIN_MALLOC_SZB) \ alignment = VG_MIN_MALLOC_SZB; \ \ - /* Round up to nearest power-of-two if necessary (like glibc). */ \ - while (0 != (alignment & (alignment - 1))) alignment++; \ - \ v = (void*)VALGRIND_NON_SIMD_CALL2( info.tl_##vg_replacement, n, alignment ); \ MALLOC_TRACE(" = %p\n", v ); \ if (NULL == v) { \ diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am index 98cecb9ca2..c9008ec5e7 100644 --- a/memcheck/tests/Makefile.am +++ b/memcheck/tests/Makefile.am @@ -142,6 +142,8 @@ EXTRA_DIST = \ sized_aligned_new_delete_args.stderr.exp \ sized_aligned_new_delete_args.vgtest \ sized_aligned_new_delete_args.stderr.exp_32 \ + sized_aligned_new_delete_misaligned.stderr.exp \ + sized_aligned_new_delete_misaligned.vgtest \ deep-backtrace.vgtest deep-backtrace.stderr.exp \ demangle.stderr.exp demangle.vgtest \ big_debuginfo_symbol.stderr.exp big_debuginfo_symbol.vgtest \ @@ -489,7 +491,8 @@ cdebug_zlib_gnu_CFLAGS = $(AM_CFLAGS) -g -gz=zlib-gnu @FLAG_W_NO_UNINITIALIZED@ endif if HAVE_ALIGNED_CXX_ALLOC -check_PROGRAMS += cxx17_aligned_new sized_aligned_new_delete_args +check_PROGRAMS += cxx17_aligned_new sized_aligned_new_delete_args \ + sized_aligned_new_delete_misaligned endif if HAVE_PTHREAD_BARRIER @@ -552,6 +555,8 @@ cxx17_aligned_new_SOURCES = cxx17_aligned_new.cpp cxx17_aligned_new_CXXFLAGS = -std=c++17 @FLAG_W_NO_MISMATCHED_NEW_DELETE@ sized_aligned_new_delete_args_SOURCES = sized_aligned_new_delete_args.cpp sized_aligned_new_delete_args_CXXFLAGS = ${AM_CXXFLAGS} -std=c++17 +sized_aligned_new_delete_misaligned_SOURCES = sized_aligned_new_delete_misaligned.cpp +sized_aligned_new_delete_misaligned_CXXFLAGS = ${AM_CXXFLAGS} -std=c++17 endif demangle_SOURCES = demangle.cpp diff --git a/memcheck/tests/sized_aligned_new_delete_misaligned.cpp b/memcheck/tests/sized_aligned_new_delete_misaligned.cpp new file mode 100644 index 0000000000..647fa5a850 --- /dev/null +++ b/memcheck/tests/sized_aligned_new_delete_misaligned.cpp @@ -0,0 +1,86 @@ +#include <cstdlib> +#include <new> +#include <iostream> +#include <cassert> +#include <cstdio> +#include <unistd.h> +#include <sys/types.h> +#include <sys/wait.h> +#include "valgrind.h" + +int main() { + std::align_val_t misalign(static_cast<std::align_val_t>(63U)); + std::align_val_t zeroalign(static_cast<std::align_val_t>(0U)); + std::align_val_t onealign(static_cast<std::align_val_t>(1U)); + std::align_val_t align(static_cast<std::align_val_t>(64U)); + size_t size(32); + std::nothrow_t tag; + void *mem = nullptr; + + // libc++ will allocate something for size zero + // but libstdc++ doesn't + mem = operator new(size, zeroalign, tag); + if (RUNNING_ON_VALGRIND) { + assert(!mem); + } + operator delete(mem, zeroalign, tag); + mem = nullptr; + + mem = operator new(size, onealign, tag); + assert(mem); + operator delete(mem, onealign, tag); + mem = nullptr; + + mem = operator new(size, align); + operator delete(mem, misalign); + mem = nullptr; + + mem = operator new[](size, align); + operator delete[](mem, misalign); + mem = nullptr; + + // doesn't matter that tag is uninit + // don't want to see an error + mem = operator new(size, misalign, tag); + operator delete(mem, misalign, tag); + assert(!mem); + + mem = operator new[](size, misalign, tag); + operator delete[](mem, misalign, tag); + assert(!mem); + + mem = operator new(size, align); + operator delete(mem, size, misalign); + mem = nullptr; + + mem = operator new[](size, align); + operator delete[](mem, size, misalign); + + // the last two throw exceptions in C++ + int pid; + int status; + pid = fork(); + if (pid == -1) { + perror("fork"); + exit(1); + } + if (pid == 0) { + // child + mem = operator new(size, misalign); + // should throw + assert(false); + } + waitpid(pid, &status, 0); + pid = fork(); + if (pid == -1) { + perror("fork"); + exit(1); + } + if (pid == 0) { + // child + mem = operator new[](size, misalign); + // should throw + assert(false); + } + waitpid(pid, &status, 0); +} diff --git a/memcheck/tests/sized_aligned_new_delete_misaligned.stderr.exp b/memcheck/tests/sized_aligned_new_delete_misaligned.stderr.exp new file mode 100644 index 0000000000..afbd817bad --- /dev/null +++ b/memcheck/tests/sized_aligned_new_delete_misaligned.stderr.exp @@ -0,0 +1,10 @@ +new/new[] aligned failed and should throw an exception, but Valgrind + cannot throw exceptions and so is aborting instead. Sorry. + ... + by 0x........: operator new(unsigned long, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_misaligned.cpp:69) +new/new[] aligned failed and should throw an exception, but Valgrind + cannot throw exceptions and so is aborting instead. Sorry. + ... + by 0x........: operator new[](unsigned long, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_misaligned.cpp:81) diff --git a/memcheck/tests/sized_aligned_new_delete_misaligned.vgtest b/memcheck/tests/sized_aligned_new_delete_misaligned.vgtest new file mode 100644 index 0000000000..fc7b6f4712 --- /dev/null +++ b/memcheck/tests/sized_aligned_new_delete_misaligned.vgtest @@ -0,0 +1,3 @@ +prog: sized_aligned_new_delete_misaligned +prereq: test -e ./sized_aligned_new_delete_misaligned +vgopts: -q |
|
From: Paul F. <pa...@so...> - 2023-03-08 20:34:58
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=bb5e8df5604214b690ab39445014bfb284450b00 commit bb5e8df5604214b690ab39445014bfb284450b00 Author: Paul Floyd <pj...@wa...> Date: Wed Mar 8 21:33:36 2023 +0100 regtest: add an arm expected for memalign_args Diff: --- memcheck/tests/Makefile.am | 1 + memcheck/tests/memalign_args.stderr.exp-arm | 40 +++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am index 72d56cfa48..98cecb9ca2 100644 --- a/memcheck/tests/Makefile.am +++ b/memcheck/tests/Makefile.am @@ -223,6 +223,7 @@ EXTRA_DIST = \ memalign_args.vgtest memalign_args.stderr.exp \ memalign_args.stderr.exp-glibc \ memalign_args.stderr.exp-ppc64 \ + memalign_args.stderr.exp-arm \ memcmptest.stderr.exp memcmptest.stderr.exp2 \ memcmptest.stdout.exp memcmptest.vgtest \ memmem.stderr.exp memmem.vgtest \ diff --git a/memcheck/tests/memalign_args.stderr.exp-arm b/memcheck/tests/memalign_args.stderr.exp-arm new file mode 100644 index 0000000000..093accfb7e --- /dev/null +++ b/memcheck/tests/memalign_args.stderr.exp-arm @@ -0,0 +1,40 @@ +Conditional jump or move depends on uninitialised value(s) + at 0x........: memalign (vg_replace_malloc.c:...) + by 0x........: main (memalign_args.c:19) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: memalign (vg_replace_malloc.c:...) + by 0x........: main (memalign_args.c:19) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: memalign (vg_replace_malloc.c:...) + by 0x........: main (memalign_args.c:19) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: posix_memalign (vg_replace_malloc.c:...) + by 0x........: main (memalign_args.c:23) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: posix_memalign (vg_replace_malloc.c:...) + by 0x........: main (memalign_args.c:23) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: posix_memalign (vg_replace_malloc.c:...) + by 0x........: main (memalign_args.c:23) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: memalign (vg_replace_malloc.c:...) + by 0x........: main (memalign_args.c:26) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: memalign (vg_replace_malloc.c:...) + by 0x........: main (memalign_args.c:26) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: memalign (vg_replace_malloc.c:...) + by 0x........: main (memalign_args.c:26) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: valloc (vg_replace_malloc.c:...) + by 0x........: main (memalign_args.c:29) + |
|
From: Mark W. <ma...@kl...> - 2023-03-08 11:04:52
|
Sourceware infrastructure community updates for Q1 2023. = New cgit setup gitweb has been working out pretty nicely for many years, but cgit is cgit is nicer looking, has easier to understand URLs and is much faster. The first experimental setup can be found here: https://cygwin.com/cgit/ https://gcc.gnu.org/cgit/ https://sourceware.org/cgit/ Thanks to Jon Turney for the cygwin work. If this works out, we would like to deploy a script written by Arsen Arsenović to switch the main /git/ to cgit while keeping all old gitweb URLs working. See https://sourceware.org/bugzilla/show_bug.cgi?id=29769 = New sparc builder for builder.sourceware.org Thanks to the Gentoo Foundation and OSUOSL [*] there is now a large (and small) gentoo-sparc worker: https://builder.sourceware.org/buildbot/#/workers/35 https://builder.sourceware.org/buildbot/#/workers/36 Please contact the buildbot mailinglis if you want to do specific builds on it: https://sourceware.org/mailman/listinfo/buildbot = AI comes to the bunsen test results It isn't a large language model chatbot, but probably more useful. https://builder.sourceware.org/testruns/ will now predict what it believes the the dejagnu test results should be. It will give a score for what it expected a result to be. e.g for a new FAIL it could say: mispredicted PASS 81% which means in 81% of similar test runs that test PASSed. So you can concentrate on those FAILing tests that have a high PASSing score. For more info see: https://inbox.sourceware.org/buildbot/202...@re.../ = openssh update produces misleading invalid key length warning Connecting to sourceware through ssh with a newer openssh or crypto policy might produce a misleading warning about the key length being too short: Bad server host key: Invalid key length Please don't try to replace your ssh key, there is nothing wrong with it. The issue is that you might have an old server key in your ~/.ssh/known_hosts file. Simply remove it and reconnect to get the new server key: ssh-keygen -R sourceware.org ssh-keygen -R cygwin.com ssh-keygen -R gcc.gnu.org See also https://bugzilla.redhat.com/show_bug.cgi?id=2164016 = inbox.sourceware.org and '/' in Message-ID Those using public-inbox might have noticed that when a Message-ID contains a slash character '/' it is not always correctly encoded or decoded as %2F in the inbox.sourceware.org path URLs. If you are using a newer mutt as email client then you might want to make sure that your Message-ID doesn't contain any characters that might need URL encoding. For mutt 2.2 you might want to set the following in your ~/.muttrc to produce a uuid-like Message-ID as other email clients do: set message_id_format="<%x%x%x%x-%x%x-%x%x-%x%x-%x%x%x%x%x%x@%f>" For older mutt, and some more background, see: https://people.kernel.org/monsieuricon/fix-your-mutt = Happy hacking And as always please feel free join the overseers mailinglist https://sourceware.org/mailman/listinfo/overseers file infrastructure issues in bugzilla https://sourceware.org/bugzilla/describecomponents.cgi?product=sourceware or join us in #overseers on irc.libera.chat [*] But specifically Sam James. We should also thank the following other individuals and organisations for maintaining and/or providing hardware for builder.sourceware.org Brno University, Dan Horák, Marist University, Thomas Fitzsimmons, Mark Wielaard, Frank Eigler, IBM, Carl Love, The Works on Arm initiative, Christophe Lyon, and Red Hat |
|
From: Paul F. <pa...@so...> - 2023-03-08 08:00:54
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=a7d86da0f6f35e0f613158a5be9d2c0f741b36ae commit a7d86da0f6f35e0f613158a5be9d2c0f741b36ae Author: Paul Floyd <pj...@wa...> Date: Wed Mar 8 08:59:38 2023 +0100 regtest: fix warning in memalign_args and add debug info to sized_aligned_new_delete_args Diff: --- memcheck/tests/Makefile.am | 2 +- memcheck/tests/memalign_args.c | 3 ++ memcheck/tests/memalign_args.stderr.exp | 16 ++++----- memcheck/tests/memalign_args.stderr.exp-glibc | 16 ++++----- memcheck/tests/memalign_args.stderr.exp-ppc64 | 22 +++++-------- .../tests/sized_aligned_new_delete_args.stderr.exp | 38 ++++++++++------------ 6 files changed, 46 insertions(+), 51 deletions(-) diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am index e6afff0d00..72d56cfa48 100644 --- a/memcheck/tests/Makefile.am +++ b/memcheck/tests/Makefile.am @@ -550,7 +550,7 @@ if HAVE_ALIGNED_CXX_ALLOC cxx17_aligned_new_SOURCES = cxx17_aligned_new.cpp cxx17_aligned_new_CXXFLAGS = -std=c++17 @FLAG_W_NO_MISMATCHED_NEW_DELETE@ sized_aligned_new_delete_args_SOURCES = sized_aligned_new_delete_args.cpp -sized_aligned_new_delete_args_CXXFLAGS = -std=c++17 +sized_aligned_new_delete_args_CXXFLAGS = ${AM_CXXFLAGS} -std=c++17 endif demangle_SOURCES = demangle.cpp diff --git a/memcheck/tests/memalign_args.c b/memcheck/tests/memalign_args.c index aadae8d9f0..0946a6ce98 100644 --- a/memcheck/tests/memalign_args.c +++ b/memcheck/tests/memalign_args.c @@ -1,5 +1,8 @@ #include <stdlib.h> #include <unistd.h> +#if !defined(VGO_darwin) +#include <malloc.h> +#endif #include "../../config.h" #include "../memcheck.h" diff --git a/memcheck/tests/memalign_args.stderr.exp b/memcheck/tests/memalign_args.stderr.exp index 9cf48891d6..65e6122005 100644 --- a/memcheck/tests/memalign_args.stderr.exp +++ b/memcheck/tests/memalign_args.stderr.exp @@ -1,32 +1,32 @@ Conditional jump or move depends on uninitialised value(s) at 0x........: memalign (vg_replace_malloc.c:...) - by 0x........: main (memalign_args.c:16) + by 0x........: main (memalign_args.c:19) Conditional jump or move depends on uninitialised value(s) at 0x........: memalign (vg_replace_malloc.c:...) - by 0x........: main (memalign_args.c:16) + by 0x........: main (memalign_args.c:19) Conditional jump or move depends on uninitialised value(s) at 0x........: posix_memalign (vg_replace_malloc.c:...) - by 0x........: main (memalign_args.c:20) + by 0x........: main (memalign_args.c:23) Conditional jump or move depends on uninitialised value(s) at 0x........: posix_memalign (vg_replace_malloc.c:...) - by 0x........: main (memalign_args.c:20) + by 0x........: main (memalign_args.c:23) Conditional jump or move depends on uninitialised value(s) at 0x........: posix_memalign (vg_replace_malloc.c:...) - by 0x........: main (memalign_args.c:20) + by 0x........: main (memalign_args.c:23) Conditional jump or move depends on uninitialised value(s) at 0x........: aligned_alloc (vg_replace_malloc.c:...) - by 0x........: main (memalign_args.c:23) + by 0x........: main (memalign_args.c:26) Conditional jump or move depends on uninitialised value(s) at 0x........: aligned_alloc (vg_replace_malloc.c:...) - by 0x........: main (memalign_args.c:23) + by 0x........: main (memalign_args.c:26) Conditional jump or move depends on uninitialised value(s) at 0x........: valloc (vg_replace_malloc.c:...) - by 0x........: main (memalign_args.c:26) + by 0x........: main (memalign_args.c:29) diff --git a/memcheck/tests/memalign_args.stderr.exp-glibc b/memcheck/tests/memalign_args.stderr.exp-glibc index d03b196826..0261a8b930 100644 --- a/memcheck/tests/memalign_args.stderr.exp-glibc +++ b/memcheck/tests/memalign_args.stderr.exp-glibc @@ -1,32 +1,32 @@ Conditional jump or move depends on uninitialised value(s) at 0x........: memalign (vg_replace_malloc.c:...) - by 0x........: main (memalign_args.c:16) + by 0x........: main (memalign_args.c:19) Conditional jump or move depends on uninitialised value(s) at 0x........: memalign (vg_replace_malloc.c:...) - by 0x........: main (memalign_args.c:16) + by 0x........: main (memalign_args.c:19) Conditional jump or move depends on uninitialised value(s) at 0x........: posix_memalign (vg_replace_malloc.c:...) - by 0x........: main (memalign_args.c:20) + by 0x........: main (memalign_args.c:23) Conditional jump or move depends on uninitialised value(s) at 0x........: posix_memalign (vg_replace_malloc.c:...) - by 0x........: main (memalign_args.c:20) + by 0x........: main (memalign_args.c:23) Conditional jump or move depends on uninitialised value(s) at 0x........: posix_memalign (vg_replace_malloc.c:...) - by 0x........: main (memalign_args.c:20) + by 0x........: main (memalign_args.c:23) Conditional jump or move depends on uninitialised value(s) at 0x........: memalign (vg_replace_malloc.c:...) - by 0x........: main (memalign_args.c:23) + by 0x........: main (memalign_args.c:26) Conditional jump or move depends on uninitialised value(s) at 0x........: memalign (vg_replace_malloc.c:...) - by 0x........: main (memalign_args.c:23) + by 0x........: main (memalign_args.c:26) Conditional jump or move depends on uninitialised value(s) at 0x........: valloc (vg_replace_malloc.c:...) - by 0x........: main (memalign_args.c:26) + by 0x........: main (memalign_args.c:29) diff --git a/memcheck/tests/memalign_args.stderr.exp-ppc64 b/memcheck/tests/memalign_args.stderr.exp-ppc64 index 72125a1fbc..2e289e86e7 100644 --- a/memcheck/tests/memalign_args.stderr.exp-ppc64 +++ b/memcheck/tests/memalign_args.stderr.exp-ppc64 @@ -1,34 +1,30 @@ Conditional jump or move depends on uninitialised value(s) at 0x........: memalign (vg_replace_malloc.c:...) - by 0x........: main (memalign_args.c:16) + by 0x........: main (memalign_args.c:19) Conditional jump or move depends on uninitialised value(s) at 0x........: memalign (vg_replace_malloc.c:...) - by 0x........: main (memalign_args.c:16) - -Conditional jump or move depends on uninitialised value(s) - at 0x........: memalign (vg_replace_malloc.c:...) - by 0x........: main (memalign_args.c:16) + by 0x........: main (memalign_args.c:19) Conditional jump or move depends on uninitialised value(s) at 0x........: posix_memalign (vg_replace_malloc.c:...) - by 0x........: main (memalign_args.c:20) + by 0x........: main (memalign_args.c:23) Conditional jump or move depends on uninitialised value(s) at 0x........: posix_memalign (vg_replace_malloc.c:...) - by 0x........: main (memalign_args.c:20) + by 0x........: main (memalign_args.c:23) Conditional jump or move depends on uninitialised value(s) at 0x........: posix_memalign (vg_replace_malloc.c:...) - by 0x........: main (memalign_args.c:20) + by 0x........: main (memalign_args.c:23) Conditional jump or move depends on uninitialised value(s) at 0x........: posix_memalign (vg_replace_malloc.c:...) - by 0x........: main (memalign_args.c:20) + by 0x........: main (memalign_args.c:23) Conditional jump or move depends on uninitialised value(s) at 0x........: memalign (vg_replace_malloc.c:...) - by 0x........: main (memalign_args.c:23) + by 0x........: main (memalign_args.c:26) Conditional jump or move depends on uninitialised value(s) at 0x........: memalign (vg_replace_malloc.c:...) @@ -36,9 +32,9 @@ Conditional jump or move depends on uninitialised value(s) Conditional jump or move depends on uninitialised value(s) at 0x........: memalign (vg_replace_malloc.c:...) - by 0x........: main (memalign_args.c:23) + by 0x........: main (memalign_args.c:26) Conditional jump or move depends on uninitialised value(s) at 0x........: valloc (vg_replace_malloc.c:...) - by 0x........: main (memalign_args.c:26) + by 0x........: main (memalign_args.c:29) diff --git a/memcheck/tests/sized_aligned_new_delete_args.stderr.exp b/memcheck/tests/sized_aligned_new_delete_args.stderr.exp index a4c30dc4bd..27047ef810 100644 --- a/memcheck/tests/sized_aligned_new_delete_args.stderr.exp +++ b/memcheck/tests/sized_aligned_new_delete_args.stderr.exp @@ -1,72 +1,68 @@ Conditional jump or move depends on uninitialised value(s) at 0x........: operator new(unsigned long, std::align_val_t) (vg_replace_malloc.c:...) - by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args) + by 0x........: main (sized_aligned_new_delete_args.cpp:16) Conditional jump or move depends on uninitialised value(s) at 0x........: operator new(unsigned long, std::align_val_t) (vg_replace_malloc.c:...) - by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args) - -Conditional jump or move depends on uninitialised value(s) - at 0x........: operator delete(void*, std::align_val_t) (vg_replace_malloc.c:...) - by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args) + by 0x........: main (sized_aligned_new_delete_args.cpp:16) Conditional jump or move depends on uninitialised value(s) at 0x........: operator new[](unsigned long, std::align_val_t) (vg_replace_malloc.c:...) - by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args) + by 0x........: main (sized_aligned_new_delete_args.cpp:19) Conditional jump or move depends on uninitialised value(s) at 0x........: operator new[](unsigned long, std::align_val_t) (vg_replace_malloc.c:...) - by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args) + by 0x........: main (sized_aligned_new_delete_args.cpp:19) Conditional jump or move depends on uninitialised value(s) at 0x........: operator delete[](void*, std::align_val_t) (vg_replace_malloc.c:...) - by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args) + by 0x........: main (sized_aligned_new_delete_args.cpp:20) Conditional jump or move depends on uninitialised value(s) at 0x........: operator new(unsigned long, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...) - by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args) + by 0x........: main (sized_aligned_new_delete_args.cpp:24) Conditional jump or move depends on uninitialised value(s) at 0x........: operator new(unsigned long, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...) - by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args) + by 0x........: main (sized_aligned_new_delete_args.cpp:24) Conditional jump or move depends on uninitialised value(s) at 0x........: operator delete(void*, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...) - by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args) + by 0x........: main (sized_aligned_new_delete_args.cpp:25) Conditional jump or move depends on uninitialised value(s) at 0x........: operator new[](unsigned long, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...) - by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args) + by 0x........: main (sized_aligned_new_delete_args.cpp:27) Conditional jump or move depends on uninitialised value(s) at 0x........: operator new[](unsigned long, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...) - by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args) + by 0x........: main (sized_aligned_new_delete_args.cpp:27) Conditional jump or move depends on uninitialised value(s) at 0x........: operator delete[](void*, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...) - by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args) + by 0x........: main (sized_aligned_new_delete_args.cpp:28) Conditional jump or move depends on uninitialised value(s) at 0x........: ...operator delete... (vg_replace_malloc.c:...) - by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args) + by 0x........: main (sized_aligned_new_delete_args.cpp:31) Conditional jump or move depends on uninitialised value(s) at 0x........: operator delete[](void*, unsigned long) (vg_replace_malloc.c:...) - by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args) + by 0x........: main (sized_aligned_new_delete_args.cpp:34) Conditional jump or move depends on uninitialised value(s) at 0x........: operator delete(void*, unsigned long, std::align_val_t) (vg_replace_malloc.c:...) - by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args) + by 0x........: main (sized_aligned_new_delete_args.cpp:37) Conditional jump or move depends on uninitialised value(s) at 0x........: operator delete(void*, unsigned long, std::align_val_t) (vg_replace_malloc.c:...) - by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args) + by 0x........: main (sized_aligned_new_delete_args.cpp:37) Conditional jump or move depends on uninitialised value(s) at 0x........: operator delete[](void*, unsigned long, std::align_val_t) (vg_replace_malloc.c:...) - by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args) + by 0x........: main (sized_aligned_new_delete_args.cpp:40) Conditional jump or move depends on uninitialised value(s) at 0x........: operator delete[](void*, unsigned long, std::align_val_t) (vg_replace_malloc.c:...) - by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args) + by 0x........: main (sized_aligned_new_delete_args.cpp:40) |
|
From: Paul F. <pa...@so...> - 2023-03-07 22:51:28
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=2fa68c1cc76333360f40ad331c64001e74f4a8ad commit 2fa68c1cc76333360f40ad331c64001e74f4a8ad Author: Paul Floyd <pj...@wa...> Date: Tue Mar 7 23:49:22 2023 +0100 auxchecks: fix building on FreeBSD FreeBSD has a sha256sum that doesn't take long args (--check) GNU sha256sum exists as gsha256sum so add a check for that to configure.ac Diff: --- auxprogs/Makefile.am | 2 +- configure.ac | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/auxprogs/Makefile.am b/auxprogs/Makefile.am index 9831ee3b41..3a9709da6f 100644 --- a/auxprogs/Makefile.am +++ b/auxprogs/Makefile.am @@ -169,7 +169,7 @@ $(GSL_TAR): # We need to autoreconf to make sure to get config.guess, config.sub # and libtool for newer architectures. $(GSL_SRC_DIR)/gsl-patched: $(GSL_TAR) - echo "$(GSL_SHA256_SUM) $(GSL_TAR)" | sha256sum --check - + echo "$(GSL_SHA256_SUM) $(GSL_TAR)" | @SHA256SUM@ --check - (cd $(AUX_CHECK_DIR) && \ tar zxf $(GSL_TAR_NAME) && \ cd $(GSL_DIR_NAME) && \ diff --git a/configure.ac b/configure.ac index 696c967ee1..92fb33c4a5 100755 --- a/configure.ac +++ b/configure.ac @@ -85,6 +85,11 @@ m4_ifndef([AC_PROG_SED], AC_CHECK_PROGS([SED],[gsed sed])])]) AC_PROG_SED +AC_DEFUN([AC_PROG_SHA256SUM], + [AC_ARG_VAR([SHA256SUM]) + AC_CHECK_PROGS([SHA256SUM],[gsha256sum sha256sum])]) +AC_PROG_SHA256SUM + # If no AR variable was specified, look up the name of the archiver. Otherwise # do not touch the AR variable. if test "x$AR" = "x"; then |
|
From: Paul F. <pa...@so...> - 2023-03-07 22:20:02
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=18ca012c0822cdecd167ca1376ce9855194643c1 commit 18ca012c0822cdecd167ca1376ce9855194643c1 Author: Paul Floyd <pj...@wa...> Date: Tue Mar 7 23:19:04 2023 +0100 Fix compile failure on Linux Use SizeT rather than size_t Also make tests quieter with -q Diff: --- coregrind/m_replacemalloc/vg_replace_malloc.c | 12 ++++++------ memcheck/tests/sized_aligned_new_delete_args.stderr.exp | 11 ----------- memcheck/tests/sized_aligned_new_delete_args.stderr.exp_32 | 11 ----------- memcheck/tests/sized_aligned_new_delete_args.vgtest | 1 + 4 files changed, 7 insertions(+), 28 deletions(-) diff --git a/coregrind/m_replacemalloc/vg_replace_malloc.c b/coregrind/m_replacemalloc/vg_replace_malloc.c index e122371202..2b0879cd86 100644 --- a/coregrind/m_replacemalloc/vg_replace_malloc.c +++ b/coregrind/m_replacemalloc/vg_replace_malloc.c @@ -932,8 +932,8 @@ extern int *___errno (void) __attribute__((weak)); #define DELETE_SIZED(soname, fnname, vg_replacement) \ \ - void VG_REPLACE_FUNCTION_EZU(10050,soname,fnname) (void *p, size_t size); \ - void VG_REPLACE_FUNCTION_EZU(10050,soname,fnname) (void *p, size_t size) \ + void VG_REPLACE_FUNCTION_EZU(10050,soname,fnname) (void *p, SizeT size); \ + void VG_REPLACE_FUNCTION_EZU(10050,soname,fnname) (void *p, SizeT size) \ { \ DO_INIT; \ TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED((UWord)size); \ @@ -1008,8 +1008,8 @@ extern int *___errno (void) __attribute__((weak)); #define DELETE_ALIGNED(soname, fnname, vg_replacement) \ \ - void VG_REPLACE_FUNCTION_EZU(10050,soname,fnname) (void *p, size_t alignment); \ - void VG_REPLACE_FUNCTION_EZU(10050,soname,fnname) (void *p, size_t alignment) \ + void VG_REPLACE_FUNCTION_EZU(10050,soname,fnname) (void *p, SizeT alignment); \ + void VG_REPLACE_FUNCTION_EZU(10050,soname,fnname) (void *p, SizeT alignment) \ { \ DO_INIT; \ TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED((UWord)alignment); \ @@ -1021,8 +1021,8 @@ extern int *___errno (void) __attribute__((weak)); #define DELETE_SIZED_ALIGNED(soname, fnname, vg_replacement) \ \ - void VG_REPLACE_FUNCTION_EZU(10050,soname,fnname) (void *p, size_t size, size_t alignment); \ - void VG_REPLACE_FUNCTION_EZU(10050,soname,fnname) (void *p, size_t size, size_t alignment) \ + void VG_REPLACE_FUNCTION_EZU(10050,soname,fnname) (void *p, SizeT size, SizeT alignment); \ + void VG_REPLACE_FUNCTION_EZU(10050,soname,fnname) (void *p, SizeT size, SizeT alignment) \ { \ DO_INIT; \ TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED((UWord)size); \ diff --git a/memcheck/tests/sized_aligned_new_delete_args.stderr.exp b/memcheck/tests/sized_aligned_new_delete_args.stderr.exp index c086f1d266..a4c30dc4bd 100644 --- a/memcheck/tests/sized_aligned_new_delete_args.stderr.exp +++ b/memcheck/tests/sized_aligned_new_delete_args.stderr.exp @@ -1,4 +1,3 @@ - Conditional jump or move depends on uninitialised value(s) at 0x........: operator new(unsigned long, std::align_val_t) (vg_replace_malloc.c:...) by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args) @@ -71,13 +70,3 @@ Conditional jump or move depends on uninitialised value(s) at 0x........: operator delete[](void*, unsigned long, std::align_val_t) (vg_replace_malloc.c:...) by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args) - -HEAP SUMMARY: - in use at exit: 0 bytes in 0 blocks - total heap usage: 8 allocs, 8 frees, 128 bytes allocated - -For a detailed leak analysis, rerun with: --leak-check=full - -Use --track-origins=yes to see where uninitialised values come from -For lists of detected and suppressed errors, rerun with: -s -ERROR SUMMARY: 18 errors from 18 contexts (suppressed: 0 from 0) diff --git a/memcheck/tests/sized_aligned_new_delete_args.stderr.exp_32 b/memcheck/tests/sized_aligned_new_delete_args.stderr.exp_32 index dfa83679ec..9a23649683 100644 --- a/memcheck/tests/sized_aligned_new_delete_args.stderr.exp_32 +++ b/memcheck/tests/sized_aligned_new_delete_args.stderr.exp_32 @@ -1,4 +1,3 @@ - Conditional jump or move depends on uninitialised value(s) at 0x........: operator new(unsigned int, std::align_val_t) (vg_replace_malloc.c:...) by 0x........: main (sized_aligned_new_delete_args.cpp:16) @@ -71,13 +70,3 @@ Conditional jump or move depends on uninitialised value(s) at 0x........: operator delete[](void*, unsigned int, std::align_val_t) (vg_replace_malloc.c:...) by 0x........: main (sized_aligned_new_delete_args.cpp:40) - -HEAP SUMMARY: - in use at exit: 0 bytes in 0 blocks - total heap usage: 8 allocs, 8 frees, 128 bytes allocated - -For a detailed leak analysis, rerun with: --leak-check=full - -Use --track-origins=yes to see where uninitialised values come from -For lists of detected and suppressed errors, rerun with: -s -ERROR SUMMARY: 18 errors from 18 contexts (suppressed: 0 from 0) diff --git a/memcheck/tests/sized_aligned_new_delete_args.vgtest b/memcheck/tests/sized_aligned_new_delete_args.vgtest index 8df8db4df2..029fd4b661 100644 --- a/memcheck/tests/sized_aligned_new_delete_args.vgtest +++ b/memcheck/tests/sized_aligned_new_delete_args.vgtest @@ -1,2 +1,3 @@ prog: sized_aligned_new_delete_args prereq: test -e ./sized_aligned_new_delete_args +vgopts: -q |
|
From: Paul F. <pa...@so...> - 2023-03-07 21:59:57
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=114c528dab93036588069688667d03d1f78d9bf0 commit 114c528dab93036588069688667d03d1f78d9bf0 Author: Paul Floyd <pj...@wa...> Date: Tue Mar 7 22:58:57 2023 +0100 Add 32bit version of sized_aligned_new_delete_args expected Asl add some parens to shut up clangd Diff: --- coregrind/m_replacemalloc/vg_replace_malloc.c | 2 +- memcheck/tests/Makefile.am | 1 + .../sized_aligned_new_delete_args.stderr.exp_32 | 83 ++++++++++++++++++++++ 3 files changed, 85 insertions(+), 1 deletion(-) diff --git a/coregrind/m_replacemalloc/vg_replace_malloc.c b/coregrind/m_replacemalloc/vg_replace_malloc.c index e07ab50504..e122371202 100644 --- a/coregrind/m_replacemalloc/vg_replace_malloc.c +++ b/coregrind/m_replacemalloc/vg_replace_malloc.c @@ -68,7 +68,7 @@ #include "pub_core_redir.h" // for VG_REPLACE_FUNCTION_* #include "pub_core_replacemalloc.h" -#define VG_ALIGN_ROUNDUP(size, alignment) ((size + alignment - 1) & ~(alignment - 1)) +#define VG_ALIGN_ROUNDUP(size, alignment) (((size) + (alignment) - 1) & ~((alignment) - 1)) /* Assignment of behavioural equivalence class tags: 1NNNP is intended to be reserved for the Valgrind core. Current usage: diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am index dc0f39aa65..e6afff0d00 100644 --- a/memcheck/tests/Makefile.am +++ b/memcheck/tests/Makefile.am @@ -141,6 +141,7 @@ EXTRA_DIST = \ cxx17_aligned_new.stdout.exp \ sized_aligned_new_delete_args.stderr.exp \ sized_aligned_new_delete_args.vgtest \ + sized_aligned_new_delete_args.stderr.exp_32 \ deep-backtrace.vgtest deep-backtrace.stderr.exp \ demangle.stderr.exp demangle.vgtest \ big_debuginfo_symbol.stderr.exp big_debuginfo_symbol.vgtest \ diff --git a/memcheck/tests/sized_aligned_new_delete_args.stderr.exp_32 b/memcheck/tests/sized_aligned_new_delete_args.stderr.exp_32 new file mode 100644 index 0000000000..dfa83679ec --- /dev/null +++ b/memcheck/tests/sized_aligned_new_delete_args.stderr.exp_32 @@ -0,0 +1,83 @@ + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator new(unsigned int, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_args.cpp:16) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator new(unsigned int, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_args.cpp:16) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator delete(void*, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_args.cpp:17) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator new[](unsigned int, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_args.cpp:19) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator new[](unsigned int, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_args.cpp:19) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator delete[](void*, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_args.cpp:20) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator new(unsigned int, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_args.cpp:24) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator new(unsigned int, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_args.cpp:24) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator delete(void*, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_args.cpp:25) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator new[](unsigned int, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_args.cpp:27) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator new[](unsigned int, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_args.cpp:27) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator delete[](void*, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_args.cpp:28) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: ...operator delete... (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_args.cpp:31) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator delete[](void*, unsigned int) (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_args.cpp:34) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator delete(void*, unsigned int, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_args.cpp:37) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator delete(void*, unsigned int, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_args.cpp:37) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator delete[](void*, unsigned int, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_args.cpp:40) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator delete[](void*, unsigned int, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (sized_aligned_new_delete_args.cpp:40) + + +HEAP SUMMARY: + in use at exit: 0 bytes in 0 blocks + total heap usage: 8 allocs, 8 frees, 128 bytes allocated + +For a detailed leak analysis, rerun with: --leak-check=full + +Use --track-origins=yes to see where uninitialised values come from +For lists of detected and suppressed errors, rerun with: -s +ERROR SUMMARY: 18 errors from 18 contexts (suppressed: 0 from 0) |
|
From: Paul F. <pa...@so...> - 2023-03-07 21:48:15
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=ceee3e8922b734f9d80166d88611c2d14ec9f06e commit ceee3e8922b734f9d80166d88611c2d14ec9f06e Author: Paul Floyd <pj...@wa...> Date: Tue Mar 7 22:47:19 2023 +0100 Add checks to all new / delete overload arguments Diff: --- .gitignore | 1 + coregrind/m_replacemalloc/vg_replace_malloc.c | 254 ++++++++++++--------- memcheck/tests/Makefile.am | 6 +- memcheck/tests/sized_aligned_new_delete_args.cpp | 42 ++++ .../tests/sized_aligned_new_delete_args.stderr.exp | 83 +++++++ .../tests/sized_aligned_new_delete_args.vgtest | 2 + 6 files changed, 280 insertions(+), 108 deletions(-) diff --git a/.gitignore b/.gitignore index 67e6b545fe..a4c7b510ba 100644 --- a/.gitignore +++ b/.gitignore @@ -961,6 +961,7 @@ /memcheck/tests/sendmsg /memcheck/tests/sh-mem /memcheck/tests/sh-mem-random +/memcheck/tests/sized_aligned_new_delete_args /memcheck/tests/sigaltstack /memcheck/tests/sigkill /memcheck/tests/signal2 diff --git a/coregrind/m_replacemalloc/vg_replace_malloc.c b/coregrind/m_replacemalloc/vg_replace_malloc.c index 6addfe80f9..e07ab50504 100644 --- a/coregrind/m_replacemalloc/vg_replace_malloc.c +++ b/coregrind/m_replacemalloc/vg_replace_malloc.c @@ -930,6 +930,19 @@ extern int *___errno (void) __attribute__((weak)); /*---------------------- delete ----------------------*/ +#define DELETE_SIZED(soname, fnname, vg_replacement) \ + \ + void VG_REPLACE_FUNCTION_EZU(10050,soname,fnname) (void *p, size_t size); \ + void VG_REPLACE_FUNCTION_EZU(10050,soname,fnname) (void *p, size_t size) \ + { \ + DO_INIT; \ + TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED((UWord)size); \ + MALLOC_TRACE(#fnname "(%p)\n", p ); \ + if (p == NULL) \ + return; \ + (void)VALGRIND_NON_SIMD_CALL1( info.tl_##vg_replacement, p ); \ + } + #if defined(VGO_linux) // operator delete(void*), not mangled (for gcc 2.96) FREE(VG_Z_LIBSTDCXX_SONAME, __builtin_delete, __builtin_delete ); @@ -941,16 +954,16 @@ extern int *___errno (void) __attribute__((weak)); FREE(SO_SYN_MALLOC, _ZdlPv, __builtin_delete ); // operator delete(void*, unsigned int), C++14, GNU mangling #if __SIZEOF_SIZE_T__ == 4 - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPvj, __builtin_delete ); - FREE(VG_Z_LIBCXX_SONAME, _ZdlPvj, __builtin_delete ); - FREE(VG_Z_LIBC_SONAME, _ZdlPvj, __builtin_delete ); - FREE(SO_SYN_MALLOC, _ZdlPvj, __builtin_delete ); + DELETE_SIZED(VG_Z_LIBSTDCXX_SONAME, _ZdlPvj, __builtin_delete ); + DELETE_SIZED(VG_Z_LIBCXX_SONAME, _ZdlPvj, __builtin_delete ); + DELETE_SIZED(VG_Z_LIBC_SONAME, _ZdlPvj, __builtin_delete ); + DELETE_SIZED(SO_SYN_MALLOC, _ZdlPvj, __builtin_delete ); // operator delete(void*, unsigned long), C++14, GNU mangling #elif __SIZEOF_SIZE_T__ == 8 - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPvm, __builtin_delete ); - FREE(VG_Z_LIBCXX_SONAME, _ZdlPvm, __builtin_delete ); - FREE(VG_Z_LIBC_SONAME, _ZdlPvm, __builtin_delete ); - FREE(SO_SYN_MALLOC, _ZdlPvm, __builtin_delete ); + DELETE_SIZED(VG_Z_LIBSTDCXX_SONAME, _ZdlPvm, __builtin_delete ); + DELETE_SIZED(VG_Z_LIBCXX_SONAME, _ZdlPvm, __builtin_delete ); + DELETE_SIZED(VG_Z_LIBC_SONAME, _ZdlPvm, __builtin_delete ); + DELETE_SIZED(SO_SYN_MALLOC, _ZdlPvm, __builtin_delete ); #endif @@ -960,13 +973,13 @@ extern int *___errno (void) __attribute__((weak)); FREE(SO_SYN_MALLOC, _ZdlPv, __builtin_delete ); // operator delete(void*, unsigned long), C++14, GNU mangling #if __SIZEOF_SIZE_T__ == 4 - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPvj, __builtin_delete ); - FREE(VG_Z_LIBCXX_SONAME, _ZdlPvj, __builtin_delete ); - FREE(SO_SYN_MALLOC, _ZdlPvj, __builtin_delete ); + DELETE_SIZED(VG_Z_LIBSTDCXX_SONAME, _ZdlPvj, __builtin_delete ); + DELETE_SIZED(VG_Z_LIBCXX_SONAME, _ZdlPvj, __builtin_delete ); + DELETE_SIZED(SO_SYN_MALLOC, _ZdlPvj, __builtin_delete ); #elif __SIZEOF_SIZE_T__ == 8 - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPvm, __builtin_delete ); - FREE(VG_Z_LIBCXX_SONAME, _ZdlPvm, __builtin_delete ); - FREE(SO_SYN_MALLOC, _ZdlPvm, __builtin_delete ); + DELETE_SIZED(VG_Z_LIBSTDCXX_SONAME, _ZdlPvm, __builtin_delete ); + DELETE_SIZED(VG_Z_LIBCXX_SONAME, _ZdlPvm, __builtin_delete ); + DELETE_SIZED(SO_SYN_MALLOC, _ZdlPvm, __builtin_delete ); #endif #elif defined(VGO_darwin) @@ -981,11 +994,11 @@ extern int *___errno (void) __attribute__((weak)); // operator delete(void*, unsigned long), C++14, GNU mangling #if __SIZEOF_SIZE_T__ == 4 - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPvj, __builtin_delete ); - FREE(SO_SYN_MALLOC, _ZdlPvj, __builtin_delete ); + DELETE_SIZED(VG_Z_LIBSTDCXX_SONAME, _ZdlPvj, __builtin_delete ); + DELETE_SIZED(SO_SYN_MALLOC, _ZdlPvj, __builtin_delete ); #elif __SIZEOF_SIZE_T__ == 8 - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPvm, __builtin_delete ); - FREE(SO_SYN_MALLOC, _ZdlPvm, __builtin_delete ); + DELETE_SIZED(VG_Z_LIBSTDCXX_SONAME, _ZdlPvm, __builtin_delete ); + DELETE_SIZED(SO_SYN_MALLOC, _ZdlPvm, __builtin_delete ); #endif @@ -993,43 +1006,70 @@ extern int *___errno (void) __attribute__((weak)); /*------------------- C++17 delete aligned -------------------*/ +#define DELETE_ALIGNED(soname, fnname, vg_replacement) \ + \ + void VG_REPLACE_FUNCTION_EZU(10050,soname,fnname) (void *p, size_t alignment); \ + void VG_REPLACE_FUNCTION_EZU(10050,soname,fnname) (void *p, size_t alignment) \ + { \ + DO_INIT; \ + TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED((UWord)alignment); \ + MALLOC_TRACE(#fnname "(%p)\n", p ); \ + if (p == NULL) \ + return; \ + (void)VALGRIND_NON_SIMD_CALL1( info.tl_##vg_replacement, p ); \ + } + +#define DELETE_SIZED_ALIGNED(soname, fnname, vg_replacement) \ + \ + void VG_REPLACE_FUNCTION_EZU(10050,soname,fnname) (void *p, size_t size, size_t alignment); \ + void VG_REPLACE_FUNCTION_EZU(10050,soname,fnname) (void *p, size_t size, size_t alignment) \ + { \ + DO_INIT; \ + TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED((UWord)size); \ + TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED((UWord)alignment); \ + MALLOC_TRACE(#fnname "(%p)\n", p ); \ + if (p == NULL) \ + return; \ + (void)VALGRIND_NON_SIMD_CALL1( info.tl_##vg_replacement, p ); \ + } + #if defined(VGO_linux) // operator delete(void*, std::align_val_t), GNU mangling - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPvSt11align_val_t, __builtin_delete_aligned ); - FREE(VG_Z_LIBCXX_SONAME, _ZdlPvSt11align_val_t, __builtin_delete_aligned ); - FREE(VG_Z_LIBC_SONAME, _ZdlPvSt11align_val_t, __builtin_delete_aligned ); + DELETE_ALIGNED(VG_Z_LIBSTDCXX_SONAME, _ZdlPvSt11align_val_t, __builtin_delete_aligned ); + DELETE_ALIGNED(VG_Z_LIBCXX_SONAME, _ZdlPvSt11align_val_t, __builtin_delete_aligned ); + DELETE_ALIGNED(VG_Z_LIBC_SONAME, _ZdlPvSt11align_val_t, __builtin_delete_aligned ); FREE(SO_SYN_MALLOC, _ZdlPvSt11align_val_t, __builtin_delete_aligned ); // operator delete(void*, unsigned int, std::align_val_t), GNU mangling #if __SIZEOF_SIZE_T__ == 4 - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPvjSt11align_val_t, __builtin_delete_aligned ); - FREE(VG_Z_LIBCXX_SONAME, _ZdlPvjSt11align_val_t, __builtin_delete_aligned ); - FREE(VG_Z_LIBC_SONAME, _ZdlPvjSt11align_val_t, __builtin_delete_aligned ); - FREE(SO_SYN_MALLOC, _ZdlPvjSt11align_val_t, __builtin_delete_aligned ); + DELETE_SIZED_ALIGNED(VG_Z_LIBSTDCXX_SONAME, _ZdlPvjSt11align_val_t, __builtin_delete_aligned ); + DELETE_SIZED_ALIGNED(VG_Z_LIBCXX_SONAME, _ZdlPvjSt11align_val_t, __builtin_delete_aligned ); + DELETE_SIZED_ALIGNED(VG_Z_LIBC_SONAME, _ZdlPvjSt11align_val_t, __builtin_delete_aligned ); + DELETE_SIZED_ALIGNED(SO_SYN_MALLOC, _ZdlPvjSt11align_val_t, __builtin_delete_aligned ); // operator delete(void*, unsigned long, std::align_val_t), GNU mangling #elif __SIZEOF_SIZE_T__ == 8 - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPvmSt11align_val_t, __builtin_delete_aligned ); - FREE(VG_Z_LIBCXX_SONAME, _ZdlPvmSt11align_val_t, __builtin_delete_aligned ); - FREE(VG_Z_LIBC_SONAME, _ZdlPvmSt11align_val_t, __builtin_delete_aligned ); - FREE(SO_SYN_MALLOC, _ZdlPvmSt11align_val_t, __builtin_delete_aligned ); + DELETE_SIZED_ALIGNED(VG_Z_LIBSTDCXX_SONAME, _ZdlPvmSt11align_val_t, __builtin_delete_aligned ); + DELETE_SIZED_ALIGNED(VG_Z_LIBCXX_SONAME, _ZdlPvmSt11align_val_t, __builtin_delete_aligned ); + DELETE_SIZED_ALIGNED(VG_Z_LIBC_SONAME, _ZdlPvmSt11align_val_t, __builtin_delete_aligned ); + DELETE_SIZED_ALIGNED(SO_SYN_MALLOC, _ZdlPvmSt11align_val_t, __builtin_delete_aligned ); #endif #elif defined(VGO_freebsd) // operator delete(void*, std::align_val_t), GNU mangling - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPvSt11align_val_t, __builtin_delete_aligned ); - FREE(VG_Z_LIBCXX_SONAME, _ZdlPvSt11align_val_t, __builtin_delete_aligned ); - FREE(SO_SYN_MALLOC, _ZdlPvSt11align_val_t, __builtin_delete_aligned ); + DELETE_ALIGNED(VG_Z_LIBSTDCXX_SONAME, _ZdlPvSt11align_val_t, __builtin_delete_aligned ); + DELETE_ALIGNED(VG_Z_LIBCXX_SONAME, _ZdlPvSt11align_val_t, __builtin_delete_aligned ); + DELETE_ALIGNED(SO_SYN_MALLOC, _ZdlPvSt11align_val_t, __builtin_delete_aligned ); // operator delete(void*, unsigned int, std::align_val_t), GNU mangling #if __SIZEOF_SIZE_T__ == 4 - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPvjSt11align_val_t, __builtin_delete_aligned ); - FREE(VG_Z_LIBCXX_SONAME, _ZdlPvjSt11align_val_t, __builtin_delete_aligned ); - FREE(SO_SYN_MALLOC, _ZdlPvjSt11align_val_t, __builtin_delete_aligned ); + DELETE_SIZED_ALIGNED(VG_Z_LIBSTDCXX_SONAME, _ZdlPvjSt11align_val_t, __builtin_delete_aligned ); + DELETE_SIZED_ALIGNED(VG_Z_LIBCXX_SONAME, _ZdlPvjSt11align_val_t, __builtin_delete_aligned ); + DELETE_SIZED_ALIGNED(SO_SYN_MALLOC, _ZdlPvjSt11align_val_t, __builtin_delete_aligned ); // operator delete(void*, unsigned long, std::align_val_t), GNU mangling #elif __SIZEOF_SIZE_T__ == 8 - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPvmSt11align_val_t, __builtin_delete_aligned ); - FREE(VG_Z_LIBCXX_SONAME, _ZdlPvmSt11align_val_t, __builtin_delete_aligned ); - FREE(SO_SYN_MALLOC, _ZdlPvmSt11align_val_t, __builtin_delete_aligned ); + DELETE_SIZED_ALIGNED(VG_Z_LIBSTDCXX_SONAME, _ZdlPvmSt11align_val_t, __builtin_delete_aligned ); + DELETE_SIZED_ALIGNED(VG_Z_LIBCXX_SONAME, _ZdlPvmSt11align_val_t, __builtin_delete_aligned ); + DELETE_SIZED_ALIGNED(SO_SYN_MALLOC, _ZdlPvmSt11align_val_t, __builtin_delete_aligned ); #endif #elif defined(VGO_darwin) @@ -1037,17 +1077,17 @@ extern int *___errno (void) __attribute__((weak)); #elif defined(VGO_solaris) // operator delete(void*, std::align_val_t) - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPvSt11align_val_t, __builtin_delete_aligned ); - FREE(SO_SYN_MALLOC, _ZdlPvSt11align_val_t, __builtin_delete_aligned ); + DELETE_ALIGNED(VG_Z_LIBSTDCXX_SONAME, _ZdlPvSt11align_val_t, __builtin_delete_aligned ); + DELETE_ALIGNED(SO_SYN_MALLOC, _ZdlPvSt11align_val_t, __builtin_delete_aligned ); // operator delete(void*, unsigned int, std::align_val_t) #if __SIZEOF_SIZE_T__ == 4 - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPvjSt11align_val_t, __builtin_delete_aligned ); - FREE(SO_SYN_MALLOC, _ZdlPvjSt11align_val_t, __builtin_delete_aligned ); + DELETE_SIZED_ALIGNED(VG_Z_LIBSTDCXX_SONAME, _ZdlPvjSt11align_val_t, __builtin_delete_aligned ); + DELETE_SIZED_ALIGNED(SO_SYN_MALLOC, _ZdlPvjSt11align_val_t, __builtin_delete_aligned ); // operator delete(void*, unsigned long, std::align_val_t) #elif __SIZEOF_SIZE_T__ == 8 - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPvmSt11align_val_t, __builtin_delete_aligned ); - FREE(SO_SYN_MALLOC, _ZdlPvmSt11align_val_t, __builtin_delete_aligned ); + DELETE_SIZED_ALIGNED(VG_Z_LIBSTDCXX_SONAME, _ZdlPvmSt11align_val_t, __builtin_delete_aligned ); + DELETE_SIZED_ALIGNED(SO_SYN_MALLOC, _ZdlPvmSt11align_val_t, __builtin_delete_aligned ); #endif #endif @@ -1083,25 +1123,25 @@ extern int *___errno (void) __attribute__((weak)); #if defined(VGO_linux) // operator delete(void*, std::align_val_t, std::nothrow_t const&), GNU mangling - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPvSt11align_val_tRKSt9nothrow_t, __builtin_delete_aligned ); - FREE(VG_Z_LIBCXX_SONAME, _ZdlPvSt11align_val_tRKSt9nothrow_t, __builtin_delete_aligned ); - FREE(VG_Z_LIBC_SONAME, _ZdlPvSt11align_val_tRKSt9nothrow_t, __builtin_delete_aligned ); - FREE(SO_SYN_MALLOC, _ZdlPvSt11align_val_tRKSt9nothrow_t, __builtin_delete_aligned ); + DELETE_ALIGNED(VG_Z_LIBSTDCXX_SONAME, _ZdlPvSt11align_val_tRKSt9nothrow_t, __builtin_delete_aligned ); + DELETE_ALIGNED(VG_Z_LIBCXX_SONAME, _ZdlPvSt11align_val_tRKSt9nothrow_t, __builtin_delete_aligned ); + DELETE_ALIGNED(VG_Z_LIBC_SONAME, _ZdlPvSt11align_val_tRKSt9nothrow_t, __builtin_delete_aligned ); + DELETE_ALIGNED(SO_SYN_MALLOC, _ZdlPvSt11align_val_tRKSt9nothrow_t, __builtin_delete_aligned ); // no sized version of this operator #elif defined(VGO_freebsd) // operator delete(void*, std::align_val_t, std::nothrow_t const&), GNU mangling - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPvSt11align_val_tRKSt9nothrow_t, __builtin_delete_aligned ); - FREE(VG_Z_LIBCXX_SONAME, _ZdlPvSt11align_val_tRKSt9nothrow_t, __builtin_delete_aligned ); - FREE(SO_SYN_MALLOC, _ZdlPvSt11align_val_tRKSt9nothrow_t, __builtin_delete_aligned ); + DELETE_ALIGNED(VG_Z_LIBSTDCXX_SONAME, _ZdlPvSt11align_val_tRKSt9nothrow_t, __builtin_delete_aligned ); + DELETE_ALIGNED(VG_Z_LIBCXX_SONAME, _ZdlPvSt11align_val_tRKSt9nothrow_t, __builtin_delete_aligned ); + DELETE_ALIGNED(SO_SYN_MALLOC, _ZdlPvSt11align_val_tRKSt9nothrow_t, __builtin_delete_aligned ); #elif defined(VGO_darwin) #elif defined(VGO_solaris) // operator delete(void*, std::align_val_t, std::nothrow_t const&), GNU mangling - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPvSt11align_val_tRKSt9nothrow_t, __builtin_delete_aligned ); - FREE(SO_SYN_MALLOC, _ZdlPvSt11align_val_tRKSt9nothrow_t, __builtin_delete_aligned ); + DELETE_ALIGNED(VG_Z_LIBSTDCXX_SONAME, _ZdlPvSt11align_val_tRKSt9nothrow_t, __builtin_delete_aligned ); + DELETE_ALIGNED(SO_SYN_MALLOC, _ZdlPvSt11align_val_tRKSt9nothrow_t, __builtin_delete_aligned ); // no sized version of this operator @@ -1122,16 +1162,16 @@ extern int *___errno (void) __attribute__((weak)); // operator delete[](void*, unsigned long), C++14, GNU mangling #if __SIZEOF_SIZE_T__ == 4 - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdaPvj, __builtin_vec_delete ); - FREE(VG_Z_LIBCXX_SONAME, _ZdaPvj, __builtin_vec_delete ); - FREE(VG_Z_LIBC_SONAME, _ZdaPvj, __builtin_vec_delete ); - FREE(SO_SYN_MALLOC, _ZdaPvj, __builtin_vec_delete ); + DELETE_SIZED(VG_Z_LIBSTDCXX_SONAME, _ZdaPvj, __builtin_vec_delete ); + DELETE_SIZED(VG_Z_LIBCXX_SONAME, _ZdaPvj, __builtin_vec_delete ); + DELETE_SIZED(VG_Z_LIBC_SONAME, _ZdaPvj, __builtin_vec_delete ); + DELETE_SIZED(SO_SYN_MALLOC, _ZdaPvj, __builtin_vec_delete ); #elif __SIZEOF_SIZE_T__ == 8 - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdaPvm, __builtin_vec_delete ); - FREE(VG_Z_LIBCXX_SONAME, _ZdaPvm, __builtin_vec_delete ); - FREE(VG_Z_LIBC_SONAME, _ZdaPvm, __builtin_vec_delete ); - FREE(SO_SYN_MALLOC, _ZdaPvm, __builtin_vec_delete ); + DELETE_SIZED(VG_Z_LIBSTDCXX_SONAME, _ZdaPvm, __builtin_vec_delete ); + DELETE_SIZED(VG_Z_LIBCXX_SONAME, _ZdaPvm, __builtin_vec_delete ); + DELETE_SIZED(VG_Z_LIBC_SONAME, _ZdaPvm, __builtin_vec_delete ); + DELETE_SIZED(SO_SYN_MALLOC, _ZdaPvm, __builtin_vec_delete ); #endif #elif defined(VGO_freebsd) @@ -1141,13 +1181,13 @@ extern int *___errno (void) __attribute__((weak)); FREE(SO_SYN_MALLOC, _ZdaPv, __builtin_vec_delete ); // operator delete[](void*, unsigned long), C++14, GNU mangling #if __SIZEOF_SIZE_T__ == 4 - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdaPvj, __builtin_vec_delete ); - FREE(VG_Z_LIBCXX_SONAME, _ZdaPvj, __builtin_vec_delete ); - FREE(SO_SYN_MALLOC, _ZdaPvj, __builtin_vec_delete ); + DELETE_SIZED(VG_Z_LIBSTDCXX_SONAME, _ZdaPvj, __builtin_vec_delete ); + DELETE_SIZED(VG_Z_LIBCXX_SONAME, _ZdaPvj, __builtin_vec_delete ); + DELETE_SIZED(SO_SYN_MALLOC, _ZdaPvj, __builtin_vec_delete ); #elif __SIZEOF_SIZE_T__ == 8 - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdaPvm, __builtin_vec_delete ); - FREE(VG_Z_LIBCXX_SONAME, _ZdaPvm, __builtin_vec_delete ); - FREE(SO_SYN_MALLOC, _ZdaPvm, __builtin_vec_delete ); + DELETE_SIZED(VG_Z_LIBSTDCXX_SONAME, _ZdaPvm, __builtin_vec_delete ); + DELETE_SIZED(VG_Z_LIBCXX_SONAME, _ZdaPvm, __builtin_vec_delete ); + DELETE_SIZED(SO_SYN_MALLOC, _ZdaPvm, __builtin_vec_delete ); #endif #elif defined(VGO_darwin) @@ -1165,12 +1205,12 @@ extern int *___errno (void) __attribute__((weak)); // operator delete[](void*, unsigned int), C++14, GNU mangling #if __SIZEOF_SIZE_T__ == 4 - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdaPvj, __builtin_vec_delete ); - FREE(SO_SYN_MALLOC, _ZdaPvj, __builtin_vec_delete ); + DELETE_SIZED(VG_Z_LIBSTDCXX_SONAME, _ZdaPvj, __builtin_vec_delete ); + DELETE_SIZED(SO_SYN_MALLOC, _ZdaPvj, __builtin_vec_delete ); // operator delete[](void*, unsigned long), C++14, GNU mangling #elif __SIZEOF_SIZE_T__ == 8 - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdaPvm, __builtin_vec_delete ); - FREE(SO_SYN_MALLOC, _ZdaPvm, __builtin_vec_delete ); + DELETE_SIZED(VG_Z_LIBSTDCXX_SONAME, _ZdaPvm, __builtin_vec_delete ); + DELETE_SIZED(SO_SYN_MALLOC, _ZdaPvm, __builtin_vec_delete ); #endif #endif @@ -1179,58 +1219,58 @@ extern int *___errno (void) __attribute__((weak)); #if defined(VGO_linux) // operator delete[](void*, std::align_val_t), GNU mangling - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdaPvSt11align_val_t, __builtin_vec_delete_aligned ); - FREE(VG_Z_LIBCXX_SONAME, _ZdaPvSt11align_val_t, __builtin_vec_delete_aligned ); - FREE(VG_Z_LIBC_SONAME, _ZdaPvSt11align_val_t, __builtin_vec_delete_aligned ); - FREE(SO_SYN_MALLOC, _ZdaPvSt11align_val_t, __builtin_vec_delete_aligned ); + DELETE_ALIGNED(VG_Z_LIBSTDCXX_SONAME, _ZdaPvSt11align_val_t, __builtin_vec_delete_aligned ); + DELETE_ALIGNED(VG_Z_LIBCXX_SONAME, _ZdaPvSt11align_val_t, __builtin_vec_delete_aligned ); + DELETE_ALIGNED(VG_Z_LIBC_SONAME, _ZdaPvSt11align_val_t, __builtin_vec_delete_aligned ); + DELETE_ALIGNED(SO_SYN_MALLOC, _ZdaPvSt11align_val_t, __builtin_vec_delete_aligned ); // operator delete[](void*, unsigned int, std::align_val_t), GNU mangling #if __SIZEOF_SIZE_T__ == 4 - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdaPvjSt11align_val_t, __builtin_vec_delete_aligned ); - FREE(VG_Z_LIBCXX_SONAME, _ZdaPvjSt11align_val_t, __builtin_vec_delete_aligned ); - FREE(VG_Z_LIBC_SONAME, _ZdaPvjSt11align_val_t, __builtin_vec_delete_aligned ); - FREE(SO_SYN_MALLOC, _ZdaPvjSt11align_val_t, __builtin_vec_delete_aligned ); + DELETE_SIZED_ALIGNED(VG_Z_LIBSTDCXX_SONAME, _ZdaPvjSt11align_val_t, __builtin_vec_delete_aligned ); + DELETE_SIZED_ALIGNED(VG_Z_LIBCXX_SONAME, _ZdaPvjSt11align_val_t, __builtin_vec_delete_aligned ); + DELETE_SIZED_ALIGNED(VG_Z_LIBC_SONAME, _ZdaPvjSt11align_val_t, __builtin_vec_delete_aligned ); + DELETE_SIZED_ALIGNED(SO_SYN_MALLOC, _ZdaPvjSt11align_val_t, __builtin_vec_delete_aligned ); // operator delete[](void*, unsigned long, std::align_val_t), GNU mangling #elif __SIZEOF_SIZE_T__ == 8 - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdaPvmSt11align_val_t, __builtin_vec_delete_aligned ); - FREE(VG_Z_LIBCXX_SONAME, _ZdaPvmSt11align_val_t, __builtin_vec_delete_aligned ); - FREE(VG_Z_LIBC_SONAME, _ZdaPvmSt11align_val_t, __builtin_vec_delete_aligned ); - FREE(SO_SYN_MALLOC, _ZdaPvmSt11align_val_t, __builtin_vec_delete_aligned ); + DELETE_SIZED_ALIGNED(VG_Z_LIBSTDCXX_SONAME, _ZdaPvmSt11align_val_t, __builtin_vec_delete_aligned ); + DELETE_SIZED_ALIGNED(VG_Z_LIBCXX_SONAME, _ZdaPvmSt11align_val_t, __builtin_vec_delete_aligned ); + DELETE_SIZED_ALIGNED(VG_Z_LIBC_SONAME, _ZdaPvmSt11align_val_t, __builtin_vec_delete_aligned ); + DELETE_SIZED_ALIGNED(SO_SYN_MALLOC, _ZdaPvmSt11align_val_t, __builtin_vec_delete_aligned ); #endif #elif defined(VGO_freebsd) // operator delete[](void*, std::align_val_t), GNU mangling - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdaPvSt11align_val_t, __builtin_vec_delete_aligned ); - FREE(VG_Z_LIBCXX_SONAME, _ZdaPvSt11align_val_t, __builtin_vec_delete_aligned ); - FREE(SO_SYN_MALLOC, _ZdaPvSt11align_val_t, __builtin_vec_delete_aligned ); + DELETE_ALIGNED(VG_Z_LIBSTDCXX_SONAME, _ZdaPvSt11align_val_t, __builtin_vec_delete_aligned ); + DELETE_ALIGNED(VG_Z_LIBCXX_SONAME, _ZdaPvSt11align_val_t, __builtin_vec_delete_aligned ); + DELETE_ALIGNED(SO_SYN_MALLOC, _ZdaPvSt11align_val_t, __builtin_vec_delete_aligned ); // operator delete[](void*, unsigned int, std::align_val_t), GNU mangling #if __SIZEOF_SIZE_T__ == 4 - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdaPvjSt11align_val_t, __builtin_vec_delete_aligned ); - FREE(VG_Z_LIBCXX_SONAME, _ZdaPvjSt11align_val_t, __builtin_vec_delete_aligned ); - FREE(SO_SYN_MALLOC, _ZdaPvjSt11align_val_t, __builtin_vec_delete_aligned ); + DELETE_SIZED_ALIGNED(VG_Z_LIBSTDCXX_SONAME, _ZdaPvjSt11align_val_t, __builtin_vec_delete_aligned ); + DELETE_SIZED_ALIGNED(VG_Z_LIBCXX_SONAME, _ZdaPvjSt11align_val_t, __builtin_vec_delete_aligned ); + DELETE_SIZED_ALIGNED(SO_SYN_MALLOC, _ZdaPvjSt11align_val_t, __builtin_vec_delete_aligned ); // operator delete[](void*, unsigned long, std::align_val_t), GNU mangling #elif __SIZEOF_SIZE_T__ == 8 - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdaPvmSt11align_val_t, __builtin_vec_delete_aligned ); - FREE(VG_Z_LIBCXX_SONAME, _ZdaPvmSt11align_val_t, __builtin_vec_delete_aligned ); - FREE(SO_SYN_MALLOC, _ZdaPvmSt11align_val_t, __builtin_vec_delete_aligned ); + DELETE_SIZED_ALIGNED(VG_Z_LIBSTDCXX_SONAME, _ZdaPvmSt11align_val_t, __builtin_vec_delete_aligned ); + DELETE_SIZED_ALIGNED(VG_Z_LIBCXX_SONAME, _ZdaPvmSt11align_val_t, __builtin_vec_delete_aligned ); + DELETE_SIZED_ALIGNED(SO_SYN_MALLOC, _ZdaPvmSt11align_val_t, __builtin_vec_delete_aligned ); #endif #elif defined(VGO_darwin) #elif defined(VGO_solaris) // operator delete[](void*, std::align_val_t), GNU mangling - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdaPvSt11align_val_t, __builtin_vec_delete_aligned ); - FREE(SO_SYN_MALLOC, _ZdaPvSt11align_val_t, __builtin_vec_delete_aligned ); + DELETE_ALIGNED(VG_Z_LIBSTDCXX_SONAME, _ZdaPvSt11align_val_t, __builtin_vec_delete_aligned ); + DELETE_ALIGNED(SO_SYN_MALLOC, _ZdaPvSt11align_val_t, __builtin_vec_delete_aligned ); // operator delete[](void*, unsigned int, std::align_val_t) #if __SIZEOF_SIZE_T__ == 4 - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdaPvjSt11align_val_t, __builtin_vec_delete_aligned ); - FREE(SO_SYN_MALLOC, _ZdaPvjSt11align_val_t, __builtin_vec_delete_aligned ); + DELETE_SIZED_ALIGNED(VG_Z_LIBSTDCXX_SONAME, _ZdaPvjSt11align_val_t, __builtin_vec_delete_aligned ); + DELETE_SIZED_ALIGNED(SO_SYN_MALLOC, _ZdaPvjSt11align_val_t, __builtin_vec_delete_aligned ); // operator delete[](void*, unsigned long), GNU mangling #elif __SIZEOF_SIZE_T__ == 8 - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdaPvmSt11align_val_t, __builtin_vec_delete_aligned ); - FREE(SO_SYN_MALLOC, _ZdaPvmSt11align_val_t, __builtin_vec_delete_aligned ); + DELETE_SIZED_ALIGNED(VG_Z_LIBSTDCXX_SONAME, _ZdaPvmSt11align_val_t, __builtin_vec_delete_aligned ); + DELETE_SIZED_ALIGNED(SO_SYN_MALLOC, _ZdaPvmSt11align_val_t, __builtin_vec_delete_aligned ); #endif #endif @@ -1266,25 +1306,25 @@ extern int *___errno (void) __attribute__((weak)); #if defined(VGO_linux) // operator delete[](void*, std::align_val_t, std::nothrow_t const&), GNU mangling - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdaPvSt11align_val_tRKSt9nothrow_t, __builtin_vec_delete_aligned ); - FREE(VG_Z_LIBCXX_SONAME, _ZdaPvSt11align_val_tRKSt9nothrow_t, __builtin_vec_delete_aligned ); - FREE(VG_Z_LIBC_SONAME, _ZdaPvSt11align_val_tRKSt9nothrow_t, __builtin_vec_delete_aligned ); - FREE(SO_SYN_MALLOC, _ZdaPvSt11align_val_tRKSt9nothrow_t, __builtin_vec_delete_aligned ); + DELETE_ALIGNED(VG_Z_LIBSTDCXX_SONAME, _ZdaPvSt11align_val_tRKSt9nothrow_t, __builtin_vec_delete_aligned ); + DELETE_ALIGNED(VG_Z_LIBCXX_SONAME, _ZdaPvSt11align_val_tRKSt9nothrow_t, __builtin_vec_delete_aligned ); + DELETE_ALIGNED(VG_Z_LIBC_SONAME, _ZdaPvSt11align_val_tRKSt9nothrow_t, __builtin_vec_delete_aligned ); + DELETE_ALIGNED(SO_SYN_MALLOC, _ZdaPvSt11align_val_tRKSt9nothrow_t, __builtin_vec_delete_aligned ); // no sized version of this operator #elif defined(VGO_freebsd) // operator delete[](void*, std::align_val_t, std::nothrow_t const&), GNU mangling - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdaPvSt11align_val_tRKSt9nothrow_t, __builtin_vec_delete_aligned ); - FREE(VG_Z_LIBCXX_SONAME, _ZdaPvSt11align_val_tRKSt9nothrow_t, __builtin_vec_delete_aligned ); - FREE(SO_SYN_MALLOC, _ZdaPvSt11align_val_tRKSt9nothrow_t, __builtin_vec_delete_aligned ); + DELETE_ALIGNED(VG_Z_LIBSTDCXX_SONAME, _ZdaPvSt11align_val_tRKSt9nothrow_t, __builtin_vec_delete_aligned ); + DELETE_ALIGNED(VG_Z_LIBCXX_SONAME, _ZdaPvSt11align_val_tRKSt9nothrow_t, __builtin_vec_delete_aligned ); + DELETE_ALIGNED(SO_SYN_MALLOC, _ZdaPvSt11align_val_tRKSt9nothrow_t, __builtin_vec_delete_aligned ); #elif defined(VGO_darwin) #elif defined(VGO_solaris) // operator delete[](void*, std::align_val_t, std::nothrow_t const&), GNU mangling - FREE(VG_Z_LIBSTDCXX_SONAME, _ZdaPvSt11align_val_tRKSt9nothrow_t, __builtin_vec_delete_aligned ); - FREE(SO_SYN_MALLOC, _ZdaPvSt11align_val_tRKSt9nothrow_t, __builtin_vec_delete_aligned ); + DELETE_ALIGNED(VG_Z_LIBSTDCXX_SONAME, _ZdaPvSt11align_val_tRKSt9nothrow_t, __builtin_vec_delete_aligned ); + DELETE_ALIGNED(SO_SYN_MALLOC, _ZdaPvSt11align_val_tRKSt9nothrow_t, __builtin_vec_delete_aligned ); // no sized version of this operator diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am index 6c1c20185a..dc0f39aa65 100644 --- a/memcheck/tests/Makefile.am +++ b/memcheck/tests/Makefile.am @@ -139,6 +139,8 @@ EXTRA_DIST = \ cxx17_aligned_new.stderr.exp cxx17_aligned_new.vgtest \ cxx17_aligned_new.stderr.exp_32 \ cxx17_aligned_new.stdout.exp \ + sized_aligned_new_delete_args.stderr.exp \ + sized_aligned_new_delete_args.vgtest \ deep-backtrace.vgtest deep-backtrace.stderr.exp \ demangle.stderr.exp demangle.vgtest \ big_debuginfo_symbol.stderr.exp big_debuginfo_symbol.vgtest \ @@ -485,7 +487,7 @@ cdebug_zlib_gnu_CFLAGS = $(AM_CFLAGS) -g -gz=zlib-gnu @FLAG_W_NO_UNINITIALIZED@ endif if HAVE_ALIGNED_CXX_ALLOC -check_PROGRAMS += cxx17_aligned_new +check_PROGRAMS += cxx17_aligned_new sized_aligned_new_delete_args endif if HAVE_PTHREAD_BARRIER @@ -546,6 +548,8 @@ bug340392_CFLAGS = $(AM_CFLAGS) -O3 @FLAG_W_NO_MAYBE_UNINITIALIZED@ if HAVE_ALIGNED_CXX_ALLOC cxx17_aligned_new_SOURCES = cxx17_aligned_new.cpp cxx17_aligned_new_CXXFLAGS = -std=c++17 @FLAG_W_NO_MISMATCHED_NEW_DELETE@ +sized_aligned_new_delete_args_SOURCES = sized_aligned_new_delete_args.cpp +sized_aligned_new_delete_args_CXXFLAGS = -std=c++17 endif demangle_SOURCES = demangle.cpp diff --git a/memcheck/tests/sized_aligned_new_delete_args.cpp b/memcheck/tests/sized_aligned_new_delete_args.cpp new file mode 100644 index 0000000000..a8d5024ac5 --- /dev/null +++ b/memcheck/tests/sized_aligned_new_delete_args.cpp @@ -0,0 +1,42 @@ +#include <cstdlib> +#include <new> +#include <iostream> +#include "../memcheck.h" + +int main() { + std::align_val_t align(static_cast<std::align_val_t>(64U)); + std::align_val_t uninitalign(static_cast<std::align_val_t>(64U)); + size_t uninitsize(16); + size_t size(16); + std::nothrow_t tag; + void *mem; + VALGRIND_MAKE_MEM_UNDEFINED(&uninitsize, sizeof(uninitsize)); + VALGRIND_MAKE_MEM_UNDEFINED(&uninitalign, sizeof(uninitalign)); + + mem = operator new(uninitsize, uninitalign); + operator delete(mem, uninitalign); + + mem = operator new[](uninitsize, uninitalign); + operator delete[](mem, uninitalign); + + // doesn't matter that tag is uninit + // don't want to see an error + mem = operator new(uninitsize, uninitalign, tag); + operator delete(mem, uninitalign, tag); + + mem = operator new[](uninitsize, uninitalign, tag); + operator delete[](mem, uninitalign, tag); + + mem = operator new(size); + operator delete(mem, uninitsize); + + mem = operator new[](size); + operator delete[](mem, uninitsize); + + mem = operator new(size, align); + operator delete(mem, uninitsize, uninitalign); + + mem = operator new[](size, align); + operator delete[](mem, uninitsize, uninitalign); +} + diff --git a/memcheck/tests/sized_aligned_new_delete_args.stderr.exp b/memcheck/tests/sized_aligned_new_delete_args.stderr.exp new file mode 100644 index 0000000000..c086f1d266 --- /dev/null +++ b/memcheck/tests/sized_aligned_new_delete_args.stderr.exp @@ -0,0 +1,83 @@ + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator new(unsigned long, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator new(unsigned long, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator delete(void*, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator new[](unsigned long, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator new[](unsigned long, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator delete[](void*, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator new(unsigned long, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...) + by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator new(unsigned long, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...) + by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator delete(void*, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...) + by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator new[](unsigned long, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...) + by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator new[](unsigned long, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...) + by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator delete[](void*, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...) + by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: ...operator delete... (vg_replace_malloc.c:...) + by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator delete[](void*, unsigned long) (vg_replace_malloc.c:...) + by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator delete(void*, unsigned long, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator delete(void*, unsigned long, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator delete[](void*, unsigned long, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: operator delete[](void*, unsigned long, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (in /usr/home/paulf/scratch/valgrind/memcheck/tests/sized_aligned_new_delete_args) + + +HEAP SUMMARY: + in use at exit: 0 bytes in 0 blocks + total heap usage: 8 allocs, 8 frees, 128 bytes allocated + +For a detailed leak analysis, rerun with: --leak-check=full + +Use --track-origins=yes to see where uninitialised values come from +For lists of detected and suppressed errors, rerun with: -s +ERROR SUMMARY: 18 errors from 18 contexts (suppressed: 0 from 0) diff --git a/memcheck/tests/sized_aligned_new_delete_args.vgtest b/memcheck/tests/sized_aligned_new_delete_args.vgtest new file mode 100644 index 0000000000..8df8db4df2 --- /dev/null +++ b/memcheck/tests/sized_aligned_new_delete_args.vgtest @@ -0,0 +1,2 @@ +prog: sized_aligned_new_delete_args +prereq: test -e ./sized_aligned_new_delete_args |
|
From: Paul F. <pa...@so...> - 2023-03-07 07:04:26
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=2715ad4ab5bc0be1e6a3e87aae29cfab90e01668 commit 2715ad4ab5bc0be1e6a3e87aae29cfab90e01668 Author: Paul Floyd <pj...@wa...> Date: Tue Mar 7 08:00:03 2023 +0100 auxchecks: use outer configure make and compilers On FreeBSD the hard coded 'make' will switch to BSD make rather than the outer configure make - GNU make. Similarly for systems with gcc and clang installed then an outer 'configure CC=clang' and then make auxchecks doesn't propagate the CC to the inner gsl configure, which will use gcc. Still need some work on the tarball checksum calculation. Diff: --- auxprogs/Makefile.am | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/auxprogs/Makefile.am b/auxprogs/Makefile.am index c05f82825e..9831ee3b41 100644 --- a/auxprogs/Makefile.am +++ b/auxprogs/Makefile.am @@ -183,9 +183,9 @@ $(GSL_SRC_DIR)/gsl-patched: $(GSL_TAR) $(GSL_BUILD_DIR)/gsl-build: $(GSL_SRC_DIR)/gsl-patched mkdir -p $(GSL_BUILD_DIR) (cd $(GSL_BUILD_DIR) && \ - $(GSL_SRC_DIR)/configure CFLAGS="$(GSL_CFLAGS)" && \ - make -j $(nproc) && \ - make check -k || true) + $(GSL_SRC_DIR)/configure CC="${CC}" CXX="${CXX}" CFLAGS="$(GSL_CFLAGS)" && \ + ${MAKE} -j $(nproc) && \ + ${MAKE} check -k || true) touch $@ # We hope all tests PASS (so don't produce output except for the test names). |
|
From: Paul F. <pa...@so...> - 2023-03-06 20:52:25
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=e8d4d64e46cde7507c3716ad8094d886e8824fa4 commit e8d4d64e46cde7507c3716ad8094d886e8824fa4 Author: Paul Floyd <pj...@wa...> Date: Mon Mar 6 21:50:01 2023 +0100 Bug 466104 - aligned_alloc problems, part 1 I think that these are all now done. This commit refactors memalign and updates manual-core.xml to say some behaviour of Valgrind depends on the build time OS and libraries. Diff: --- NEWS | 1 + coregrind/m_replacemalloc/vg_replace_malloc.c | 124 +++++++++----------------- docs/xml/manual-core.xml | 5 ++ 3 files changed, 50 insertions(+), 80 deletions(-) diff --git a/NEWS b/NEWS index 61c4e03053..bc3f4a363b 100644 --- a/NEWS +++ b/NEWS @@ -98,6 +98,7 @@ are not entered into bugzilla tend to get forgotten about or ignored. 464859 Build failures with GCC-13 (drd tsan_unittest) 464969 D language demangling 465435 m_libcfile.c:66 (vgPlain_safe_fd): Assertion 'newfd >= VG_(fd_hard_limit)' failed. +466104 aligned_alloc problems, part 1 n-i-bz FreeBSD rfork syscall fail with EINVAL or ENOSYS rather than VG_(unimplemented) To see details of a given bug, visit diff --git a/coregrind/m_replacemalloc/vg_replace_malloc.c b/coregrind/m_replacemalloc/vg_replace_malloc.c index 18cbb7f88e..6addfe80f9 100644 --- a/coregrind/m_replacemalloc/vg_replace_malloc.c +++ b/coregrind/m_replacemalloc/vg_replace_malloc.c @@ -1506,6 +1506,7 @@ extern int *___errno (void) __attribute__((weak)); * */ + /* @todo PJF exactly what is the behaviour if this? */ #define ZONEMEMALIGN(soname, fnname) \ \ void* VG_REPLACE_FUNCTION_EZU(10100,soname,fnname) \ @@ -1534,8 +1535,34 @@ extern int *___errno (void) __attribute__((weak)); return v; \ } -#if defined(VGO_linux) -#if !defined(MUSL_LIBC) +#if defined(VGO_freebsd) +#define VG_MEMALIGN_MAKE_SIZE_MULTIPLE_ALIGN 1 +#else +#define VG_MEMALIG_MAKE_SIZE_MULTIPLE_ALIGN 0 +#endif + +#if defined(VGO_solaris) +#define VG_MEMALIGN_ALIGN_POWER_TWO 0 +#else +#define VG_MEMALIGN_ALIGN_POWER_TWO 1 +#endif + +#if defined(VGO_solaris) +#define VG_MEMALIGD_ALIGN_FACTOR_FOUR 1 +#else +#define VG_MEMALIGN_ALIGN_FACTOR_FOUR 0 +#endif + +#if defined(MUSL_LIBC) +#define VG_MEMALIGN_NO_SIZE_ZERO 0 +#else +#define VG_MEMALIGN_NO_SIZE_ZERO 1 +#endif + + + +#if defined(VGO_linux) && !defined(MUSL_LIBC) + #define MEMALIGN(soname, fnname) \ \ void* VG_REPLACE_FUNCTION_EZU(10110,soname,fnname) \ @@ -1562,34 +1589,8 @@ extern int *___errno (void) __attribute__((weak)); if (!v) SET_ERRNO_ENOMEM; \ return v; \ } -#else /* MUSL_LIBC */ -#define MEMALIGN(soname, fnname) \ - \ - void* VG_REPLACE_FUNCTION_EZU(10110,soname,fnname) \ - ( SizeT alignment, SizeT size ); \ - void* VG_REPLACE_FUNCTION_EZU(10110,soname,fnname) \ - ( SizeT alignment, SizeT size ) \ - { \ - void *mem; \ - \ - DO_INIT; \ - if ((alignment & (alignment - 1)) != 0) { \ - SET_ERRNO_EINVAL; \ - return 0; \ - } \ - /* Round up to minimum alignment if necessary. */ \ - if (alignment < VG_MIN_MALLOC_SZB) \ - alignment = VG_MIN_MALLOC_SZB; \ - \ - mem = (void*)VALGRIND_NON_SIMD_CALL2( info.tl_memalign, alignment, size ); \ - \ - if (!mem) SET_ERRNO_ENOMEM; \ - \ - return mem; \ - } -#endif -#elif defined(VGO_freebsd) +#else #define MEMALIGN(soname, fnname) \ \ @@ -1601,70 +1602,31 @@ extern int *___errno (void) __attribute__((weak)); void *mem; \ \ DO_INIT; \ - TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED(size); \ - MALLOC_TRACE("memalign(al %llu, size %llu)\n", \ - (ULong)alignment, (ULong)size ); \ - if ((alignment & (alignment - 1)) != 0) { \ + MALLOC_TRACE("memalign(alignment %llu, size %llu)", \ + (ULong)alignment, (ULong)size ); \ + if ((VG_MEMALIGN_NO_SIZE_ZERO && (alignment == 0)) \ + || (VG_MEMALIGN_ALIGN_POWER_TWO && (alignment & (alignment - 1)) != 0) \ + || (VG_MEMALIGN_ALIGN_FACTOR_FOUR && (alignment % 4 != 0))) { \ SET_ERRNO_EINVAL; \ return 0; \ } \ /* Round up to minimum alignment if necessary. */ \ - if (alignment < VG_MIN_MALLOC_SZB) \ - alignment = VG_MIN_MALLOC_SZB; \ - \ - mem = (void*)VALGRIND_NON_SIMD_CALL2( info.tl_memalign, \ - alignment, VG_ALIGN_ROUNDUP(size, alignment) ); \ - \ - if (!mem) SET_ERRNO_ENOMEM; \ - \ - return mem; \ - } - -#elif defined(VGO_solaris) - -// In the Illumos source there is a macro MINSIZE -// which is sizeof (TREE) - sizeof (WORD) -// struct TREE contains 6 WORDS -// so MINSIZE is 5 words -// -// In gdb I get the impression that sizeof (WORD) is 16 -#define VG_MEMALIGN_MINSIZE (5*VG_WORDSIZE) - -#define MEMALIGN(soname, fnname) \ - \ - void* VG_REPLACE_FUNCTION_EZU(10110,soname,fnname) \ - ( SizeT alignment, SizeT size ); \ - void* VG_REPLACE_FUNCTION_EZU(10110,soname,fnname) \ - ( SizeT alignment, SizeT size ) \ - { \ - void *mem; \ + if (alignment < VG_MIN_MALLOC_SZB) \ + alignment = VG_MIN_MALLOC_SZB; \ + /* Solaris allows non-power of 2 alignment but not Valgrind. */ \ + while (0 != (alignment & (alignment - 1))) alignment++; \ \ - DO_INIT; \ - MALLOC_TRACE("memalign(al %llu, size %llu)\n", \ - (ULong)alignment, (ULong)size ); \ - if (alignment == 0 \ - || (size == 0) \ - || (alignment & 3)) { \ - SET_ERRNO_EINVAL; \ - return 0; \ + if (VG_MEMALIGN_MAKE_SIZE_MULTIPLE_ALIGN) { \ + size = ((size + alignment - 1)/alignment)*alignment; \ } \ - size = VG_ALIGN_ROUNDUP(size, VG_WORDSIZE); \ - if (size < VG_MEMALIGN_MINSIZE) \ - size = VG_MEMALIGN_MINSIZE; \ - alignment = VG_ALIGN_ROUNDUP(alignment, VG_WORDSIZE); \ - while (alignment < VG_MEMALIGN_MINSIZE + VG_WORDSIZE) \ - alignment <<= 1U; \ \ - mem = (void*)VALGRIND_NON_SIMD_CALL2( info.tl_memalign, \ - alignment, VG_ALIGN_ROUNDUP(size, alignment) ); \ + mem = (void*)VALGRIND_NON_SIMD_CALL2( info.tl_memalign, alignment, size ); \ \ if (!mem) SET_ERRNO_ENOMEM; \ \ return mem; \ } -// no Darwin - #endif #if defined(VGO_linux) @@ -1955,6 +1917,7 @@ extern int *___errno (void) __attribute__((weak)); { \ void *mem; \ \ + DO_INIT; \ TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED(size); \ MALLOC_TRACE("aligned_alloc(al %llu, size %llu)", \ (ULong)alignment, (ULong)size ); \ @@ -1982,6 +1945,7 @@ extern int *___errno (void) __attribute__((weak)); { \ void *mem; \ \ + DO_INIT; \ MALLOC_TRACE("aligned_alloc(al %llu, size %llu)", \ (ULong)alignment, (ULong)size ); \ if ((VG_ALIGNED_ALLOC_NO_SIZE_ZERO && (alignment == 0)) \ diff --git a/docs/xml/manual-core.xml b/docs/xml/manual-core.xml index 558d1f62df..3a91c930fa 100644 --- a/docs/xml/manual-core.xml +++ b/docs/xml/manual-core.xml @@ -82,6 +82,11 @@ To make it easier to write suppressions, you can use the print out a suppression for each reported error, which you can then copy into a suppressions file.</para> +<para>Valgrind will try to match the behaviour of applications +compiled to run on the same OS and libraries that Valgrind was +built with. If you use different libraries or a different +OS version there may be some small differences in behaviour.</para> + <para>Different error-checking tools report different kinds of errors. The suppression mechanism therefore allows you to say which tool or tool(s) each suppression applies to.</para> |
|
From: Nicholas N. <n.n...@gm...> - 2023-03-06 11:03:32
|
Hi, Perl was a reasonable choice for `cg_annotate` when I first wrote it 20+ years ago. But it's unfortunate now, with Perl being (a) a pretty weird and horrible language, and (b) moribund. I'd like to rewrite it (and `cg_diff`) in Python, which will make maintenance easier. I see that we already have some Python in Valgrind: `coregrind/m_gdbserver/valgrind-monitor.py` and `coregrind/m_gdbserver/valgrind-monitor-def.py`. Therefore I don't think this should be controversial. But I might as well ask, just in case: any objections or advice? Because these are single file scripts, we avoid all the usual problems of Python packaging, and just use `cp` as the package manager :) On a related note, the `cg_annotate.in`/`cg_annotate` split is annoying. The only reason for it now is to auto-embed the version number into the script, via the configure `@VERSION@` variable, for `cg_annotate --version` output. Does anyone know of a way to achieve that without requiring configure? Thanks. Nick |
|
From: Paul F. <pa...@so...> - 2023-03-05 16:42:16
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=43880cb199e4f467ebeda70b9f6c14b10cd863e5 commit 43880cb199e4f467ebeda70b9f6c14b10cd863e5 Author: Paul Floyd <pj...@wa...> Date: Sun Mar 5 17:41:27 2023 +0100 Linux musl: fix code refactor that missed one usage Diff: --- coregrind/m_replacemalloc/vg_replace_malloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coregrind/m_replacemalloc/vg_replace_malloc.c b/coregrind/m_replacemalloc/vg_replace_malloc.c index d123890a8a..18cbb7f88e 100644 --- a/coregrind/m_replacemalloc/vg_replace_malloc.c +++ b/coregrind/m_replacemalloc/vg_replace_malloc.c @@ -1939,7 +1939,7 @@ extern int *___errno (void) __attribute__((weak)); #endif #if defined(MUSL_LIBC) -#define VG_ALIGNED_ALLOC_SIZE_ZERO 0 +#define VG_ALIGNED_ALLOC_NO_SIZE_ZERO 0 #else #define VG_ALIGNED_ALLOC_NO_SIZE_ZERO 1 #endif |
|
From: Paul F. <pa...@so...> - 2023-03-05 16:23:48
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=b2ca91d66997653c56468be25b416b81a81f5476 commit b2ca91d66997653c56468be25b416b81a81f5476 Author: Paul Floyd <pj...@wa...> Date: Sun Mar 5 17:22:59 2023 +0100 Darwin regtest: again, forgot to delete errno Setting errno on Darwin not supported on Valgrind. Diff: --- memcheck/tests/darwin/aligned_alloc.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/memcheck/tests/darwin/aligned_alloc.c b/memcheck/tests/darwin/aligned_alloc.c index 8d38f593bf..f8d580538f 100644 --- a/memcheck/tests/darwin/aligned_alloc.c +++ b/memcheck/tests/darwin/aligned_alloc.c @@ -9,15 +9,12 @@ int main(void) // zero size p = aligned_alloc(0, 8); assert(p == NULL); - errno = 0; // non multiple of alignment fails on Darwin p = aligned_alloc(8, 25); assert(p == NULL); - errno = 0; // align not power of 2 p = aligned_alloc(40, 160); assert(p == NULL); - errno = 0; // @todo PJF this works standalone // but for some reason it doesn't fail in arena_memalign |
|
From: Paul F. <pa...@so...> - 2023-03-05 16:21:23
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=0fecf3914d52dcc0b783806ab6d4fe9482ad30f8 commit 0fecf3914d52dcc0b783806ab6d4fe9482ad30f8 Author: Paul Floyd <pj...@wa...> Date: Sun Mar 5 17:20:23 2023 +0100 Darwin regtest: remove test that aligned_alloc fails with huge alignment Needs more debugging. Diff: --- coregrind/m_replacemalloc/vg_replace_malloc.c | 4 ++-- memcheck/tests/darwin/aligned_alloc.c | 21 ++++++++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/coregrind/m_replacemalloc/vg_replace_malloc.c b/coregrind/m_replacemalloc/vg_replace_malloc.c index cbb9f038e4..d123890a8a 100644 --- a/coregrind/m_replacemalloc/vg_replace_malloc.c +++ b/coregrind/m_replacemalloc/vg_replace_malloc.c @@ -1941,7 +1941,7 @@ extern int *___errno (void) __attribute__((weak)); #if defined(MUSL_LIBC) #define VG_ALIGNED_ALLOC_SIZE_ZERO 0 #else -#define VG_ALIGNED_ALLOC_SIZE_ZERO 1 +#define VG_ALIGNED_ALLOC_NO_SIZE_ZERO 1 #endif #if defined (VGO_linux) && !defined(MUSL_LIBC) @@ -1984,7 +1984,7 @@ extern int *___errno (void) __attribute__((weak)); \ MALLOC_TRACE("aligned_alloc(al %llu, size %llu)", \ (ULong)alignment, (ULong)size ); \ - if ((VG_ALIGNED_ALLOC_SIZE_ZERO && (alignment == 0)) \ + if ((VG_ALIGNED_ALLOC_NO_SIZE_ZERO && (alignment == 0)) \ || (VG_ALIGNED_ALLOC_SIZE_MULTIPLE_ALIGN && (size % alignment != 0)) \ || (VG_ALIGNED_ALLOC_ALIGN_POWER_TWO && (alignment & (alignment - 1)) != 0) \ || (VG_ALIGNED_ALLOC_ALIGN_FACTOR_FOUR && (alignment % 4 != 0))) { \ diff --git a/memcheck/tests/darwin/aligned_alloc.c b/memcheck/tests/darwin/aligned_alloc.c index 13b04525a5..8d38f593bf 100644 --- a/memcheck/tests/darwin/aligned_alloc.c +++ b/memcheck/tests/darwin/aligned_alloc.c @@ -1,6 +1,5 @@ #include <stdlib.h> #include <assert.h> -#include <errno.h> int main(void) { @@ -9,19 +8,24 @@ int main(void) // zero size p = aligned_alloc(0, 8); - assert(p == NULL && errno == EINVAL); + assert(p == NULL); errno = 0; // non multiple of alignment fails on Darwin p = aligned_alloc(8, 25); - assert(p == NULL && errno == EINVAL); + assert(p == NULL); errno = 0; // align not power of 2 p = aligned_alloc(40, 160); - assert(p == NULL && errno == EINVAL); + assert(p == NULL); errno = 0; - // the test below causes a segfault with musl 1.2.2 - // apparently it has been + // @todo PJF this works standalone + // but for some reason it doesn't fail in arena_memalign + // and I see + // ==25899== Warning: set address range perms: large range [0x1000, 0x1000000001000) (defined) + + +#if 0 // too big if (sizeof(size_t) == 8) { @@ -30,11 +34,10 @@ int main(void) else { p = NULL; - errno = ENOMEM; } - assert(p == NULL && errno == ENOMEM); - + assert(p == NULL); +#endif } |
|
From: Paul F. <pa...@so...> - 2023-03-05 15:49:57
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=b07d06888720187221660c6b5d54a20f7fcc3112 commit b07d06888720187221660c6b5d54a20f7fcc3112 Author: Paul Floyd <pj...@wa...> Date: Sun Mar 5 16:49:12 2023 +0100 Linux musl: one more iteration for aligned_alloc, assert in wrong place Diff: --- memcheck/tests/linux/aligned_alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/memcheck/tests/linux/aligned_alloc.c b/memcheck/tests/linux/aligned_alloc.c index 0cffe085b3..6585580d8b 100644 --- a/memcheck/tests/linux/aligned_alloc.c +++ b/memcheck/tests/linux/aligned_alloc.c @@ -35,9 +35,9 @@ int main(void) p = NULL; errno = ENOMEM; } -#endif assert(p == NULL && errno == ENOMEM); #endif +#endif } |