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
(19) |
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
|
|
|
|
|
|
1
|
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
|
9
|
10
|
11
|
12
(1) |
13
|
14
|
15
(1) |
|
16
(1) |
17
|
18
(6) |
19
(7) |
20
(3) |
21
|
22
(4) |
|
23
(3) |
24
(3) |
25
(1) |
26
|
27
|
28
(3) |
29
|
|
30
|
31
(1) |
|
|
|
|
|
|
From: Mark W. <ma...@kl...> - 2022-10-18 21:31:08
|
Hi, On Wed, Oct 19, 2022 at 07:03:56AM +1100, Nicholas Nethercote wrote: > It would be great to have a new release out. Currently you have to use a > trunk build of Valgrind with Rust code because of Dwarf 5 features that > Rust uses. I admit that I had wanted to do more work before the release, thinking 7 weeks was enough time. Now it suddenly is in less than a week... But I don't believe we have any regressions. So it is probably still a good idea to just do a new release. Lots of people only use actualy releases. continued below... On Wed, 19 Oct 2022 at 04:51, Carl Love <ce...@us...> wrote: > I was thinking the date is fast approaching and I hadn't seen anything > on a release. > > At this point, the Power support is all in place I don't have anything > pending. Not sure about other architectures. > > I will be out of the office next week so will not be able to test any > release candidates next week. > > Anyway, just thought someone should poke at this and see how things > stand for doing a release. I think Power is indeed in a good state. Paul said on irc that FreeBSD also looks good. He is looking at some FreeBSD 14 (the unstable dev branch) issues, but those shouldn't be blocking. There are some issues with the auxchecks against newer glibc, that runs an older gnu scientific library testsuite which shows some issues with random* tests. But I think this isn't a valgrind bug, it looks like a change in how glibc handles some random bits/calls. But I don't know about any other issues/regressions. I'll try to do a test/rc release tomorrow and see how things look. Cheers, Mark |
|
From: Paul F. <pa...@so...> - 2022-10-18 20:55:46
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=12d2a3c85d41db5f540ce3a21cba749641ce4a31 commit 12d2a3c85d41db5f540ce3a21cba749641ce4a31 Author: Paul Floyd <pj...@wa...> Date: Wed Oct 19 00:51:05 2022 +0200 Auxv user stack for FreeBSD, last part Clean up, didn't need an extra func for user stack limit. Diff: --- coregrind/m_initimg/initimg-freebsd.c | 2 +- coregrind/m_main.c | 5 ----- coregrind/pub_core_aspacemgr.h | 1 - none/tests/freebsd/auxv.c | 2 +- none/tests/freebsd/auxv.stderr.exp-freebsd14 | 26 ++++++++++++++++++++++++++ 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/coregrind/m_initimg/initimg-freebsd.c b/coregrind/m_initimg/initimg-freebsd.c index 43b88948af..8188e60d90 100644 --- a/coregrind/m_initimg/initimg-freebsd.c +++ b/coregrind/m_initimg/initimg-freebsd.c @@ -718,7 +718,7 @@ Addr setup_client_stack( void* init_sp, auxv->u.a_val = VG_(get_usrstack)(); break; case AT_USRSTACKLIM: - auxv->u.a_val = VG_(get_usrstacklim)(); + auxv->u.a_val = clstack_max_size; break; #endif diff --git a/coregrind/m_main.c b/coregrind/m_main.c index 327a130a80..f02a8b0eb5 100644 --- a/coregrind/m_main.c +++ b/coregrind/m_main.c @@ -3908,11 +3908,6 @@ Word VG_(get_usrstack)(void) { return VG_PGROUNDDN(the_iicii.clstack_end) + VKI_PAGE_SIZE; } - -Word VG_(get_usrstacklim)(void) -{ - return the_iifii.clstack_max_size; -} #endif diff --git a/coregrind/pub_core_aspacemgr.h b/coregrind/pub_core_aspacemgr.h index 1a73ac1a34..b867108a22 100644 --- a/coregrind/pub_core_aspacemgr.h +++ b/coregrind/pub_core_aspacemgr.h @@ -387,7 +387,6 @@ extern Bool VG_(am_search_for_new_segment)(Addr *start, SizeT *size, #if defined(VGO_freebsd) /* For kern.usrstack syscall on FreeBSD */ extern Word VG_(get_usrstack)(void); -extern Word VG_(get_usrstacklim)(void); #endif #endif // __PUB_CORE_ASPACEMGR_H diff --git a/none/tests/freebsd/auxv.c b/none/tests/freebsd/auxv.c index 778280b39a..49911deaed 100644 --- a/none/tests/freebsd/auxv.c +++ b/none/tests/freebsd/auxv.c @@ -55,7 +55,7 @@ Elf_AuxStr aux_map[AT_COUNT] = { #endif #if (FREEBSD_VERS >= FREEBSD_14) {"AT_USRSTACKBASE", 35}, - {"AT_USRSTACKLIM", 36), + {"AT_USRSTACKLIM", 36}, // {"AT_COUNT", 37}, #endif }; diff --git a/none/tests/freebsd/auxv.stderr.exp-freebsd14 b/none/tests/freebsd/auxv.stderr.exp-freebsd14 new file mode 100644 index 0000000000..76c6db5759 --- /dev/null +++ b/none/tests/freebsd/auxv.stderr.exp-freebsd14 @@ -0,0 +1,26 @@ +val: AT_PHDR int: 03 ptr: 0x........ +val: AT_PHENT int: 04 ptr: 0x........ +val: AT_PHNUM int: 05 ptr: 0x........ +val: AT_PAGESZ int: 06 ptr: 0x........ +val: AT_FLAGS int: 08 ptr: 0x........ +val: AT_ENTRY int: 09 ptr: 0x........ +val: AT_BASE int: 07 ptr: 0x........ +val: AT_EHDRFLAGS int: 24 ptr: 0x........ +val: AT_EXECPATH int: 15 ptr: 0x........ +val: AT_OSRELDATE int: 18 ptr: 0x........ +val: AT_CANARY int: 16 ptr: 0x........ +val: AT_CANARYLEN int: 17 ptr: 0x........ +val: AT_NCPUS int: 19 ptr: 0x........ +val: AT_PAGESIZES int: 20 ptr: 0x........ +val: AT_PAGESIZESLEN int: 21 ptr: 0x........ +val: AT_IGNORE int: 01 ptr: 0x........ +val: AT_STACKPROT int: 23 ptr: 0x........ +val: AT_IGNORE int: 01 ptr: 0x........ +val: AT_ARGC int: 28 ptr: 0x........ +val: AT_ARGV int: 29 ptr: 0x........ +val: AT_ENVC int: 30 ptr: 0x........ +val: AT_ENVV int: 31 ptr: 0x........ +val: AT_PS_STRINGS int: 32 ptr: 0x........ +val: AT_IGNORE int: 01 ptr: 0x........ +val: AT_USRSTACKBASE int: 35 ptr: 0x........ +val: AT_USRSTACKLIM int: 36 ptr: 0x........ |
|
From: Paul F. <pa...@so...> - 2022-10-18 20:12:26
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=802f2d21d9e0148393845616a329a8041353e2f3 commit 802f2d21d9e0148393845616a329a8041353e2f3 Author: Paul Floyd <pj...@wa...> Date: Tue Oct 18 22:11:32 2022 +0200 Auxv user stack for FreeBSD, part 2 Try to set the stack limit. Diff: --- coregrind/m_initimg/initimg-freebsd.c | 2 +- coregrind/m_main.c | 8 +++++++- coregrind/m_syswrap/syswrap-freebsd.c | 4 ++-- coregrind/pub_core_aspacemgr.h | 4 +++- none/tests/freebsd/auxv.c | 12 ++++++++---- 5 files changed, 21 insertions(+), 9 deletions(-) diff --git a/coregrind/m_initimg/initimg-freebsd.c b/coregrind/m_initimg/initimg-freebsd.c index 920ed92911..43b88948af 100644 --- a/coregrind/m_initimg/initimg-freebsd.c +++ b/coregrind/m_initimg/initimg-freebsd.c @@ -718,7 +718,7 @@ Addr setup_client_stack( void* init_sp, auxv->u.a_val = VG_(get_usrstack)(); break; case AT_USRSTACKLIM: - auxv->a_type = AT_IGNORE; + auxv->u.a_val = VG_(get_usrstacklim)(); break; #endif diff --git a/coregrind/m_main.c b/coregrind/m_main.c index 200da407fb..327a130a80 100644 --- a/coregrind/m_main.c +++ b/coregrind/m_main.c @@ -3903,12 +3903,18 @@ UWord voucher_mach_msg_set ( UWord arg1 ) #endif - +#if defined(VGO_freebsd) Word VG_(get_usrstack)(void) { return VG_PGROUNDDN(the_iicii.clstack_end) + VKI_PAGE_SIZE; } +Word VG_(get_usrstacklim)(void) +{ + return the_iifii.clstack_max_size; +} +#endif + /*--------------------------------------------------------------------*/ diff --git a/coregrind/m_syswrap/syswrap-freebsd.c b/coregrind/m_syswrap/syswrap-freebsd.c index 518eaf0871..0fad6aa844 100644 --- a/coregrind/m_syswrap/syswrap-freebsd.c +++ b/coregrind/m_syswrap/syswrap-freebsd.c @@ -2022,7 +2022,7 @@ PRE(sys___sysctl) /* * Special handling cases * - * 1. kern.userstack + * 1. kern.usrstack * This sysctl returns the address of the bottom of the user stack * (that is the highest user stack address, since the stack grows * downwards). Without any special handling this would return the @@ -2034,7 +2034,7 @@ PRE(sys___sysctl) */ if (SARG2 >= 2 && ML_(safe_to_deref)(name, 2*sizeof(int))) { if (name[0] == 1 && name[1] == 33) { - // kern.userstack + // kern.usrstack sysctl_kern_usrstack((SizeT*)ARG3, (SizeT*)ARG4); SET_STATUS_Success(0); } diff --git a/coregrind/pub_core_aspacemgr.h b/coregrind/pub_core_aspacemgr.h index aac2a0a321..1a73ac1a34 100644 --- a/coregrind/pub_core_aspacemgr.h +++ b/coregrind/pub_core_aspacemgr.h @@ -384,9 +384,11 @@ extern Bool VG_(am_search_for_new_segment)(Addr *start, SizeT *size, UInt *prot); #endif +#if defined(VGO_freebsd) /* For kern.usrstack syscall on FreeBSD */ extern Word VG_(get_usrstack)(void); - +extern Word VG_(get_usrstacklim)(void); +#endif #endif // __PUB_CORE_ASPACEMGR_H diff --git a/none/tests/freebsd/auxv.c b/none/tests/freebsd/auxv.c index 9033c3427e..778280b39a 100644 --- a/none/tests/freebsd/auxv.c +++ b/none/tests/freebsd/auxv.c @@ -38,7 +38,7 @@ Elf_AuxStr aux_map[AT_COUNT] = { {"AT_HWCAP", 25}, {"AT_HWCAP2", 26}, // FreeBSD 12 and 11 -// {"AT_COUNT", 27}, +// {"AT_COUNT", 27}, #if (FREEBSD_VERS >= FREEBSD_13_0) {"AT_BSDFLAGS", 27}, {"AT_ARGC", 28}, @@ -46,13 +46,17 @@ Elf_AuxStr aux_map[AT_COUNT] = { {"AT_ENVC", 30}, {"AT_ENVV", 31}, {"AT_PS_STRINGS", 32}, -// {"AT_COUNT", 33}, +// {"AT_COUNT", 33}, #endif #if (FREEBSD_VERS >= FREEBSD_13_1) {"AT_FXRNG", 33}, {"AT_KPRELOAD", 34}, - -// {"AT_COUNT", 35}, +// {"AT_COUNT", 35}, +#endif +#if (FREEBSD_VERS >= FREEBSD_14) + {"AT_USRSTACKBASE", 35}, + {"AT_USRSTACKLIM", 36), +// {"AT_COUNT", 37}, #endif }; |
|
From: Nicholas N. <n.n...@gm...> - 2022-10-18 20:04:14
|
It would be great to have a new release out. Currently you have to use a trunk build of Valgrind with Rust code because of Dwarf 5 features that Rust uses. Nick On Wed, 19 Oct 2022 at 04:51, Carl Love <ce...@us...> wrote: > > Mark: > > On Mon, 2022-09-05 at 20:29 +0200, Mark Wielaard wrote: > > Hi, > > > > The last few releases were 6 months apart around in April and > > October. > > I propose we try to do the next release in October again. If possible > > I > > would like to try to aim for October 22. Which gives us ~7 weeks from > > now. > > > > Please look at features and bugs you could finish in about a month, > > then we have ~2 weeks for stabilization and fixups. > > I was thinking the date is fast approaching and I hadn't seen anything > on a release. > > At this point, the Power support is all in place I don't have anything > pending. Not sure about other architectures. > > I will be out of the office next week so will not be able to test any > release candidates next week. > > Anyway, just thought someone should poke at this and see how things > stand for doing a release. > > Carl Love > > > > _______________________________________________ > Valgrind-developers mailing list > Val...@li... > https://lists.sourceforge.net/lists/listinfo/valgrind-developers > |
|
From: Paul F. <pa...@so...> - 2022-10-18 19:57:55
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=121374b287ce39ef0e42e45dfc27ae0949e6f528 commit 121374b287ce39ef0e42e45dfc27ae0949e6f528 Author: Paul Floyd <pj...@wa...> Date: Tue Oct 18 23:38:36 2022 +0200 Add auxv entry for usrstack on FreeBSD 14, part 1 Previously the user stack was obtained using the kern.usrstack sysctl. This has been moved to auxv in FreeBSD 14. Without this change all programs linked with libthr fail with a panic when they fail to get a valid user stack address. Note also in FreeBSD 14 ASLR has been enabled. This means that there is now some extra difference between the address layout of a standalone executable and the same executable under valgrind. Pre-FreeBSD 14 and under valgrind: lib rtld is loaded after the executable (though a much smaller gap inder valgrind) user stack starts at 0x7ffffffff000 FreeBSD 14 lib rtld is loaded at a much higher address, around 0xeeeecc15000 user stack is at a much lower address, around 0x82073d000 This means that valgrind behaves somewhat as thogh the kern.elf(64|32).aslr.stack sysctl were set to 0. Some more work will be needed for the stack size. There are no plans at the moment to match the FreeBSD 14 memory layout. Diff: --- coregrind/m_initimg/initimg-freebsd.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/coregrind/m_initimg/initimg-freebsd.c b/coregrind/m_initimg/initimg-freebsd.c index f315a147ff..920ed92911 100644 --- a/coregrind/m_initimg/initimg-freebsd.c +++ b/coregrind/m_initimg/initimg-freebsd.c @@ -713,6 +713,15 @@ Addr setup_client_stack( void* init_sp, // case AT_KPRELOAD: #endif +#if (FREEBSD_VERS >= FREEBSD_14) + case AT_USRSTACKBASE: + auxv->u.a_val = VG_(get_usrstack)(); + break; + case AT_USRSTACKLIM: + auxv->a_type = AT_IGNORE; + break; +#endif + case AT_PHDR: if (info->phdr == 0) auxv->a_type = AT_IGNORE; |
|
From: Carl L. <ce...@us...> - 2022-10-18 17:50:34
|
Mark:
On Mon, 2022-09-05 at 20:29 +0200, Mark Wielaard wrote:
> Hi,
>
> The last few releases were 6 months apart around in April and
> October.
> I propose we try to do the next release in October again. If possible
> I
> would like to try to aim for October 22. Which gives us ~7 weeks from
> now.
>
> Please look at features and bugs you could finish in about a month,
> then we have ~2 weeks for stabilization and fixups.
I was thinking the date is fast approaching and I hadn't seen anything
on a release.
At this point, the Power support is all in place I don't have anything
pending. Not sure about other architectures.
I will be out of the office next week so will not be able to test any
release candidates next week.
Anyway, just thought someone should poke at this and see how things
stand for doing a release.
Carl Love
|
|
From: Paul F. <pa...@so...> - 2022-10-16 17:42:33
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=b31ff3321e57b774b48c6b547045cb8b089d152a commit b31ff3321e57b774b48c6b547045cb8b089d152a Author: Paul Floyd <pj...@wa...> Date: Sun Oct 16 18:58:52 2022 +0200 Improve FreeBSD handling of W^X setting. FreeBSD has a sysctl that prevents mmapping regions that are both Write and Exec. This setting prevents Valgrind from workig correctly. This change uses ELF tags to turn off W^X control, and also removes a sysctl check for the same flag. Patch contributor: https://github.com/semihalf-Duleba-Kornel/valgrind/commit/0a3a794143f7c451a5a00e598854ae8d813f8f17 Diff: --- coregrind/m_debuginfo/readelf.c | 2 +- coregrind/m_main.c | 85 ++++++++++++++++++++--------------------- include/vki/vki-freebsd.h | 10 ++--- 3 files changed, 47 insertions(+), 50 deletions(-) diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c index 25d237b7de..6cf08f666f 100644 --- a/coregrind/m_debuginfo/readelf.c +++ b/coregrind/m_debuginfo/readelf.c @@ -1171,7 +1171,7 @@ void read_and_set_osrel(DiImage* img) DiOffT name_ioff = note_ioff + sizeof(ElfXX_Nhdr); //DiOffT desc_ioff = name_ioff + ((note[0].n_namesz + 3) & ~3); if (ML_(img_strcmp_c)(img, name_ioff, "FreeBSD") == 0 - && note[0].n_type == NT_FREEBSD_ABI_TAG) { + && note[0].n_type == VKI_NT_FREEBSD_ABI_TAG) { u_int32_t osrel = note[1].n_type; int name[4]; diff --git a/coregrind/m_main.c b/coregrind/m_main.c index 25882e7cea..200da407fb 100644 --- a/coregrind/m_main.c +++ b/coregrind/m_main.c @@ -1373,50 +1373,6 @@ Int valgrind_main ( Int argc, HChar **argv, HChar **envp ) VG_(exit)(1); } - - //-------------------------------------------------------------- - // FreeBSD also check for sysctl kern.elf64.allow_wx=0 - // This is a sysctl that prevents applications from mmap'ing - // segments that are writeable and executable - //-------------------------------------------------------------- -#if defined(VGP_amd64_freebsd) - error = VG_(sysctlbyname)("kern.elf64.allow_wx", &val, &len, 0, 0); - if (error != -1 && val != 1) { - VG_(debugLog)(0, "main", "Valgrind: FATAL:\n"); - VG_(debugLog)(0, "main", "sysctl kern.elf64.allow_wx sysctl is 0.\n"); - VG_(debugLog)(0, "main", " Set this sysctl with\n"); - VG_(debugLog)(0, "main", " 'sysctl kern.elf64.allow_wx sysctl=1'.\n"); - // the below code doesn't work as I expected - // the proccontrol command doesn't cause sysctlbyname to get a modified value - // which means that valgrind will still detect allow_wx == 0 and exit here -//#if (FREEBSD_VERS >= FREEBSD_13_1) -// VG_(debugLog)(0, "main", " Or, alternatively, run valgrind with\n"); -// VG_(debugLog)(0, "main", " 'proccontrol -m wxmap -s enable valgrind [options] prog-and-args'\n"); -//#endif - VG_(debugLog)(0, "main", " Cannot continue.\n"); - - VG_(exit)(1); - } - -#endif - - /* also 323bit version */ -#if defined(VGP_x86_freebsd) - error = VG_(sysctlbyname)("kern.elf32.allow_wx", &val, &len, 0, 0); - if (error != -1 && val != 1) { - VG_(debugLog)(0, "main", "Valgrind: FATAL:\n"); - VG_(debugLog)(0, "main", "sysctl kern.elf32.allow_wx sysctl is 0.\n"); - VG_(debugLog)(0, "main", " Set this sysctl with\n"); - VG_(debugLog)(0, "main", " 'sysctl kern.elf32.allow_wx sysctl=1'.\n"); -//#if (FREEBSD_VERS >= FREEBSD_13_1) -// VG_(debugLog)(0, "main", " Or, alternatively, run valgrind with\n"); -// VG_(debugLog)(0, "main", " 'proccontrol -m wxmap -s enable valgrind [options] prog-and-args'\n"); -//#endif - VG_(debugLog)(0, "main", " Cannot continue.\n"); - - VG_(exit)(1); - } -#endif #endif @@ -3351,6 +3307,47 @@ void _start_in_C_solaris ( UWord* pArgc ) /*====================================================================*/ #elif defined(VGO_freebsd) +/* + * Could probably extract __FreeBSD_version at configure time + */ +/* --- !!! --- EXTERNAL HEADERS start --- !!! --- */ +#include <sys/param.h> /* __FreeBSD_version */ +/* --- !!! --- EXTERNAL HEADERS end --- !!! --- */ + +/* + * We need to add two elf notes in order for image activator to parse + * additional binary properites. + * First note declares the ABI, second is the feature note. + * This is primarly used to turn off W^X policy for all valgrind tools, + * as they don't work with it enabled. + */ + +/* Based on FreeBSD sources: lib/csu/common/crtbrand.S */ +asm("\n" + ".section .note.tag,\"aG\",%note,.freebsd.noteG,comdat\n" + ".p2align 2\n" + ".4byte 2f-1f\n" + ".4byte 4f-3f\n" + ".4byte "VG_STRINGIFY(VKI_NT_FREEBSD_ABI_TAG)"\n" +"1: .asciz \"FreeBSD\"\n" +"2: .p2align 2\n" +"3: .4byte "VG_STRINGIFY(__FreeBSD_version)"\n" +"4: .previous\n" +); + +/* Based on FreeBSD sources: lib/csu/common/feature_note.S */ +asm("\n" + ".section .note.tag,\"a\",%note\n" + ".p2align 2\n" + ".4byte 2f-1f\n" + ".4byte 4f-3f\n" + ".4byte "VG_STRINGIFY(VKI_NT_FREEBSD_FEATURE_CTL)"\n" +"1: .asciz \"FreeBSD\"\n" +"2: .p2align 2\n" +"3: .4byte "VG_STRINGIFY(VKI_NT_FREEBSD_FCTL_WXNEEDED)"\n" +"4: .previous\n" +); + #if defined(VGP_x86_freebsd) asm("\n" ".text\n" diff --git a/include/vki/vki-freebsd.h b/include/vki/vki-freebsd.h index c2234664d6..c7481f31c7 100644 --- a/include/vki/vki-freebsd.h +++ b/include/vki/vki-freebsd.h @@ -200,7 +200,7 @@ typedef __vki_fd_set vki_fd_set; #endif //---------------------------------------------------------------------- -// linux and freebsd version hacks +// freebsd version hacks //---------------------------------------------------------------------- #ifndef ELFMAG #define ELFMAG "\177ELF" /* magic string */ @@ -214,10 +214,6 @@ typedef __vki_fd_set vki_fd_set; #define ELF_NOTE_GNU "GNU" #endif -// This is not defined on FreeBSD 10.4 -#if !defined(NT_FREEBSD_ABI_TAG) -#define NT_FREEBSD_ABI_TAG 1 -#endif #define VKI_ELF_NOTE_ROUNDSIZE 4 @@ -2485,6 +2481,10 @@ struct vki_ps_strings { #define VKI_AT_NULL 0 #define VKI_AT_PS_STRINGS 32 +#define VKI_NT_FREEBSD_ABI_TAG 1 +#define VKI_NT_FREEBSD_FEATURE_CTL 4 +#define VKI_NT_FREEBSD_FCTL_WXNEEDED 0x00000008 + // See syswrap-freebsd.c PRE/POST(sys_ioctl) #if 0 |
|
From: Philippe W. <phi...@so...> - 2022-10-15 22:45:12
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=348775f34ba073af3307489f0689f961f6de8854 commit 348775f34ba073af3307489f0689f961f6de8854 Author: Philippe Waroquiers <phi...@sk...> Date: Sat Oct 15 22:59:08 2022 +0200 Remove register cache to fix 458915 gdbserver causes wrong syscall return The valgrind gdbserver inheritated a register cache from the original GDBserver implementation. The objective of this register cache was to improve the performance of GDB-> gdbserver -> inferior by avoiding the gdbserver having to do ptrace system calls each time GDB wants to read or write a register when the inferior is stopped. This register cache is however not useful for the valgrind gdbserver: As the valgrind gdbserver being co-located with the inferior, it can directly and efficiently read and write registers from/to the VEX state. This commit ensures the valgrind GDBserver directly reads from VEX state instead of fetching the registers from the VEX state and copying them to the gdbserver regcache. Similarly, when GDB wants to modify a register, the valgrind GDB server now directly writes into the VEX state instead of writing the registers in the regcache and having the regcache flushed to the VEX state when execution is resumed. The files regcache.h and regcache.c are still useful as they provide a translation between a register number, a register name on one side and the offset in an array of bytes in the format expected by GDB. The regcache now is only used to create this array of bytes, which is itself only used temporarily when GDB reads or writes the complete set of registers instead of reading/writing one register at a time. Removing the usage of this regcache avoids the bug 458915. The regcache was causing the bug in the following circumstances: We have a thread executing code, while we have a bunch of threads that are blocked in a syscall. When a thread is blocked in a syscall, the VEX rax register is set to the syscall nr. A thread executing code will check from time to time if GDB tries to attach. When GDB attaches to the valgrind gdbserver , the thread executing code will copy the registers from all the threads to the thread gdbserver regcache. However, the threads blocked in a system call can be unblocked e.g. because the epoll_wait timeout expires. In such a case, the thread will still execute the few instructions that follow the syscall instructions till the thread is blocked trying to acquire the scheduler lock. These instructions are extracting the syscall return code from the host register and copies it to the valgrind VEX state. However, this assembly code is not aware that there is a gdbserver cache. When the unblocked thread is on the acquire lock statement, the GDB server regcache is now inconsistent (i.e. different from) the real VEX state. When finally GDB tells GDB server to continue execution, the GDB server wrongly detected that its regcache was modified compared to the VEX state: the regcache still contains e.g. for the rax register the syscall number while the unblocked thread has put the syscall return code in the VEX rax register. GDBserver then flushed the regcache rax (containing the syscall number) to the VEX rax. And that led to the detected bug that the syscall return code seen by the guest application was the syscall number. Removing the regcache ensures that GDB directly reads the values from VEX and directly writes to VEX state. Note that we could still have GDB reading from VEX a register value that will be changed a few instructions later. GDB will then show some (slightly) old/obsolete values for some registers to the user. This should have no consequence as long as GDB does not try to modify the registers to execute an inferior call. The bug did not happen systematically as most of the time, when threads are blocked in syscalls, vgdb attaches using ptrace to the valgrind process. When vgdb attaches with ptrace, it stops all the threads using linux syscall. When vgdb stops the threads, the threads blocked in a syscall will not execute the instructions between the syscall instruction and the lock acquire, and so the problem of desynchronisation between the VEX state and the register cache could not happen. This commit touches architecture specific files of the gdbserver, it has been tested on amd64/debian, on pcc64/centos and on arm64/ubuntu. Possibly, some untested arch might not compile but the fix should be trivial. Diff: --- NEWS | 1 + coregrind/m_gdbserver/regcache.c | 100 +++------------- coregrind/m_gdbserver/regcache.h | 28 ++--- coregrind/m_gdbserver/remote-utils.c | 2 +- coregrind/m_gdbserver/server.c | 3 +- coregrind/m_gdbserver/server.h | 2 +- coregrind/m_gdbserver/target.c | 157 ++++++++++---------------- coregrind/m_gdbserver/target.h | 10 +- coregrind/m_gdbserver/valgrind-low-amd64.c | 9 +- coregrind/m_gdbserver/valgrind-low-arm.c | 7 +- coregrind/m_gdbserver/valgrind-low-arm64.c | 7 +- coregrind/m_gdbserver/valgrind-low-mips32.c | 7 +- coregrind/m_gdbserver/valgrind-low-mips64.c | 7 +- coregrind/m_gdbserver/valgrind-low-nanomips.c | 7 +- coregrind/m_gdbserver/valgrind-low-ppc32.c | 7 +- coregrind/m_gdbserver/valgrind-low-ppc64.c | 7 +- coregrind/m_gdbserver/valgrind-low-s390x.c | 7 +- coregrind/m_gdbserver/valgrind-low-x86.c | 7 +- 18 files changed, 112 insertions(+), 263 deletions(-) diff --git a/NEWS b/NEWS index e6094b5bf2..a5c0a2d017 100644 --- a/NEWS +++ b/NEWS @@ -51,6 +51,7 @@ are not entered into bugzilla tend to get forgotten about or ignored. n-i-bz Implement vgdb invoker on FreeBSD 458845 PowerPC: The L field for the dcbf and sync instruction should be 3 bits in ISA 3.1. +458915 Remove register cache to fix 458915 gdbserver causes wrong syscall return 459031 Documentation on --error-exitcode incomplete 459477 XERROR messages lacks ending '\n' in vgdb diff --git a/coregrind/m_gdbserver/regcache.c b/coregrind/m_gdbserver/regcache.c index 6b3d54bd89..7357967d2c 100644 --- a/coregrind/m_gdbserver/regcache.c +++ b/coregrind/m_gdbserver/regcache.c @@ -29,9 +29,7 @@ struct inferior_regcache_data { - int registers_valid; unsigned char *registers; - Bool *register_supplied; /* set to True once it has been supplied */ }; static int register_bytes; @@ -42,8 +40,7 @@ static int num_registers; const char **gdbserver_expedite_regs; static -struct inferior_regcache_data * get_regcache (struct thread_info *inf, - int fetch) +struct inferior_regcache_data * get_regcache (struct thread_info *inf) { struct inferior_regcache_data *regcache; @@ -52,38 +49,9 @@ struct inferior_regcache_data * get_regcache (struct thread_info *inf, if (regcache == NULL) fatal ("no register cache\n"); - /* FIXME - fetch registers for INF */ - if (fetch && regcache->registers_valid == 0) { - valgrind_fetch_registers (0); - regcache->registers_valid = 1; - } - return regcache; } -void regcache_invalidate_one (struct inferior_list_entry *entry) -{ - struct thread_info *thread = (struct thread_info *) entry; - struct inferior_regcache_data *regcache; - - regcache = (struct inferior_regcache_data *) inferior_regcache_data (thread); - - if (regcache->registers_valid) { - struct thread_info *saved_inferior = current_inferior; - - current_inferior = thread; - valgrind_store_registers (-1); - current_inferior = saved_inferior; - } - - regcache->registers_valid = 0; -} - -void regcache_invalidate () -{ - for_each_inferior (&all_threads, regcache_invalidate_one); -} - int registers_length (void) { return 2 * register_bytes; @@ -92,7 +60,7 @@ int registers_length (void) void *new_register_cache (void) { struct inferior_regcache_data *regcache; - + regcache = malloc (sizeof (*regcache)); /* Make sure to zero-initialize the register cache when it is created, @@ -102,12 +70,6 @@ void *new_register_cache (void) if (regcache->registers == NULL) fatal ("Could not allocate register cache.\n"); - regcache->register_supplied = calloc (1, num_registers); - if (regcache->register_supplied == NULL) - fatal ("Could not allocate register_supplied cache.\n"); - - regcache->registers_valid = 0; - return regcache; } @@ -117,7 +79,6 @@ void free_register_cache (void *regcache_p) = (struct inferior_regcache_data *) regcache_p; free (regcache->registers); - free (regcache->register_supplied); free (regcache); } @@ -142,7 +103,7 @@ void regcache_realloc_one (struct inferior_list_entry *entry) void set_register_cache (struct reg *regs, int n) { int offset, i; - + reg_defs = regs; num_registers = n; @@ -159,15 +120,17 @@ void set_register_cache (struct reg *regs, int n) void registers_to_string (char *buf) { - unsigned char *registers = get_regcache (current_inferior, 1)->registers; + unsigned char *registers = get_regcache (current_inferior)->registers; + for (int i = 0; i < num_registers; i++) + valgrind_fetch_register (i, registers + (reg_defs[i].offset / 8)); convert_int_to_ascii (registers, buf, register_bytes); } void registers_from_string (const char *buf) { int len = strlen (buf); - unsigned char *registers = get_regcache (current_inferior, 1)->registers; + unsigned char *registers = get_regcache (current_inferior)->registers; if (len != register_bytes * 2) { warning ("Wrong sized register packet (expected %d bytes, got %d)\n", @@ -199,62 +162,33 @@ int register_size (int n) return reg_defs[n].size / 8; } -static -unsigned char *register_data (int n, int fetch) -{ - unsigned char *registers - = get_regcache (current_inferior, fetch)->registers; - - return registers + (reg_defs[n].offset / 8); -} -static -unsigned char *register_data_for_supply (int n, int fetch, Bool *mod) -{ - struct inferior_regcache_data * cache - = get_regcache (current_inferior, fetch); - unsigned char *registers = cache->registers; - - if (cache->register_supplied[n]) - *mod = False; - else - *mod = True; - cache->register_supplied[n] = True; - return registers + (reg_defs[n].offset / 8); -} - -void supply_register (int n, const void *buf, Bool *mod) +void supply_register (int n, const void *buf) { - Bool new; - VG_(dmemcpy) (register_data_for_supply (n, 0, &new), - buf, register_size (n), mod); - if (new) - *mod = True; + valgrind_store_register (n, buf); } -void supply_register_from_string (int n, const char *buf, Bool *mod) +void supply_register_from_string (int n, const char *buf) { - Bool new; unsigned char bytes_register[register_size (n)]; convert_ascii_to_int (buf, bytes_register, register_size (n)); - VG_(dmemcpy) (register_data_for_supply (n, 0, &new), - bytes_register, register_size (n), mod); - if (new) - *mod = True; + valgrind_store_register (n, bytes_register); } -void supply_register_by_name (const char *name, const void *buf, Bool *mod) +void supply_register_by_name (const char *name, const void *buf) { - supply_register (find_regno (name), buf, mod); + supply_register (find_regno (name), buf); } void collect_register (int n, void *buf) { - VG_(memcpy) (buf, register_data (n, 1), register_size (n)); + valgrind_fetch_register (n, buf); } void collect_register_as_string (int n, char *buf) { - convert_int_to_ascii (register_data (n, 1), buf, register_size (n)); + unsigned char local_buf [register_size (n)]; + valgrind_fetch_register (n, local_buf); + convert_int_to_ascii (local_buf, buf, register_size (n)); } void collect_register_by_name (const char *name, void *buf) diff --git a/coregrind/m_gdbserver/regcache.h b/coregrind/m_gdbserver/regcache.h index cb6fef7990..881dcc37b1 100644 --- a/coregrind/m_gdbserver/regcache.h +++ b/coregrind/m_gdbserver/regcache.h @@ -22,7 +22,15 @@ #ifndef REGCACHE_H #define REGCACHE_H -#include "pub_core_basics.h" // Bool +/* Defines support routines to get/set registers for the valgrind + remote GDB server. + This file used to provide a real register cache, where the register + values were written to by GDB without directly reaching the valgrind VEX + state. In the real GDB gdbserver, this cache was used to avoid a ptrace + system call each time a register has to be re-read. In valgrind, registers + are directly accessible by the embedded gdbserver. So, read/write registers + operations by GDB are directly executed from/to the valgrind VEX registers. */ + struct inferior_list_entry; @@ -34,11 +42,6 @@ void *new_register_cache (void); void free_register_cache (void *regcache); -/* Invalidate cached registers for one or all threads. */ - -void regcache_invalidate_one (struct inferior_list_entry *); -void regcache_invalidate (void); - /* Convert all registers to a string in the currently specified remote format. */ @@ -62,16 +65,15 @@ int find_regno (const char *name); extern const char **gdbserver_expedite_regs; -/* *mod set to True if *buf provides a new value. */ -void supply_register (int n, const void *buf, Bool *mod); +/* Sets the value of register N to buf content. */ +void supply_register (int n, const void *buf); /* Reads register data from buf (hex string in target byte order) - and stores it in the register cache. - *mod set to True if *buf provides a new value. */ -void supply_register_from_string (int n, const char *buf, Bool *mod); + and stores it in the register cache. */ +void supply_register_from_string (int n, const char *buf); -/* *mod set to True if *buf provides a new value. */ -void supply_register_by_name (const char *name, const void *buf, Bool *mod); +/* Sets the value of register identified by NAME to buf content. */ +void supply_register_by_name (const char *name, const void *buf); void collect_register (int n, void *buf); diff --git a/coregrind/m_gdbserver/remote-utils.c b/coregrind/m_gdbserver/remote-utils.c index 559d8dd8e9..2ec8e6fe59 100644 --- a/coregrind/m_gdbserver/remote-utils.c +++ b/coregrind/m_gdbserver/remote-utils.c @@ -688,7 +688,7 @@ int hexify (char *hex, const char *bin, int count) /* builds an image of bin according to byte order of the architecture Useful for register and int image */ -char* heximage (char *buf, char *bin, int count) +char* heximage (char *buf, const char *bin, int count) { #if (VKI_LITTLE_ENDIAN) char rev[count]; diff --git a/coregrind/m_gdbserver/server.c b/coregrind/m_gdbserver/server.c index 8e4bae8567..0f639b2743 100644 --- a/coregrind/m_gdbserver/server.c +++ b/coregrind/m_gdbserver/server.c @@ -1306,7 +1306,6 @@ void server_main (void) case 'P': { int regno; char *regbytes; - Bool mod; ThreadState *tst; regno = strtol(&own_buf[1], NULL, 16); regbytes = strchr(&own_buf[0], '=') + 1; @@ -1318,7 +1317,7 @@ void server_main (void) We assume we do not need to very specific here, and that we can just refuse all of these. */ if (tst->status == VgTs_Runnable || tst->status == VgTs_Yielding) { - supply_register_from_string (regno, regbytes, &mod); + supply_register_from_string (regno, regbytes); write_ok (own_buf); } else { /* at least from gdb 6.6 onwards, an E. error diff --git a/coregrind/m_gdbserver/server.h b/coregrind/m_gdbserver/server.h index 1c2d8612e3..953abbd61d 100644 --- a/coregrind/m_gdbserver/server.h +++ b/coregrind/m_gdbserver/server.h @@ -315,7 +315,7 @@ int unhexify (char *bin, const char *hex, int count); int hexify (char *hex, const char *bin, int count); /* heximage builds an image of bin according to byte order of the architecture Useful for register and int image */ -char* heximage (char *buf, char *bin, int count); +char* heximage (char *buf, const char *bin, int count); /* convert from CORE_ADDR to void* */ void* C2v(CORE_ADDR addr); diff --git a/coregrind/m_gdbserver/target.c b/coregrind/m_gdbserver/target.c index b49d210779..490276b6c4 100644 --- a/coregrind/m_gdbserver/target.c +++ b/coregrind/m_gdbserver/target.c @@ -290,7 +290,6 @@ void valgrind_resume (struct thread_resume *resume_info) "stop_pc %p changed to be resume_pc %s\n", C2v(stop_pc), sym(resume_pc)); } - regcache_invalidate(); } unsigned char valgrind_wait (char *ourstatus) @@ -304,7 +303,6 @@ unsigned char valgrind_wait (char *ourstatus) pid = VG_(getpid) (); dlog(1, "enter valgrind_wait pid %d\n", pid); - regcache_invalidate(); valgrind_update_threads(pid); /* First see if we are done with this process. */ @@ -355,14 +353,13 @@ unsigned char valgrind_wait (char *ourstatus) } /* Fetch one register from valgrind VEX guest state. */ -static -void fetch_register (int regno) +void valgrind_fetch_register (int regno, unsigned char *buf) { int size; ThreadState *tst = (ThreadState *) inferior_target_data (current_inferior); ThreadId tid = tst->tid; - if (regno >= the_low_target.num_regs) { + if (regno < 0 || regno >= the_low_target.num_regs) { dlog(0, "error fetch_register regno %d max %d\n", regno, the_low_target.num_regs); return; @@ -370,16 +367,13 @@ void fetch_register (int regno) size = register_size (regno); if (size > 0) { Bool mod; - char buf [size]; VG_(memset) (buf, 0, size); // registers not fetched will be seen as 0. (*the_low_target.transfer_register) (tid, regno, buf, valgrind_to_gdbserver, size, &mod); // Note: the *mod received from transfer_register is not interesting. - // We are interested to see if the register data in the register cache is modified. - supply_register (regno, buf, &mod); if (mod && VG_(debugLog_getLevel)() > 1) { char bufimage [2*size + 1]; - heximage (bufimage, buf, size); + heximage (bufimage, (char*) buf, size); dlog(3, "fetched register %d size %d name %s value %s tid %u status %s\n", regno, size, the_low_target.reg_defs[regno].name, bufimage, tid, VG_(name_of_ThreadStatus) (tst->status)); @@ -387,102 +381,74 @@ void fetch_register (int regno) } } -/* Fetch all registers, or just one, from the child process. */ -static -void usr_fetch_inferior_registers (int regno) -{ - if (regno == -1 || regno == 0) - for (regno = 0; regno < the_low_target.num_regs; regno++) - fetch_register (regno); - else - fetch_register (regno); -} - -/* Store our register values back into the inferior. - If REGNO is -1, do this for all registers. - Otherwise, REGNO specifies which register (so we can save time). */ -static -void usr_store_inferior_registers (int regno) +/* Store register REGNO value back into the inferior VEX state. */ +void valgrind_store_register (int regno, const unsigned char *buf) { int size; ThreadState *tst = (ThreadState *) inferior_target_data (current_inferior); ThreadId tid = tst->tid; - - if (regno >= 0) { - if (regno >= the_low_target.num_regs) { - dlog(0, "error store_register regno %d max %d\n", - regno, the_low_target.num_regs); - return; + if (regno < 0 || regno >= the_low_target.num_regs) { + dlog(0, "error store_register regno %d max %d\n", + regno, the_low_target.num_regs); + return; + } + + size = register_size (regno); + if (size > 0) { + Bool mod; + Addr old_SP, new_SP; + + if (regno == the_low_target.stack_pointer_regno) { + /* When the stack pointer register is changed such that + the stack is extended, we better inform the tool of the + stack increase. This is needed in particular to avoid + spurious Memcheck errors during Inferior calls. So, we + save in old_SP the SP before the change. A change of + stack pointer is also assumed to have initialised this + new stack space. For the typical example of an inferior + call, gdb writes arguments on the stack, and then + changes the stack pointer. As the stack increase tool + function might mark it as undefined, we have to call it + at the good moment. */ + VG_(memset) ((void *) &old_SP, 0, size); + (*the_low_target.transfer_register) (tid, regno, (void *) &old_SP, + valgrind_to_gdbserver, size, &mod); } - - size = register_size (regno); - if (size > 0) { - Bool mod; - Addr old_SP, new_SP; - char buf[size]; - - if (regno == the_low_target.stack_pointer_regno) { - /* When the stack pointer register is changed such that - the stack is extended, we better inform the tool of the - stack increase. This is needed in particular to avoid - spurious Memcheck errors during Inferior calls. So, we - save in old_SP the SP before the change. A change of - stack pointer is also assumed to have initialised this - new stack space. For the typical example of an inferior - call, gdb writes arguments on the stack, and then - changes the stack pointer. As the stack increase tool - function might mark it as undefined, we have to call it - at the good moment. */ - VG_(memset) ((void *) &old_SP, 0, size); - (*the_low_target.transfer_register) (tid, regno, (void *) &old_SP, - valgrind_to_gdbserver, size, &mod); - } - VG_(memset) (buf, 0, size); - collect_register (regno, buf); - (*the_low_target.transfer_register) (tid, regno, buf, - gdbserver_to_valgrind, size, &mod); - if (mod && VG_(debugLog_getLevel)() > 1) { - char bufimage [2*size + 1]; - heximage (bufimage, buf, size); - dlog(2, - "stored register %d size %d name %s value %s " - "tid %u status %s\n", - regno, size, the_low_target.reg_defs[regno].name, bufimage, - tid, VG_(name_of_ThreadStatus) (tst->status)); - } - if (regno == the_low_target.stack_pointer_regno) { - VG_(memcpy) (&new_SP, buf, size); - if (old_SP > new_SP) { - Word delta = (Word)new_SP - (Word)old_SP; - dlog(1, - " stack increase by stack pointer changed from %p to %p " - "delta %ld\n", - (void*) old_SP, (void *) new_SP, - delta); - VG_TRACK( new_mem_stack_w_ECU, new_SP, -delta, 0 ); - VG_TRACK( new_mem_stack, new_SP, -delta ); - VG_TRACK( post_mem_write, Vg_CoreClientReq, tid, - new_SP, -delta); - } + char buf_copy[size]; + /* copy buf to buf_copy to avoid warnings passing a const to transfer_register. + This is ok as transfer_register called with gdbserver_to_valgrind will read from + buf and write to VEX state. */ + VG_(memcpy) (buf_copy, buf, size); + + (*the_low_target.transfer_register) (tid, regno, buf_copy, + gdbserver_to_valgrind, size, &mod); + if (mod && VG_(debugLog_getLevel)() > 1) { + char bufimage [2*size + 1]; + heximage (bufimage, buf_copy, size); + dlog(2, + "stored register %d size %d name %s value %s " + "tid %u status %s\n", + regno, size, the_low_target.reg_defs[regno].name, bufimage, + tid, VG_(name_of_ThreadStatus) (tst->status)); + } + if (regno == the_low_target.stack_pointer_regno) { + VG_(memcpy) (&new_SP, buf, size); + if (old_SP > new_SP) { + Word delta = (Word)new_SP - (Word)old_SP; + dlog(1, + " stack increase by stack pointer changed from %p to %p " + "delta %ld\n", + (void*) old_SP, (void *) new_SP, + delta); + VG_TRACK( new_mem_stack_w_ECU, new_SP, -delta, 0 ); + VG_TRACK( new_mem_stack, new_SP, -delta ); + VG_TRACK( post_mem_write, Vg_CoreClientReq, tid, + new_SP, -delta); } } } - else { - for (regno = 0; regno < the_low_target.num_regs; regno++) - usr_store_inferior_registers (regno); - } -} - -void valgrind_fetch_registers (int regno) -{ - usr_fetch_inferior_registers (regno); -} - -void valgrind_store_registers (int regno) -{ - usr_store_inferior_registers (regno); } Bool hostvisibility = False; @@ -806,7 +772,6 @@ void initialize_shadow_low(Bool shadow_mode) non_shadow_num_regs = the_low_target.num_regs; } - regcache_invalidate(); if (the_low_target.reg_defs != non_shadow_reg_defs) { free (the_low_target.reg_defs); } diff --git a/coregrind/m_gdbserver/target.h b/coregrind/m_gdbserver/target.h index 9a8b5f2b4e..1309bba7a5 100644 --- a/coregrind/m_gdbserver/target.h +++ b/coregrind/m_gdbserver/target.h @@ -179,13 +179,11 @@ extern int valgrind_thread_alive (unsigned long tid); set to the first valid thread. */ extern void set_desired_inferior (int use_general); -/* Fetch registers from the current_inferior thread. - If REGNO is -1, fetch all registers; otherwise, fetch at least REGNO. */ -extern void valgrind_fetch_registers (int regno); +/* Fetch register regno from the current_inferior thread and put its value in buf. */ +extern void valgrind_fetch_register (int regno, unsigned char *buf); -/* Store registers to the current_inferior thread. - If REGNO is -1, store all registers; otherwise, store at least REGNO. */ -extern void valgrind_store_registers (int regno); +/* Store register REGNO value from BUF to the VEX valgrind state. */ +extern void valgrind_store_register (int regno, const unsigned char *buf); diff --git a/coregrind/m_gdbserver/valgrind-low-amd64.c b/coregrind/m_gdbserver/valgrind-low-amd64.c index c0d85bf3d3..0f83de1e1e 100644 --- a/coregrind/m_gdbserver/valgrind-low-amd64.c +++ b/coregrind/m_gdbserver/valgrind-low-amd64.c @@ -129,7 +129,7 @@ CORE_ADDR get_pc (void) unsigned long pc; collect_register_by_name ("rip", &pc); - + dlog(1, "stop pc is %p\n", (void *) pc); return pc; } @@ -137,12 +137,7 @@ CORE_ADDR get_pc (void) static void set_pc (CORE_ADDR newpc) { - Bool mod; - supply_register_by_name ("rip", &newpc, &mod); - if (mod) - dlog(1, "set pc to %p\n", C2v (newpc)); - else - dlog(1, "set pc not changed %p\n", C2v (newpc)); + supply_register_by_name ("rip", &newpc); } /* store registers in the guest state (gdbserver_to_valgrind) diff --git a/coregrind/m_gdbserver/valgrind-low-arm.c b/coregrind/m_gdbserver/valgrind-low-arm.c index fecbb071c9..5a2348732b 100644 --- a/coregrind/m_gdbserver/valgrind-low-arm.c +++ b/coregrind/m_gdbserver/valgrind-low-arm.c @@ -114,12 +114,7 @@ CORE_ADDR get_pc (void) static void set_pc (CORE_ADDR newpc) { - Bool mod; - supply_register_by_name ("pc", &newpc, &mod); - if (mod) - dlog(1, "set pc to %p\n", C2v (newpc)); - else - dlog(1, "set pc not changed %p\n", C2v (newpc)); + supply_register_by_name ("pc", &newpc); } Addr thumb_pc (Addr pc) diff --git a/coregrind/m_gdbserver/valgrind-low-arm64.c b/coregrind/m_gdbserver/valgrind-low-arm64.c index 17aa2068bf..292650dc1a 100644 --- a/coregrind/m_gdbserver/valgrind-low-arm64.c +++ b/coregrind/m_gdbserver/valgrind-low-arm64.c @@ -125,12 +125,7 @@ CORE_ADDR get_pc (void) static void set_pc (CORE_ADDR newpc) { - Bool mod; - supply_register_by_name ("pc", &newpc, &mod); - if (mod) - dlog(1, "set pc to %p\n", C2v (newpc)); - else - dlog(1, "set pc not changed %p\n", C2v (newpc)); + supply_register_by_name ("pc", &newpc); } /* store registers in the guest state (gdbserver_to_valgrind) diff --git a/coregrind/m_gdbserver/valgrind-low-mips32.c b/coregrind/m_gdbserver/valgrind-low-mips32.c index 5f965f54a3..a132a43505 100644 --- a/coregrind/m_gdbserver/valgrind-low-mips32.c +++ b/coregrind/m_gdbserver/valgrind-low-mips32.c @@ -130,12 +130,7 @@ CORE_ADDR get_pc (void) static void set_pc (CORE_ADDR newpc) { - Bool mod; - supply_register_by_name ("pc", &newpc, &mod); - if (mod) - dlog(1, "set pc to %p\n", C2v (newpc)); - else - dlog(1, "set pc not changed %p\n", C2v (newpc)); + supply_register_by_name ("pc", &newpc); } /* These are the fields of 32 bit mips instructions. */ diff --git a/coregrind/m_gdbserver/valgrind-low-mips64.c b/coregrind/m_gdbserver/valgrind-low-mips64.c index 20323a3b69..026dbe7638 100644 --- a/coregrind/m_gdbserver/valgrind-low-mips64.c +++ b/coregrind/m_gdbserver/valgrind-low-mips64.c @@ -131,12 +131,7 @@ CORE_ADDR get_pc (void) static void set_pc (CORE_ADDR newpc) { - Bool mod; - supply_register_by_name ("pc", &newpc, &mod); - if (mod) - dlog(1, "set pc to %p\n", C2v (newpc)); - else - dlog(1, "set pc not changed %p\n", C2v (newpc)); + supply_register_by_name ("pc", &newpc); } /* These are the fields of 32 bit mips instructions. */ diff --git a/coregrind/m_gdbserver/valgrind-low-nanomips.c b/coregrind/m_gdbserver/valgrind-low-nanomips.c index 77a4190fe0..d2c4f0332f 100644 --- a/coregrind/m_gdbserver/valgrind-low-nanomips.c +++ b/coregrind/m_gdbserver/valgrind-low-nanomips.c @@ -93,12 +93,7 @@ CORE_ADDR get_pc (void) static void set_pc (CORE_ADDR newpc) { - Bool mod; - supply_register_by_name ("pc", &newpc, &mod); - if (mod) - dlog(1, "set pc to %p\n", C2v (newpc)); - else - dlog(1, "set pc not changed %p\n", C2v (newpc)); + supply_register_by_name ("pc", &newpc); } /* These are the fields of 32 bit mips instructions. */ diff --git a/coregrind/m_gdbserver/valgrind-low-ppc32.c b/coregrind/m_gdbserver/valgrind-low-ppc32.c index db5d8ced16..bdb0896b9b 100644 --- a/coregrind/m_gdbserver/valgrind-low-ppc32.c +++ b/coregrind/m_gdbserver/valgrind-low-ppc32.c @@ -164,12 +164,7 @@ CORE_ADDR get_pc (void) static void set_pc (CORE_ADDR newpc) { - Bool mod; - supply_register_by_name ("pc", &newpc, &mod); - if (mod) - dlog(1, "set pc to %p\n", C2v (newpc)); - else - dlog(1, "set pc not changed %p\n", C2v (newpc)); + supply_register_by_name ("pc", &newpc); } /* store registers in the guest state (gdbserver_to_valgrind) diff --git a/coregrind/m_gdbserver/valgrind-low-ppc64.c b/coregrind/m_gdbserver/valgrind-low-ppc64.c index 3c6146c59a..1e2a159442 100644 --- a/coregrind/m_gdbserver/valgrind-low-ppc64.c +++ b/coregrind/m_gdbserver/valgrind-low-ppc64.c @@ -239,12 +239,7 @@ CORE_ADDR get_pc (void) static void set_pc (CORE_ADDR newpc) { - Bool mod; - supply_register_by_name ("pc", &newpc, &mod); - if (mod) - dlog(1, "set pc to %p\n", C2v (newpc)); - else - dlog(1, "set pc not changed %p\n", C2v (newpc)); + supply_register_by_name ("pc", &newpc); } /* store registers in the guest state (gdbserver_to_valgrind) diff --git a/coregrind/m_gdbserver/valgrind-low-s390x.c b/coregrind/m_gdbserver/valgrind-low-s390x.c index a667f4b40b..74898e471a 100644 --- a/coregrind/m_gdbserver/valgrind-low-s390x.c +++ b/coregrind/m_gdbserver/valgrind-low-s390x.c @@ -139,12 +139,7 @@ CORE_ADDR get_pc (void) static void set_pc (CORE_ADDR newpc) { - Bool mod; - supply_register_by_name ("pswa", &newpc, &mod); - if (mod) - dlog(1, "set pc to %p\n", C2v (newpc)); - else - dlog(1, "set pc not changed %p\n", C2v (newpc)); + supply_register_by_name ("pswa", &newpc); } /* store registers in the guest state (gdbserver_to_valgrind) diff --git a/coregrind/m_gdbserver/valgrind-low-x86.c b/coregrind/m_gdbserver/valgrind-low-x86.c index 410c4257fd..e7adac700c 100644 --- a/coregrind/m_gdbserver/valgrind-low-x86.c +++ b/coregrind/m_gdbserver/valgrind-low-x86.c @@ -104,12 +104,7 @@ CORE_ADDR get_pc (void) static void set_pc (CORE_ADDR newpc) { - Bool mod; - supply_register_by_name ("eip", &newpc, &mod); - if (mod) - dlog(1, "set pc to %p\n", C2v (newpc)); - else - dlog(1, "set pc not changed %p\n", C2v (newpc)); + supply_register_by_name ("eip", &newpc); } /* store registers in the guest state (gdbserver_to_valgrind) |
|
From: Paul F. <pa...@so...> - 2022-10-12 06:36:50
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=2dde5c405b020c96c0595222045475d195939a2b commit 2dde5c405b020c96c0595222045475d195939a2b Author: Paul Floyd <pj...@wa...> Date: Wed Oct 12 08:34:51 2022 +0200 Bug 131186 - writev reports error in (vector[...]) Use the index rather than ... Also done for readv. Diff: --- NEWS | 1 + coregrind/m_syswrap/syswrap-generic.c | 16 ++++++++++------ memcheck/tests/writev1.stderr.exp | 2 +- memcheck/tests/writev1.stderr.exp-solaris | 2 +- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/NEWS b/NEWS index b2ca7e12d7..e6094b5bf2 100644 --- a/NEWS +++ b/NEWS @@ -38,6 +38,7 @@ bugzilla (https://bugs.kde.org/enter_bug.cgi?product=valgrind) rather than mailing the developers (or mailing lists) directly -- bugs that are not entered into bugzilla tend to get forgotten about or ignored. +131186 writev reports error in (vector[...]) 434764 iconv_open causes ld.so v2.28+ to use optimised strncmp 446754 Improve error codes from alloc functions under memcheck 452274 memcheck crashes with Assertion 'sci->status.what == SsIdle' failed diff --git a/coregrind/m_syswrap/syswrap-generic.c b/coregrind/m_syswrap/syswrap-generic.c index 44a60bf128..7d11ff4064 100644 --- a/coregrind/m_syswrap/syswrap-generic.c +++ b/coregrind/m_syswrap/syswrap-generic.c @@ -4410,6 +4410,7 @@ PRE(sys_readv) { Int i; struct vki_iovec * vec; + char buf[sizeof("writev(vector[])") + 11]; *flags |= SfMayBlock; PRINT("sys_readv ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", ARG1, ARG2, ARG3); @@ -4424,9 +4425,10 @@ PRE(sys_readv) if (ML_(safe_to_deref)((const void*)ARG2, ARG3*sizeof(struct vki_iovec *))) { vec = (struct vki_iovec *)(Addr)ARG2; - for (i = 0; i < (Int)ARG3; i++) - PRE_MEM_WRITE( "readv(vector[...])", - (Addr)vec[i].iov_base, vec[i].iov_len ); + for (i = 0; i < (Int)ARG3; i++) { + VG_(sprintf)(buf, "writev(vector[%d])", i); + PRE_MEM_WRITE(buf, (Addr)vec[i].iov_base, vec[i].iov_len ); + } } } } @@ -4770,6 +4772,7 @@ PRE(sys_writev) { Int i; struct vki_iovec * vec; + char buf[sizeof("writev(vector[])") + 11]; *flags |= SfMayBlock; PRINT("sys_writev ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", ARG1, ARG2, ARG3); @@ -4785,9 +4788,10 @@ PRE(sys_writev) if (ML_(safe_to_deref)((const void*)ARG2, ARG3*sizeof(struct vki_iovec *))) { vec = (struct vki_iovec *)(Addr)ARG2; - for (i = 0; i < (Int)ARG3; i++) - PRE_MEM_READ( "writev(vector[...])", - (Addr)vec[i].iov_base, vec[i].iov_len ); + for (i = 0; i < (Int)ARG3; i++) { + VG_(sprintf)(buf, "writev(vector[%d])", i); + PRE_MEM_READ( buf, (Addr)vec[i].iov_base, vec[i].iov_len ); + } } } } diff --git a/memcheck/tests/writev1.stderr.exp b/memcheck/tests/writev1.stderr.exp index aea8390c74..df9ef77116 100644 --- a/memcheck/tests/writev1.stderr.exp +++ b/memcheck/tests/writev1.stderr.exp @@ -1,5 +1,5 @@ Test file created. -Syscall param writev(vector[...]) points to unaddressable byte(s) +Syscall param writev(vector[0]) points to unaddressable byte(s) ... by 0x........: main (writev1.c:56) Address 0x........ is not stack'd, malloc'd or (recently) free'd diff --git a/memcheck/tests/writev1.stderr.exp-solaris b/memcheck/tests/writev1.stderr.exp-solaris index b19d775c50..1cc95e7710 100644 --- a/memcheck/tests/writev1.stderr.exp-solaris +++ b/memcheck/tests/writev1.stderr.exp-solaris @@ -1,5 +1,5 @@ Test file created. -Syscall param writev(vector[...]) points to unaddressable byte(s) +Syscall param writev(vector[0]) points to unaddressable byte(s) ... by 0x........: main (writev1.c:56) Address 0x........ is not stack'd, malloc'd or (recently) free'd |