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) |
2
(2) |
3
|
4
|
|
5
|
6
(3) |
7
(1) |
8
(1) |
9
(4) |
10
(1) |
11
(1) |
|
12
(2) |
13
(7) |
14
(3) |
15
(2) |
16
(7) |
17
(1) |
18
(2) |
|
19
|
20
|
21
|
22
|
23
|
24
|
25
|
|
26
|
27
|
28
|
29
|
30
|
|
|
|
From: Feiyang C. <chr...@gm...> - 2022-06-10 08:38:53
|
Hi, team, After fixing some decoding and stack backtracking bugs, Valgrind for loongarch64-linux successfully passed most of the tests. https://github.com/loongson/valgrind-loongarch64 I will try to get Valgrind to pass more tests. But now I have some doubts. Could you help me, please? There are more dubious and reachable blocks in some memcheck tests. I don't know what's wrong with it. $ valgrind --leak-check=full --leak-resolution=high memcheck/tests/leak-cases ==166906== Memcheck, a memory error detector ==166906== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al. ==166906== Using Valgrind-3.20.0.GIT and LibVEX; rerun with -h for copyright info ==166906== Command: memcheck/tests/leak-cases ==166906== ==166906== All heap blocks were freed -- no leaks are possible ==166906== ==166906== LEAK SUMMARY: ==166906== definitely lost: 32 bytes in 2 blocks ==166906== indirectly lost: 16 bytes in 1 blocks ==166906== possibly lost: 112 bytes in 7 blocks ==166906== still reachable: 80 bytes in 5 blocks ==166906== suppressed: 0 bytes in 0 blocks ==166906== Rerun with --leak-check=full to see details of leaked memory ==166906== leaked: 48 bytes in 3 blocks dubious: 112 bytes in 7 blocks reachable: 80 bytes in 5 blocks suppressed: 0 bytes in 0 blocks ==166906== ==166906== HEAP SUMMARY: ==166906== in use at exit: 240 bytes in 15 blocks ==166906== total heap usage: 15 allocs, 0 frees, 240 bytes allocated ==166906== ==166906== 16 bytes in 1 blocks are possibly lost in loss record 7 of 17 ==166906== at 0x484704C: malloc (vg_replace_malloc.c:393) ==166906== by 0x120A27: mk (leak-cases.c:52) ==166906== by 0x120AC3: f (leak-cases.c:78) ==166906== by 0x120DE7: main (leak-cases.c:107) ==166906== ==166906== 16 bytes in 1 blocks are possibly lost in loss record 8 of 17 ==166906== at 0x484704C: malloc (vg_replace_malloc.c:393) ==166906== by 0x120A27: mk (leak-cases.c:52) ==166906== by 0x120AF7: f (leak-cases.c:81) ==166906== by 0x120DE7: main (leak-cases.c:107) ==166906== ==166906== 16 bytes in 1 blocks are possibly lost in loss record 9 of 17 ==166906== at 0x484704C: malloc (vg_replace_malloc.c:393) ==166906== by 0x120A27: mk (leak-cases.c:52) ==166906== by 0x120B33: f (leak-cases.c:84) ==166906== by 0x120DE7: main (leak-cases.c:107) ==166906== ==166906== 16 bytes in 1 blocks are possibly lost in loss record 10 of 17 ==166906== at 0x484704C: malloc (vg_replace_malloc.c:393) ==166906== by 0x120A27: mk (leak-cases.c:52) ==166906== by 0x120B3F: f (leak-cases.c:84) ==166906== by 0x120DE7: main (leak-cases.c:107) ==166906== ==166906== 16 bytes in 1 blocks are possibly lost in loss record 11 of 17 ==166906== at 0x484704C: malloc (vg_replace_malloc.c:393) ==166906== by 0x120A27: mk (leak-cases.c:52) ==166906== by 0x120B73: f (leak-cases.c:87) ==166906== by 0x120DE7: main (leak-cases.c:107) ==166906== ==166906== 16 bytes in 1 blocks are possibly lost in loss record 12 of 17 ==166906== at 0x484704C: malloc (vg_replace_malloc.c:393) ==166906== by 0x120A27: mk (leak-cases.c:52) ==166906== by 0x120B7F: f (leak-cases.c:87) ==166906== by 0x120DE7: main (leak-cases.c:107) ==166906== ==166906== 16 bytes in 1 blocks are definitely lost in loss record 15 of 17 ==166906== at 0x484704C: malloc (vg_replace_malloc.c:393) ==166906== by 0x120A27: mk (leak-cases.c:52) ==166906== by 0x120AA7: f (leak-cases.c:74) ==166906== by 0x120DE7: main (leak-cases.c:107) ==166906== ==166906== 32 (16 direct, 16 indirect) bytes in 1 blocks are definitely lost in loss record 16 of 17 ==166906== at 0x484704C: malloc (vg_replace_malloc.c:393) ==166906== by 0x120A27: mk (leak-cases.c:52) ==166906== by 0x120ABB: f (leak-cases.c:76) ==166906== by 0x120DE7: main (leak-cases.c:107) ==166906== ==166906== 32 (16 direct, 16 indirect) bytes in 1 blocks are definitely lost in loss record 17 of 17 ==166906== at 0x484704C: malloc (vg_replace_malloc.c:393) ==166906== by 0x120A27: mk (leak-cases.c:52) ==166906== by 0x120BD7: f (leak-cases.c:91) ==166906== by 0x120DE7: main (leak-cases.c:107) ==166906== ==166906== LEAK SUMMARY: ==166906== definitely lost: 48 bytes in 3 blocks ==166906== indirectly lost: 32 bytes in 2 blocks ==166906== possibly lost: 96 bytes in 6 blocks ==166906== still reachable: 64 bytes in 4 blocks ==166906== suppressed: 0 bytes in 0 blocks ==166906== Reachable blocks (those to which a pointer was found) are not shown. ==166906== To see them, rerun with: --leak-check=full --show-leak-kinds=all ==166906== ==166906== For lists of detected and suppressed errors, rerun with: -s ==166906== ERROR SUMMARY: 9 errors from 9 contexts (suppressed: 0 from 0) I add four functions in glibc-2.X-helgrind.supp.in: '_dl_lookup_symbol_x', '_dl_map_object_deps', '_dl_sort_maps_dfs' and '_dl_fini'. I don't know why they cause errors. $ valgrind --tool=helgrind helgrind/tests/bar_bad ==166897== Helgrind, a thread error detector ==166897== Copyright (C) 2007-2017, and GNU GPL'd, by OpenWorks LLP et al. ==166897== Using Valgrind-3.20.0.GIT and LibVEX; rerun with -h for copyright info ==166897== Command: helgrind/tests/bar_bad ==166897== initialise a barrier with zero count ==166897== ---Thread-Announcement------------------------------------------ ==166897== ==166897== Thread #1 is the program's root thread ==166897== ==166897== ---------------------------------------------------------------- ==166897== ==166897== Thread #1: pthread_barrier_init: 'count' argument is zero ==166897== at 0x4855184: pthread_barrier_init (hg_intercepts.c:1869) ==166897== by 0x120CEB: main (bar_bad.c:44) ==166897== ==166897== ---------------------------------------------------------------- ==166897== ==166897== Thread #1's call to pthread_barrier_init failed ==166897== with error code 22 (EINVAL: Invalid argument) ==166897== at 0x4855244: pthread_barrier_init (hg_intercepts.c:1877) ==166897== by 0x120CEB: main (bar_bad.c:44) ==166897== initialise a barrier twice ==166897== ---------------------------------------------------------------- ==166897== ==166897== Thread #1: pthread_barrier_init: barrier is already initialised ==166897== at 0x4855184: pthread_barrier_init (hg_intercepts.c:1869) ==166897== by 0x120D3F: main (bar_bad.c:50) ==166897== initialise a barrier which has threads waiting on it ==166897== ---Thread-Announcement------------------------------------------ ==166897== ==166897== Thread #2 was created ==166897== at 0x4978F68: clone (clone.S:56) ==166897== by 0x490F27B: create_thread (pthread_create.c:295) ==166897== by 0x490FC47: pthread_create@@GLIBC_2.36 (pthread_create.c:828) ==166897== by 0x4853883: pthread_create_WRK (hg_intercepts.c:445) ==166897== by 0x4854B2F: pthread_create@* (hg_intercepts.c:478) ==166897== by 0x120D9F: main (bar_bad.c:59) ==166897== ==166897== ---------------------------------------------------------------- ==166897== ==166897== Possible data race during read of size 8 at 0x4030B10 by thread #2 ==166897== Locks held: none ==166897== at 0x400B1A4: _dl_lookup_symbol_x (dl-lookup.c:824) ==166897== by 0x4010953: _dl_fixup (dl-runtime.c:95) ==166897== by 0x4012B27: _dl_runtime_resolve (dl-trampoline.S:62) ==166897== by 0xFFFFFFFFFFFFFFFF: ??? ==166897== ==166897== This conflicts with a previous write of size 8 by thread #1 ==166897== Locks held: none ==166897== at 0x400B1C0: _dl_lookup_symbol_x (dl-lookup.c:824) ==166897== by 0x4010953: _dl_fixup (dl-runtime.c:95) ==166897== by 0x4012B27: _dl_runtime_resolve (dl-trampoline.S:62) ==166897== by 0xFFFFFFFFFFFFFFFF: ??? ==166897== Address 0x4030b10 is 2712 bytes inside data symbol "_rtld_local" ==166897== ==166897== ---------------------------------------------------------------- ==166897== ==166897== Possible data race during write of size 8 at 0x4030B10 by thread #2 ==166897== Locks held: none ==166897== at 0x400B1C0: _dl_lookup_symbol_x (dl-lookup.c:824) ==166897== by 0x4010953: _dl_fixup (dl-runtime.c:95) ==166897== by 0x4012B27: _dl_runtime_resolve (dl-trampoline.S:62) ==166897== by 0xFFFFFFFFFFFFFFFF: ??? ==166897== ==166897== This conflicts with a previous write of size 8 by thread #1 ==166897== Locks held: none ==166897== at 0x400B1C0: _dl_lookup_symbol_x (dl-lookup.c:824) ==166897== by 0x4010953: _dl_fixup (dl-runtime.c:95) ==166897== by 0x4012B27: _dl_runtime_resolve (dl-trampoline.S:62) ==166897== by 0xFFFFFFFFFFFFFFFF: ??? ==166897== Address 0x4030b10 is 2712 bytes inside data symbol "_rtld_local" ==166897== ==166897== ---------------------------------------------------------------- ==166897== ==166897== Thread #1: pthread_barrier_init: barrier is already initialised ==166897== at 0x4855184: pthread_barrier_init (hg_intercepts.c:1869) ==166897== by 0x120DD3: main (bar_bad.c:65) ==166897== ==166897== ---------------------------------------------------------------- ==166897== ==166897== Thread #1: pthread_barrier_init: threads are waiting at barrier ==166897== at 0x4855184: pthread_barrier_init (hg_intercepts.c:1869) ==166897== by 0x120DD3: main (bar_bad.c:65) ==166897== destroy a barrier that has waiting threads ==166897== ---------------------------------------------------------------- ==166897== ==166897== Thread #1: pthread_barrier_destroy: threads are waiting at barrier ==166897== at 0x4855444: pthread_barrier_destroy (hg_intercepts.c:1944) ==166897== by 0x120E5F: main (bar_bad.c:83) ==166897== ==166897== ---Thread-Announcement------------------------------------------ ==166897== ==166897== Thread #4 was created ==166897== at 0x4978F68: clone (clone.S:56) ==166897== by 0x490F27B: create_thread (pthread_create.c:295) ==166897== by 0x490FC47: pthread_create@@GLIBC_2.36 (pthread_create.c:828) ==166897== by 0x4853883: pthread_create_WRK (hg_intercepts.c:445) ==166897== by 0x4854B2F: pthread_create@* (hg_intercepts.c:478) ==166897== by 0x120E33: main (bar_bad.c:77) ==166897== ==166897== ---------------------------------------------------------------- ==166897== ==166897== Thread #4: pthread_barrier_wait: barrier is uninitialised ==166897== at 0x48552E8: pthread_barrier_wait (hg_intercepts.c:1910) ==166897== by 0x120C5B: sleep1 (bar_bad.c:23) ==166897== by 0x4853A5F: mythread_wrapper (hg_intercepts.c:406) ==166897== by 0x490F4CB: start_thread (pthread_create.c:442) ==166897== by 0x4978F8B: __thread_start (clone.S:87) ==166897== ==166897== ---------------------------------------------------------------- ==166897== ==166897== Lock at 0x4030A80 was first observed ==166897== at 0x4850BEC: mutex_lock_WRK (hg_intercepts.c:942) ==166897== by 0x4854F63: pthread_mutex_lock (hg_intercepts.c:958) ==166897== by 0x400CD17: _dl_open (dl-open.c:830) ==166897== by 0x49B311F: do_dlopen (dl-libc.c:95) ==166897== by 0x49B2D2B: _dl_catch_exception (dl-error-skeleton.c:208) ==166897== by 0x49B2DEF: _dl_catch_error (dl-error-skeleton.c:227) ==166897== by 0x49B3073: dlerror_run (dl-libc.c:45) ==166897== by 0x49B326F: __libc_dlopen_mode (dl-libc.c:162) ==166897== by 0x4978BD3: __libc_unwind_link_get (unwind-link.c:50) ==166897== by 0x490D783: pthread_cancel@@GLIBC_2.36 (pthread_cancel.c:99) ==166897== by 0x120E6B: main (bar_bad.c:85) ==166897== Address 0x4030a80 is 2568 bytes inside data symbol "_rtld_local" ==166897== ==166897== Lock at 0x4030AD0 was first observed ==166897== at 0x4850BEC: mutex_lock_WRK (hg_intercepts.c:942) ==166897== by 0x4854F63: pthread_mutex_lock (hg_intercepts.c:958) ==166897== by 0x40120C3: _dl_allocate_tls_init (dl-tls.c:539) ==166897== by 0x4910127: allocate_stack (allocatestack.c:428) ==166897== by 0x4910127: pthread_create@@GLIBC_2.36 (pthread_create.c:647) ==166897== by 0x4853883: pthread_create_WRK (hg_intercepts.c:445) ==166897== by 0x4854B2F: pthread_create@* (hg_intercepts.c:478) ==166897== by 0x120D9F: main (bar_bad.c:59) ==166897== Address 0x4030ad0 is 2648 bytes inside data symbol "_rtld_local" ==166897== ==166897== Possible data race during write of size 2 at 0x4032774 by thread #1 ==166897== Locks held: 2, at addresses 0x4030A80 0x4030AD0 ==166897== at 0x40040F8: _dl_map_object_deps (dl-deps.c:259) ==166897== by 0x400D23F: dl_open_worker_begin (dl-open.c:592) ==166897== by 0x49B2D2B: _dl_catch_exception (dl-error-skeleton.c:208) ==166897== by 0x400C917: dl_open_worker (dl-open.c:782) ==166897== by 0x49B2D2B: _dl_catch_exception (dl-error-skeleton.c:208) ==166897== by 0x400CD5B: _dl_open (dl-open.c:883) ==166897== by 0x49B311F: do_dlopen (dl-libc.c:95) ==166897== by 0x49B2D2B: _dl_catch_exception (dl-error-skeleton.c:208) ==166897== by 0x49B2DEF: _dl_catch_error (dl-error-skeleton.c:227) ==166897== by 0x49B3073: dlerror_run (dl-libc.c:45) ==166897== by 0x49B326F: __libc_dlopen_mode (dl-libc.c:162) ==166897== by 0x4978BD3: __libc_unwind_link_get (unwind-link.c:50) ==166897== ==166897== This conflicts with a previous read of size 2 by thread #4 ==166897== Locks held: none ==166897== at 0x400B274: _dl_lookup_symbol_x (dl-lookup.c:907) ==166897== by 0x4010953: _dl_fixup (dl-runtime.c:95) ==166897== by 0x4012B27: _dl_runtime_resolve (dl-trampoline.S:62) ==166897== by 0xFFFFFFFFFFFFFFFF: ??? ==166897== Address 0x4032774 is in a rw- mapped file /usr/lib64/ld-linux-loongarch-lp64d.so.1 segment ==166897== ==166897== ---------------------------------------------------------------- ==166897== ==166897== Lock at 0x4030A80 was first observed ==166897== at 0x4850BEC: mutex_lock_WRK (hg_intercepts.c:942) ==166897== by 0x4854F63: pthread_mutex_lock (hg_intercepts.c:958) ==166897== by 0x400CD17: _dl_open (dl-open.c:830) ==166897== by 0x49B311F: do_dlopen (dl-libc.c:95) ==166897== by 0x49B2D2B: _dl_catch_exception (dl-error-skeleton.c:208) ==166897== by 0x49B2DEF: _dl_catch_error (dl-error-skeleton.c:227) ==166897== by 0x49B3073: dlerror_run (dl-libc.c:45) ==166897== by 0x49B326F: __libc_dlopen_mode (dl-libc.c:162) ==166897== by 0x4978BD3: __libc_unwind_link_get (unwind-link.c:50) ==166897== by 0x490D783: pthread_cancel@@GLIBC_2.36 (pthread_cancel.c:99) ==166897== by 0x120E6B: main (bar_bad.c:85) ==166897== Address 0x4030a80 is 2568 bytes inside data symbol "_rtld_local" ==166897== ==166897== Lock at 0x4030AD0 was first observed ==166897== at 0x4850BEC: mutex_lock_WRK (hg_intercepts.c:942) ==166897== by 0x4854F63: pthread_mutex_lock (hg_intercepts.c:958) ==166897== by 0x40120C3: _dl_allocate_tls_init (dl-tls.c:539) ==166897== by 0x4910127: allocate_stack (allocatestack.c:428) ==166897== by 0x4910127: pthread_create@@GLIBC_2.36 (pthread_create.c:647) ==166897== by 0x4853883: pthread_create_WRK (hg_intercepts.c:445) ==166897== by 0x4854B2F: pthread_create@* (hg_intercepts.c:478) ==166897== by 0x120D9F: main (bar_bad.c:59) ==166897== Address 0x4030ad0 is 2648 bytes inside data symbol "_rtld_local" ==166897== ==166897== Possible data race during read of size 8 at 0x4030B10 by thread #1 ==166897== Locks held: 2, at addresses 0x4030A80 0x4030AD0 ==166897== at 0x400B1A4: _dl_lookup_symbol_x (dl-lookup.c:824) ==166897== by 0x400F6BB: elf_machine_rela (dl-machine.h:186) ==166897== by 0x400F6BB: elf_dynamic_do_Rela (do-rel.h:147) ==166897== by 0x400F6BB: _dl_relocate_object (dl-reloc.c:288) ==166897== by 0x400D373: dl_open_worker_begin (dl-open.c:702) ==166897== by 0x49B2D2B: _dl_catch_exception (dl-error-skeleton.c:208) ==166897== by 0x400C917: dl_open_worker (dl-open.c:782) ==166897== by 0x49B2D2B: _dl_catch_exception (dl-error-skeleton.c:208) ==166897== by 0x400CD5B: _dl_open (dl-open.c:883) ==166897== by 0x49B311F: do_dlopen (dl-libc.c:95) ==166897== by 0x49B2D2B: _dl_catch_exception (dl-error-skeleton.c:208) ==166897== by 0x49B2DEF: _dl_catch_error (dl-error-skeleton.c:227) ==166897== by 0x49B3073: dlerror_run (dl-libc.c:45) ==166897== by 0x49B326F: __libc_dlopen_mode (dl-libc.c:162) ==166897== ==166897== This conflicts with a previous write of size 8 by thread #4 ==166897== Locks held: none ==166897== at 0x400B1C0: _dl_lookup_symbol_x (dl-lookup.c:824) ==166897== by 0x4010953: _dl_fixup (dl-runtime.c:95) ==166897== by 0x4012B27: _dl_runtime_resolve (dl-trampoline.S:62) ==166897== by 0xFFFFFFFFFFFFFFFF: ??? ==166897== Address 0x4030b10 is 2712 bytes inside data symbol "_rtld_local" ==166897== ==166897== ---------------------------------------------------------------- ==166897== ==166897== Lock at 0x4030A80 was first observed ==166897== at 0x4850BEC: mutex_lock_WRK (hg_intercepts.c:942) ==166897== by 0x4854F63: pthread_mutex_lock (hg_intercepts.c:958) ==166897== by 0x400CD17: _dl_open (dl-open.c:830) ==166897== by 0x49B311F: do_dlopen (dl-libc.c:95) ==166897== by 0x49B2D2B: _dl_catch_exception (dl-error-skeleton.c:208) ==166897== by 0x49B2DEF: _dl_catch_error (dl-error-skeleton.c:227) ==166897== by 0x49B3073: dlerror_run (dl-libc.c:45) ==166897== by 0x49B326F: __libc_dlopen_mode (dl-libc.c:162) ==166897== by 0x4978BD3: __libc_unwind_link_get (unwind-link.c:50) ==166897== by 0x490D783: pthread_cancel@@GLIBC_2.36 (pthread_cancel.c:99) ==166897== by 0x120E6B: main (bar_bad.c:85) ==166897== Address 0x4030a80 is 2568 bytes inside data symbol "_rtld_local" ==166897== ==166897== Lock at 0x4030AD0 was first observed ==166897== at 0x4850BEC: mutex_lock_WRK (hg_intercepts.c:942) ==166897== by 0x4854F63: pthread_mutex_lock (hg_intercepts.c:958) ==166897== by 0x40120C3: _dl_allocate_tls_init (dl-tls.c:539) ==166897== by 0x4910127: allocate_stack (allocatestack.c:428) ==166897== by 0x4910127: pthread_create@@GLIBC_2.36 (pthread_create.c:647) ==166897== by 0x4853883: pthread_create_WRK (hg_intercepts.c:445) ==166897== by 0x4854B2F: pthread_create@* (hg_intercepts.c:478) ==166897== by 0x120D9F: main (bar_bad.c:59) ==166897== Address 0x4030ad0 is 2648 bytes inside data symbol "_rtld_local" ==166897== ==166897== Possible data race during write of size 8 at 0x4030B10 by thread #1 ==166897== Locks held: 2, at addresses 0x4030A80 0x4030AD0 ==166897== at 0x400B1C0: _dl_lookup_symbol_x (dl-lookup.c:824) ==166897== by 0x400F6BB: elf_machine_rela (dl-machine.h:186) ==166897== by 0x400F6BB: elf_dynamic_do_Rela (do-rel.h:147) ==166897== by 0x400F6BB: _dl_relocate_object (dl-reloc.c:288) ==166897== by 0x400D373: dl_open_worker_begin (dl-open.c:702) ==166897== by 0x49B2D2B: _dl_catch_exception (dl-error-skeleton.c:208) ==166897== by 0x400C917: dl_open_worker (dl-open.c:782) ==166897== by 0x49B2D2B: _dl_catch_exception (dl-error-skeleton.c:208) ==166897== by 0x400CD5B: _dl_open (dl-open.c:883) ==166897== by 0x49B311F: do_dlopen (dl-libc.c:95) ==166897== by 0x49B2D2B: _dl_catch_exception (dl-error-skeleton.c:208) ==166897== by 0x49B2DEF: _dl_catch_error (dl-error-skeleton.c:227) ==166897== by 0x49B3073: dlerror_run (dl-libc.c:45) ==166897== by 0x49B326F: __libc_dlopen_mode (dl-libc.c:162) ==166897== ==166897== This conflicts with a previous write of size 8 by thread #4 ==166897== Locks held: none ==166897== at 0x400B1C0: _dl_lookup_symbol_x (dl-lookup.c:824) ==166897== by 0x4010953: _dl_fixup (dl-runtime.c:95) ==166897== by 0x4012B27: _dl_runtime_resolve (dl-trampoline.S:62) ==166897== by 0xFFFFFFFFFFFFFFFF: ??? ==166897== Address 0x4030b10 is 2712 bytes inside data symbol "_rtld_local" ==166897== ==166897== ---------------------------------------------------------------- ==166897== ==166897== Possible data race during read of size 8 at 0x4030B10 by thread #1 ==166897== Locks held: none ==166897== at 0x400B1A4: _dl_lookup_symbol_x (dl-lookup.c:824) ==166897== by 0x49B3177: do_dlsym (dl-libc.c:105) ==166897== by 0x49B2D2B: _dl_catch_exception (dl-error-skeleton.c:208) ==166897== by 0x49B2DEF: _dl_catch_error (dl-error-skeleton.c:227) ==166897== by 0x49B3073: dlerror_run (dl-libc.c:45) ==166897== by 0x49B32F7: __libc_dlsym (dl-libc.c:190) ==166897== by 0x4978BE7: __libc_unwind_link_get (unwind-link.c:59) ==166897== by 0x490D783: pthread_cancel@@GLIBC_2.36 (pthread_cancel.c:99) ==166897== by 0x120E6B: main (bar_bad.c:85) ==166897== ==166897== This conflicts with a previous write of size 8 by thread #4 ==166897== Locks held: none ==166897== at 0x400B1C0: _dl_lookup_symbol_x (dl-lookup.c:824) ==166897== by 0x4010953: _dl_fixup (dl-runtime.c:95) ==166897== by 0x4012B27: _dl_runtime_resolve (dl-trampoline.S:62) ==166897== by 0xFFFFFFFFFFFFFFFF: ??? ==166897== Address 0x4030b10 is 2712 bytes inside data symbol "_rtld_local" ==166897== ==166897== ---------------------------------------------------------------- ==166897== ==166897== Possible data race during write of size 8 at 0x4030B10 by thread #1 ==166897== Locks held: none ==166897== at 0x400B1C0: _dl_lookup_symbol_x (dl-lookup.c:824) ==166897== by 0x49B3177: do_dlsym (dl-libc.c:105) ==166897== by 0x49B2D2B: _dl_catch_exception (dl-error-skeleton.c:208) ==166897== by 0x49B2DEF: _dl_catch_error (dl-error-skeleton.c:227) ==166897== by 0x49B3073: dlerror_run (dl-libc.c:45) ==166897== by 0x49B32F7: __libc_dlsym (dl-libc.c:190) ==166897== by 0x4978BE7: __libc_unwind_link_get (unwind-link.c:59) ==166897== by 0x490D783: pthread_cancel@@GLIBC_2.36 (pthread_cancel.c:99) ==166897== by 0x120E6B: main (bar_bad.c:85) ==166897== ==166897== This conflicts with a previous write of size 8 by thread #4 ==166897== Locks held: none ==166897== at 0x400B1C0: _dl_lookup_symbol_x (dl-lookup.c:824) ==166897== by 0x4010953: _dl_fixup (dl-runtime.c:95) ==166897== by 0x4012B27: _dl_runtime_resolve (dl-trampoline.S:62) ==166897== by 0xFFFFFFFFFFFFFFFF: ??? ==166897== Address 0x4030b10 is 2712 bytes inside data symbol "_rtld_local" ==166897== destroy a barrier that was never initialised ==166897== ---------------------------------------------------------------- ==166897== ==166897== Thread #1: pthread_barrier_destroy: barrier was never initialised ==166897== at 0x4855444: pthread_barrier_destroy (hg_intercepts.c:1944) ==166897== by 0x120EFB: main (bar_bad.c:100) ==166897== ==166897== ---------------------------------------------------------------- ==166897== ==166897== Lock at 0x4030A80 was first observed ==166897== at 0x4850BEC: mutex_lock_WRK (hg_intercepts.c:942) ==166897== by 0x4854F63: pthread_mutex_lock (hg_intercepts.c:958) ==166897== by 0x400CD17: _dl_open (dl-open.c:830) ==166897== by 0x49B311F: do_dlopen (dl-libc.c:95) ==166897== by 0x49B2D2B: _dl_catch_exception (dl-error-skeleton.c:208) ==166897== by 0x49B2DEF: _dl_catch_error (dl-error-skeleton.c:227) ==166897== by 0x49B3073: dlerror_run (dl-libc.c:45) ==166897== by 0x49B326F: __libc_dlopen_mode (dl-libc.c:162) ==166897== by 0x4978BD3: __libc_unwind_link_get (unwind-link.c:50) ==166897== by 0x490D783: pthread_cancel@@GLIBC_2.36 (pthread_cancel.c:99) ==166897== by 0x120E6B: main (bar_bad.c:85) ==166897== Address 0x4030a80 is 2568 bytes inside data symbol "_rtld_local" ==166897== ==166897== Possible data race during write of size 2 at 0x4032774 by thread #1 ==166897== Locks held: 1, at address 0x4030A80 ==166897== at 0x4011470: _dl_sort_maps_dfs (dl-sort-maps.c:188) ==166897== by 0x4011470: _dl_sort_maps (dl-sort-maps.c:301) ==166897== by 0x4006133: _dl_fini (dl-fini.c:99) ==166897== by 0x48CDF63: __run_exit_handlers (exit.c:113) ==166897== by 0x48CE0D7: exit (exit.c:143) ==166897== by 0x120F2B: main (bar_bad.c:110) ==166897== ==166897== This conflicts with a previous read of size 2 by thread #4 ==166897== Locks held: none ==166897== at 0x400B274: _dl_lookup_symbol_x (dl-lookup.c:907) ==166897== by 0x4010953: _dl_fixup (dl-runtime.c:95) ==166897== by 0x4012B27: _dl_runtime_resolve (dl-trampoline.S:62) ==166897== by 0xFFFFFFFFFFFFFFFF: ??? ==166897== Address 0x4032774 is in a rw- mapped file /usr/lib64/ld-linux-loongarch-lp64d.so.1 segment ==166897== ==166897== ---------------------------------------------------------------- ==166897== ==166897== Possible data race during write of size 2 at 0x4032774 by thread #1 ==166897== Locks held: none ==166897== at 0x4006178: _dl_fini (dl-fini.c:120) ==166897== by 0x48CDF63: __run_exit_handlers (exit.c:113) ==166897== by 0x48CE0D7: exit (exit.c:143) ==166897== by 0x120F2B: main (bar_bad.c:110) ==166897== ==166897== This conflicts with a previous read of size 2 by thread #4 ==166897== Locks held: none ==166897== at 0x400B274: _dl_lookup_symbol_x (dl-lookup.c:907) ==166897== by 0x4010953: _dl_fixup (dl-runtime.c:95) ==166897== by 0x4012B27: _dl_runtime_resolve (dl-trampoline.S:62) ==166897== by 0xFFFFFFFFFFFFFFFF: ??? ==166897== Address 0x4032774 is in a rw- mapped file /usr/lib64/ld-linux-loongarch-lp64d.so.1 segment ==166897== ==166897== ==166897== Use --history-level=approx or =none to gain increased speed, at ==166897== the cost of reduced accuracy of conflicting-access information ==166897== For lists of detected and suppressed errors, rerun with: -s ==166897== ERROR SUMMARY: 37 errors from 17 contexts (suppressed: 8 from 7) Thanks, Feiyang |
|
From: Mark W. <ma...@so...> - 2022-06-09 21:11:02
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=3aee8a29447ea14108eb5d4ab3c1f7677767296a commit 3aee8a29447ea14108eb5d4ab3c1f7677767296a Author: Mark Wielaard <ma...@kl...> Date: Thu Jun 9 23:06:36 2022 +0200 syswrap-linux.c (sys_execveat): Define path as const HChar * Like buf, path (ARG2) is a const HChar * Prevents a gcc warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] 13328 | path = buf; | ^ Diff: --- coregrind/m_syswrap/syswrap-linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c index 04502f6257..adc3132118 100644 --- a/coregrind/m_syswrap/syswrap-linux.c +++ b/coregrind/m_syswrap/syswrap-linux.c @@ -13302,7 +13302,7 @@ PRE(sys_execveat) return; #endif - char *path = (char*) ARG2; + const HChar *path = (const HChar*) ARG2; Addr arg_2 = ARG3; Addr arg_3 = ARG4; const HChar *buf; |
|
From: Mark W. <ma...@so...> - 2022-06-09 21:10:57
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=438d5e956dfa989184fcd4c18d7db534f65b75b6 commit 438d5e956dfa989184fcd4c18d7db534f65b75b6 Author: Mark Wielaard <ma...@kl...> Date: Thu Jun 9 22:51:56 2022 +0200 syswrap-linux.c (sys_bpf): Compare raw_tracepoint.name against 0, not NULL raw_tracepoint.name is a __vki_u64 (even on 32bit arches), so compare against zero, not NULL, to avoid a gcc warning. Diff: --- coregrind/m_syswrap/syswrap-linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c index 70aaec2f2d..04502f6257 100644 --- a/coregrind/m_syswrap/syswrap-linux.c +++ b/coregrind/m_syswrap/syswrap-linux.c @@ -12938,7 +12938,7 @@ PRE(sys_bpf) break; } /* Name is limited to 128 characters in kernel/bpf/syscall.c. */ - if (attr->raw_tracepoint.name != NULL) + if (attr->raw_tracepoint.name != 0) pre_asciiz_str(tid, attr->raw_tracepoint.name, 128, "bpf(attr->raw_tracepoint.name)"); } |
|
From: Mark W. <ma...@so...> - 2022-06-09 21:10:55
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=61ddbc1fc395c787192e569d8f2238f713bdfd8e commit 61ddbc1fc395c787192e569d8f2238f713bdfd8e Author: Luboš Luňák <l....@ce...> Date: Tue Apr 19 10:58:44 2022 +0200 read properly unit headers depending on dwarf5 unit_type There may be additional fields that need to be skipped over, otherwise further reading will interpret these incorrectly. Diff: --- coregrind/m_debuginfo/readdwarf.c | 27 +++++++++++++++++++++++++-- coregrind/m_debuginfo/readdwarf3.c | 8 +++++++- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/coregrind/m_debuginfo/readdwarf.c b/coregrind/m_debuginfo/readdwarf.c index 39a2946870..56cef9a5f4 100644 --- a/coregrind/m_debuginfo/readdwarf.c +++ b/coregrind/m_debuginfo/readdwarf.c @@ -1056,6 +1056,7 @@ void read_unitinfo_dwarf2( /*OUT*/UnitInfo* ui, UShort ver; UChar addr_size = 0; + UChar unit_type = 0; DiCursor p = unitblock_img; DiCursor end_img; DiCursor abbrev_img; @@ -1073,7 +1074,7 @@ void read_unitinfo_dwarf2( /*OUT*/UnitInfo* ui, if (ver >= 5) /* unit_type for DWARF5 */ - /* unit_type = */ ML_(cur_step_UChar)(&p); + unit_type = ML_(cur_step_UChar)(&p); else /* get offset in abbrev */ atoffs = ui->dw64 ? ML_(cur_step_ULong)(&p) @@ -1082,11 +1083,33 @@ void read_unitinfo_dwarf2( /*OUT*/UnitInfo* ui, /* Address size */ addr_size = ML_(cur_step_UChar)(&p); - if (ver >= 5) + if (ver >= 5) { /* get offset in abbrev */ atoffs = ui->dw64 ? ML_(cur_step_ULong)(&p) : (ULong)(ML_(cur_step_UInt)(&p)); + /* read any extra fields */ + switch(unit_type) { + case DW_UT_compile: + case DW_UT_partial: + break; + case DW_UT_skeleton: + case DW_UT_split_compile: + /* dwo_id = */ ML_(cur_step_ULong)(&p); + break; + case DW_UT_type: + case DW_UT_split_type: + /* type_signature = */ ML_(cur_step_ULong)(&p); + /* type_offset = */ ui->dw64 ? ML_(cur_step_ULong)(&p) + : (ULong)(ML_(cur_step_UInt)(&p)); + break; + default: + VG_(printf)( "### unhandled dwarf2 unit_type code 0x%x\n", + unit_type ); + break; + } + } + /* End of this block */ end_img = ML_(cur_plus)(unitblock_img, blklen + (ui->dw64 ? 12 : 4)); diff --git a/coregrind/m_debuginfo/readdwarf3.c b/coregrind/m_debuginfo/readdwarf3.c index 5489f8d135..1453ebbdbc 100644 --- a/coregrind/m_debuginfo/readdwarf3.c +++ b/coregrind/m_debuginfo/readdwarf3.c @@ -1200,11 +1200,17 @@ void parse_CU_Header ( /*OUT*/CUConst* cc, cc->is_type_unit = type_unit; cc->is_alt_info = alt_info; - if (type_unit || (cc->version >= 5 && unit_type == DW_UT_type)) { + if (type_unit || (cc->version >= 5 && (unit_type == DW_UT_type + || unit_type == DW_UT_split_type))) { cc->type_signature = get_ULong( c ); cc->type_offset = get_Dwarfish_UWord( c, cc->is_dw64 ); } + if (cc->version >= 5 && (unit_type == DW_UT_skeleton + || unit_type == DW_UT_split_compile)) { + /* dwo_id = */ get_ULong( c ); + } + /* Set up cc->debug_abbv to point to the relevant table for this CU. Set its .szB so that at least we can't read off the end of the debug_abbrev section -- potentially (and quite likely) too |
|
From: Paul F. <pa...@so...> - 2022-06-09 20:10:44
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=7844752299b5472b21fc4df765d4cffdf92c6c3d commit 7844752299b5472b21fc4df765d4cffdf92c6c3d Author: Paul Floyd <pj...@wa...> Date: Thu Jun 9 22:03:04 2022 +0200 Bug 452802 Handle lld 9+ split RW PT_LOAD segments correctly Many changes mostly related to modifying VG_(di_notify_mmap)( Addr a, Bool allow_SkFileV, Int use_fd ) so that instead of triggering debuginfo reading after seeing one RX PT_LOAD and 1 RW PT_LOAD it can handle either 1 or 2 RW PT_LOADs. Diff: --- NEWS | 1 + coregrind/m_debuginfo/debuginfo.c | 135 ++++++++++++++++-- coregrind/m_debuginfo/image.c | 76 ++++++++-- coregrind/m_debuginfo/priv_image.h | 5 + coregrind/m_debuginfo/priv_readelf.h | 2 + coregrind/m_debuginfo/priv_storage.h | 2 +- coregrind/m_debuginfo/readelf.c | 215 ++++++++++++++++++++++------- coregrind/m_debuginfo/readpdb.c | 4 +- coregrind/m_debuginfo/storage.c | 6 +- memcheck/tests/Makefile.am | 1 + memcheck/tests/varinfo5.stderr.exp-freebsd | 191 +++++++++++++++++++++++++ 11 files changed, 556 insertions(+), 82 deletions(-) diff --git a/NEWS b/NEWS index a0cf73eaff..1f92c25e3d 100644 --- a/NEWS +++ b/NEWS @@ -41,6 +41,7 @@ are not entered into bugzilla tend to get forgotten about or ignored. 452779 Valgrind fails to build on FreeBSD 13.0 with llvm-devel (15.0.0) 453055 shared_timed_mutex drd test fails with "Lock shared failed" message 453602 Missing command line option to enable/disable debuginfod +452802 Handle lld 9+ split RW PT_LOAD segments correctly To see details of a given bug, visit https://bugs.kde.org/show_bug.cgi?id=XXXXXX diff --git a/coregrind/m_debuginfo/debuginfo.c b/coregrind/m_debuginfo/debuginfo.c index 60f9ea195d..34a2ea8ccb 100644 --- a/coregrind/m_debuginfo/debuginfo.c +++ b/coregrind/m_debuginfo/debuginfo.c @@ -665,7 +665,7 @@ static void check_CFSI_related_invariants ( const DebugInfo* di ) been successfully read. And that shouldn't happen until we have both a r-x and rw- mapping for the object. Hence: */ vg_assert(di->fsm.have_rx_map); - vg_assert(di->fsm.have_rw_map); + vg_assert(di->fsm.rw_map_count); for (i = 0; i < VG_(sizeXA)(di->fsm.maps); i++) { const DebugInfoMapping* map = VG_(indexXA)(di->fsm.maps, i); /* We are interested in r-x mappings only */ @@ -1024,16 +1024,96 @@ static ULong di_notify_ACHIEVE_ACCEPT_STATE ( struct _DebugInfo* di ) /* Notify the debuginfo system about a new mapping. This is the way - new debug information gets loaded. If allow_SkFileV is True, it - will try load debug info if the mapping at 'a' belongs to Valgrind; - whereas normally (False) it will not do that. This allows us to - carefully control when the thing will read symbols from the - Valgrind executable itself. + new debug information gets loaded. + + redelf -e will output something like + + readelf -e says + + Program Headers: + Type Offset VirtAddr PhysAddr + FileSiz MemSiz Flg Align + PHDR 0x0000000000000040 0x0000000000200040 0x0000000000200040 + 0x0000000000000268 0x0000000000000268 R 0x8 + INTERP 0x00000000000002a8 0x00000000002002a8 0x00000000002002a8 + 0x0000000000000015 0x0000000000000015 R 0x1 + [Requesting program interpreter: /libexec/ld-elf.so.1] + LOAD 0x0000000000000000 0x0000000000200000 0x0000000000200000 + 0x0000000000002acc 0x0000000000002acc R 0x1000 + LOAD 0x0000000000002ad0 0x0000000000203ad0 0x0000000000203ad0 + 0x0000000000004a70 0x0000000000004a70 R E 0x1000 + LOAD 0x0000000000007540 0x0000000000209540 0x0000000000209540 + 0x00000000000001d8 0x00000000000001d8 RW 0x1000 + LOAD 0x0000000000007720 0x000000000020a720 0x000000000020a720 + 0x00000000000002b8 0x00000000000005a0 RW 0x1000 + DYNAMIC 0x0000000000007570 0x0000000000209570 0x0000000000209570 + 0x00000000000001a0 0x00000000000001a0 RW 0x8 + GNU_RELRO 0x0000000000007540 0x0000000000209540 0x0000000000209540 + 0x00000000000001d8 0x00000000000001d8 R 0x1 + GNU_EH_FRAME 0x0000000000002334 0x0000000000202334 0x0000000000202334 + 0x000000000000012c 0x000000000000012c R 0x4 + GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000 + 0x0000000000000000 0x0000000000000000 RW 0 + NOTE 0x00000000000002c0 0x00000000002002c0 0x00000000002002c0 + 0x0000000000000048 0x0000000000000048 R 0x4 + + This function will be called for the "LOAD" segments above. + + This function gets called from 2 contexts + + "HOST TRIGGERED" + + 1a. For the tool exe and tool/core shared libs. These are already + mmap'd when the host starts so we look at something like the + /proc filesystem to get the mapping after the event and build + up the NSegments from that. + + 1b. Then the host loads ld.so and the guest exe. This is done in + the sequence + load_client -> VG_(do_exec) -> VG_(do_exec_inner) -> + exe_handlers->load_fn ( == VG_(load_ELF) ). + + This does the mmap'ing and creats the associated NSegments. + + The NSegments may get merged, (see maybe_merge_nsegments) + so there could be more PT_LOADs than there are NSegments. + VG_(di_notify_mmap) is called by iterating over the + NSegments + + "GUEST TRIGGERED" + + 2. When the guest loads any further shared libs (libc, + other dependencies, dlopens) using mmap. + + There are a few variations for syswraps/platforms. + + In this case the NSegment could possibly be merged, + but that is irrelevant because di_notify_mmap is being + called directy on the mmap result. + + If allow_SkFileV is True, it will try load debug info if the + mapping at 'a' belongs to Valgrind; whereas normally (False) + it will not do that. This allows us to carefully control when + the thing will read symbols from the Valgrind executable itself. If use_fd is not -1, that is used instead of the filename; this avoids perturbing fcntl locks, which are released by simply re-opening and closing the same file (even via different fd!). + Read-only mappings will be ignored. + There may be 1 or 2 RW mappings. + There will also be 1 RX mapping. + + If there is no RX or no RW mapping then we will not attempt to + read debuginfo for the file. + + In order to know whether there are 1 or 2 RW mappings we + need to check the ELF headers. And in the case that we + detect 2 RW mappings we need to double check that they + aren't contiguous in memory resulting in merged NSegemnts. + + This does not apply to Darwin which just checks the Mach-O header + If a call to VG_(di_notify_mmap) causes debug info to be read, then the returned ULong is an abstract handle which can later be used to refer to the debuginfo read as a result of this specific mapping, @@ -1044,12 +1124,19 @@ static ULong di_notify_ACHIEVE_ACCEPT_STATE ( struct _DebugInfo* di ) ULong VG_(di_notify_mmap)( Addr a, Bool allow_SkFileV, Int use_fd ) { NSegment const * seg; + Int rw_load_count; const HChar* filename; Bool is_rx_map, is_rw_map, is_ro_map; + DebugInfo* di; Int actual_fd, oflags; +#if defined(VGO_darwin) SysRes preadres; HChar buf1k[1024]; +#else + Bool elf_ok; +#endif + const Bool debug = VG_(debugLog_getLevel)() >= 3; SysRes statres; struct vg_stat statbuf; @@ -1211,9 +1298,12 @@ ULong VG_(di_notify_mmap)( Addr a, Bool allow_SkFileV, Int use_fd ) return 0; #endif +#if defined(VGO_darwin) /* Peer at the first few bytes of the file, to see if it is an ELF */ /* object file. Ignore the file if we do not have read permission. */ VG_(memset)(buf1k, 0, sizeof(buf1k)); +#endif + oflags = VKI_O_RDONLY; # if defined(VKI_O_LARGEFILE) oflags |= VKI_O_LARGEFILE; @@ -1237,6 +1327,7 @@ ULong VG_(di_notify_mmap)( Addr a, Bool allow_SkFileV, Int use_fd ) actual_fd = use_fd; } +#if defined(VGO_darwin) preadres = VG_(pread)( actual_fd, buf1k, sizeof(buf1k), 0 ); if (use_fd == -1) { VG_(close)( actual_fd ); @@ -1246,20 +1337,33 @@ ULong VG_(di_notify_mmap)( Addr a, Bool allow_SkFileV, Int use_fd ) DebugInfo fake_di; VG_(memset)(&fake_di, 0, sizeof(fake_di)); fake_di.fsm.filename = ML_(dinfo_strdup)("di.debuginfo.nmm", filename); - ML_(symerr)(&fake_di, True, "can't read file to inspect ELF header"); + ML_(symerr)(&fake_di, True, "can't read file to inspect Mach-O headers"); return 0; } if (sr_Res(preadres) == 0) return 0; vg_assert(sr_Res(preadres) > 0 && sr_Res(preadres) <= sizeof(buf1k) ); +#endif /* We're only interested in mappings of object files. */ # if defined(VGO_linux) || defined(VGO_solaris) || defined(VGO_freebsd) - if (!ML_(is_elf_object_file)( buf1k, (SizeT)sr_Res(preadres), False )) + + rw_load_count = 0; + + elf_ok = ML_(check_elf_and_get_rw_loads) ( actual_fd, filename, &rw_load_count ); + + if (use_fd == -1) { + VG_(close)( actual_fd ); + } + + if (!elf_ok) { return 0; + } + # elif defined(VGO_darwin) if (!ML_(is_macho_object_file)( buf1k, (SizeT)sr_Res(preadres) )) return 0; + rw_load_count = 1; # else # error "unknown OS" # endif @@ -1311,15 +1415,20 @@ ULong VG_(di_notify_mmap)( Addr a, Bool allow_SkFileV, Int use_fd ) /* Update flags about what kind of mappings we've already seen. */ di->fsm.have_rx_map |= is_rx_map; - di->fsm.have_rw_map |= is_rw_map; + /* This is a bit of a hack, using a Bool as a counter */ + if (is_rw_map) + ++di->fsm.rw_map_count; di->fsm.have_ro_map |= is_ro_map; /* So, finally, are we in an accept state? */ vg_assert(!di->have_dinfo); - if (di->fsm.have_rx_map && di->fsm.have_rw_map) { + if (di->fsm.have_rx_map && + rw_load_count >= 1 && + di->fsm.rw_map_count == rw_load_count) { /* Ok, so, finally, we found what we need, and we haven't already read debuginfo for this object. So let's do so now. Yee-ha! */ + if (debug) VG_(dmsg)("di_notify_mmap-5: " "achieved accept state for %s\n", filename); @@ -1416,7 +1525,7 @@ void VG_(di_notify_vm_protect)( Addr a, SizeT len, UInt prot ) continue; /* need to have a r-- mapping for this object */ if (di->fsm.have_rx_map) continue; /* rx- mapping already exists */ - if (!di->fsm.have_rw_map) + if (!di->fsm.rw_map_count) continue; /* need to have a rw- mapping */ /* Try to find a mapping matching the memory area. */ for (i = 0; i < VG_(sizeXA)(di->fsm.maps); i++) { @@ -1454,7 +1563,7 @@ void VG_(di_notify_vm_protect)( Addr a, SizeT len, UInt prot ) } /* Check if we're now in an accept state and read debuginfo. Finally. */ - if (di->fsm.have_rx_map && di->fsm.have_rw_map && !di->have_dinfo) { + if (di->fsm.have_rx_map && di->fsm.rw_map_count && !di->have_dinfo) { if (debug) VG_(dmsg)("di_notify_vm_protect-5: " "achieved accept state for %s\n", di->fsm.filename); @@ -1669,7 +1778,7 @@ void VG_(di_notify_pdb_debuginfo)( Int fd_obj, Addr avma_obj, { DebugInfo* di = find_or_create_DebugInfo_for(exename); /* this di must be new, since we just nuked any old stuff in the range */ - vg_assert(di && !di->fsm.have_rx_map && !di->fsm.have_rw_map); + vg_assert(di && !di->fsm.have_rx_map && !di->fsm.rw_map_count); vg_assert(!di->have_dinfo); /* don't set up any of the di-> fields; let diff --git a/coregrind/m_debuginfo/image.c b/coregrind/m_debuginfo/image.c index ebe6dfcfe8..28dfd0b472 100644 --- a/coregrind/m_debuginfo/image.c +++ b/coregrind/m_debuginfo/image.c @@ -874,6 +874,49 @@ DiImage* ML_(img_from_local_file)(const HChar* fullpath) return img; } +/* As above, but uses fd rather than filename */ +DiImage* ML_(img_from_fd)(Int fd, const HChar* fullpath) +{ + struct vg_stat stat_buf; + DiOffT size; + + if (VG_(fstat)(fd, &stat_buf) != 0) { + return NULL; + } + + size = stat_buf.size; + if (size == 0 || size == DiOffT_INVALID + || /* size is unrepresentable as a SizeT */ + size != (DiOffT)(SizeT)(size)) { + return NULL; + } + + DiImage* img = ML_(dinfo_zalloc)("di.image.ML_iflf.1", sizeof(DiImage)); + img->source.is_local = True; + img->source.fd = fd; + img->size = size; + img->real_size = size; + img->ces_used = 0; + img->source.name = ML_(dinfo_strdup)("di.image.ML_iflf.2", fullpath); + img->cslc = NULL; + img->cslc_size = 0; + img->cslc_used = 0; + /* img->ces is already zeroed out */ + vg_assert(img->source.fd >= 0); + + /* Force the zeroth entry to be the first chunk of the file. + That's likely to be the first part that's requested anyway, and + loading it at this point forcing img->cent[0] to always be + non-empty, thereby saving us an is-it-empty check on the fast + path in get(). */ + UInt entNo = alloc_CEnt(img, CACHE_ENTRY_SIZE, False/*!fromC*/); + vg_assert(entNo == 0); + set_CEnt(img, 0, 0); + + return img; +} + + /* Create an image from a file on a remote debuginfo server. This is more complex. There are lots of ways in which it can fail. */ @@ -1007,20 +1050,9 @@ DiOffT ML_(img_mark_compressed_part)(DiImage* img, DiOffT offset, SizeT szC, return ret; } -void ML_(img_done)(DiImage* img) +void ML_(img_free)(DiImage* img) { vg_assert(img != NULL); - if (img->source.is_local) { - /* Close the file; nothing else to do. */ - vg_assert(img->source.session_id == 0); - VG_(close)(img->source.fd); - } else { - /* Close the socket. The server can detect this and will scrub - the connection when it happens, so there's no need to tell it - explicitly by sending it a "CLOSE" message, or any such. */ - vg_assert(img->source.session_id != 0); - VG_(close)(img->source.fd); - } /* Free up the cache entries, ultimately |img| itself. */ UInt i; @@ -1037,6 +1069,26 @@ void ML_(img_done)(DiImage* img) ML_(dinfo_free)(img); } +void ML_(img_done)(DiImage* img) +{ + vg_assert(img != NULL); + if (img->source.is_local) { + /* Close the file; nothing else to do. */ + vg_assert(img->source.session_id == 0); + VG_(close)(img->source.fd); + } else { + /* Close the socket. The server can detect this and will scrub + the connection when it happens, so there's no need to tell it + explicitly by sending it a "CLOSE" message, or any such. */ + vg_assert(img->source.session_id != 0); + VG_(close)(img->source.fd); + } + + ML_(img_free)(img); +} + + + DiOffT ML_(img_size)(const DiImage* img) { vg_assert(img != NULL); diff --git a/coregrind/m_debuginfo/priv_image.h b/coregrind/m_debuginfo/priv_image.h index f7413a9084..a49846f149 100644 --- a/coregrind/m_debuginfo/priv_image.h +++ b/coregrind/m_debuginfo/priv_image.h @@ -59,6 +59,8 @@ typedef ULong DiOffT; if it fails, for whatever reason. */ DiImage* ML_(img_from_local_file)(const HChar* fullpath); +DiImage* ML_(img_from_fd)(Int fd, const HChar* fullpath); + /* Create an image by connecting to a Valgrind debuginfo server (auxprogs/valgrind-di-server.c). |filename| contains the object name to ask for; it must be a plain filename, not absolute, not a @@ -69,6 +71,9 @@ DiImage* ML_(img_from_local_file)(const HChar* fullpath); DiImage* ML_(img_from_di_server)(const HChar* filename, const HChar* serverAddr); +/* Free memory allocated for image. */ +void ML_(img_free)(DiImage*); + /* Destroy an existing image. */ void ML_(img_done)(DiImage*); diff --git a/coregrind/m_debuginfo/priv_readelf.h b/coregrind/m_debuginfo/priv_readelf.h index 2bee615ab5..57aa0cc3f3 100644 --- a/coregrind/m_debuginfo/priv_readelf.h +++ b/coregrind/m_debuginfo/priv_readelf.h @@ -52,6 +52,8 @@ extern Bool ML_(is_elf_object_file)( const void* image, SizeT n_image, */ extern Bool ML_(read_elf_debug_info) ( DebugInfo* di ); +extern Bool ML_(check_elf_and_get_rw_loads) ( Int fd, const HChar* filename, Int * rw_load_count ); + #endif /* ndef __PRIV_READELF_H */ diff --git a/coregrind/m_debuginfo/priv_storage.h b/coregrind/m_debuginfo/priv_storage.h index ae44ca34e5..f44ab43ffe 100644 --- a/coregrind/m_debuginfo/priv_storage.h +++ b/coregrind/m_debuginfo/priv_storage.h @@ -585,7 +585,7 @@ struct _DebugInfoFSM HChar* dbgname; /* in mallocville (VG_AR_DINFO) */ XArray* maps; /* XArray of DebugInfoMapping structs */ Bool have_rx_map; /* did we see a r?x mapping yet for the file? */ - Bool have_rw_map; /* did we see a rw? mapping yet for the file? */ + Int rw_map_count; /* count of w? mappings seen (may be > 1 ) */ Bool have_ro_map; /* did we see a r-- mapping yet for the file? */ }; diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c index ea9c80415b..b4edb4fe85 100644 --- a/coregrind/m_debuginfo/readelf.c +++ b/coregrind/m_debuginfo/readelf.c @@ -1182,10 +1182,10 @@ void read_and_set_osrel(DiImage* img) SizeT newlen = sizeof(osrel); Int error = VG_(sysctl)(name, 4, NULL, NULL, &osrel, newlen); if (error == -1) { - VG_(message)(Vg_DebugMsg, "Warning: failed to set osrel for current process with value %d\n", osrel); + VG_(message)(Vg_DebugMsg, "Warning: failed to set osrel for current process with value %u\n", osrel); } else { if (VG_(clo_verbosity) > 1) { - VG_(message)(Vg_DebugMsg, "Set osrel for current process with value %d\n", osrel); + VG_(message)(Vg_DebugMsg, "Set osrel for current process with value %u\n", osrel); } } } @@ -1924,7 +1924,7 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) vg_assert(di); vg_assert(di->fsm.have_rx_map == True); - vg_assert(di->fsm.have_rw_map == True); + vg_assert(di->fsm.rw_map_count >= 1); vg_assert(di->have_dinfo == False); vg_assert(di->fsm.filename); vg_assert(!di->symtab); @@ -2120,11 +2120,6 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) item.svma_limit = a_phdr.p_vaddr + a_phdr.p_memsz; item.bias = map->avma - map->foff + a_phdr.p_offset - a_phdr.p_vaddr; -#if (FREEBSD_VERS >= FREEBSD_12_2) - if ((long long int)item.bias < 0LL) { - item.bias = 0; - } -#endif if (map->rw && (a_phdr.p_flags & (PF_R | PF_W)) == (PF_R | PF_W)) { @@ -2264,9 +2259,10 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) } for (i = 0; i < VG_(sizeXA)(di->fsm.maps); i++) { const DebugInfoMapping* map = VG_(indexXA)(di->fsm.maps, i); - if (map->rw) + if (map->rw) { TRACE_SYMTAB("rw: at %#lx are mapped foffsets %lld .. %lld\n", map->avma, (Long)map->foff, (Long)(map->foff + map->size - 1) ); + } } TRACE_SYMTAB("rw: contains these svma regions:\n"); for (i = 0; i < VG_(sizeXA)(svma_ranges); i++) { @@ -2290,28 +2286,34 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) UInt alyn = a_shdr.sh_addralign; Bool nobits = a_shdr.sh_type == SHT_NOBITS; /* Look through our collection of info obtained from the PT_LOAD - headers, and make 'inrx' and 'inrw' point to the first entry + headers, and make 'inrx' and 'inrw1' point to the first entry in each that intersects 'avma'. If in each case none is found, leave the relevant pointer at NULL. */ RangeAndBias* inrx = NULL; - RangeAndBias* inrw = NULL; + RangeAndBias* inrw1 = NULL; + /* Depending on the link editro there may be two RW PT_LOAD headers + * If so this will point to the seond one */ + RangeAndBias* inrw2 = NULL; + /* used to switch between inrw1 and inrw2 */ + RangeAndBias* inrw; + for (j = 0; j < VG_(sizeXA)(svma_ranges); j++) { RangeAndBias* rng = VG_(indexXA)(svma_ranges, j); if (svma >= rng->svma_base && svma < rng->svma_limit) { if (!inrx && rng->exec) { inrx = rng; - } else if (!inrw && !rng->exec) { - inrw = rng; + } else if (!inrw1 && !rng->exec) { + inrw1 = rng; + } else if (!inrw2 && !rng->exec) { + inrw2 = rng; } - if (inrx && inrw) - break; } } - TRACE_SYMTAB(" [sec %2ld] %s %s al%4u foff %6lld .. %6lld " + TRACE_SYMTAB(" [sec %2ld] %s %s %s al%4u foff %6lld .. %6lld " " svma %p name \"%s\"\n", - i, inrx ? "rx" : " ", inrw ? "rw" : " ", alyn, - (Long) foff, (size == 0) ? (Long)foff : (Long)(foff+size-1), + i, inrx ? "rx" : " ", inrw1 ? "rw" : " ", inrw2 ? "rw" : " ", + alyn, (Long) foff, (size == 0) ? (Long)foff : (Long)(foff+size-1), (void *) svma, name); /* Check for sane-sized segments. SHT_NOBITS sections have zero @@ -2350,6 +2352,8 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) /* Find avma-s for: .text .data .sdata .rodata .bss .sbss .plt .got .opd and .eh_frame */ + /* In inrw2 is non-NULL then it will be used for .data .got.plt .bss */ + /* Accept .text where mapped as rx (code), even if zero-sized */ if (0 == VG_(strcmp)(name, ".text")) { if (inrx && !di->text_present) { @@ -2380,6 +2384,13 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) "%#lx .. %#lx\n", svma, svma + size - 1); } else # endif /* SOLARIS_PT_SUNDWTRACE_THRP */ + + if (inrw2) { + inrw = inrw2; + } else { + inrw = inrw1; + } + if (inrw && !di->data_present) { di->data_present = True; di->data_svma = svma; @@ -2402,14 +2413,14 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) /* Accept .sdata where mapped as rw (data) */ if (0 == VG_(strcmp)(name, ".sdata")) { - if (inrw && !di->sdata_present) { + if (inrw1 && !di->sdata_present) { di->sdata_present = True; di->sdata_svma = svma; - di->sdata_avma = svma + inrw->bias; + di->sdata_avma = svma + inrw1->bias; di->sdata_size = size; - di->sdata_bias = inrw->bias; + di->sdata_bias = inrw1->bias; di->sdata_debug_svma = svma; - di->sdata_debug_bias = inrw->bias; + di->sdata_debug_bias = inrw1->bias; TRACE_SYMTAB("acquiring .sdata svma = %#lx .. %#lx\n", di->sdata_svma, di->sdata_svma + di->sdata_size - 1); @@ -2434,10 +2445,10 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) di->rodata_avma += inrx->bias; di->rodata_bias = inrx->bias; di->rodata_debug_bias = inrx->bias; - } else if (inrw) { - di->rodata_avma += inrw->bias; - di->rodata_bias = inrw->bias; - di->rodata_debug_bias = inrw->bias; + } else if (inrw1) { + di->rodata_avma += inrw1->bias; + di->rodata_bias = inrw1->bias; + di->rodata_debug_bias = inrw1->bias; } else { BAD(".rodata"); } @@ -2456,15 +2467,15 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) } if (0 == VG_(strcmp)(name, ".dynbss")) { - if (inrw && !di->bss_present) { + if (inrw1 && !di->bss_present) { dynbss_present = True; di->bss_present = True; di->bss_svma = svma; - di->bss_avma = svma + inrw->bias; + di->bss_avma = svma + inrw1->bias; di->bss_size = size; - di->bss_bias = inrw->bias; + di->bss_bias = inrw1->bias; di->bss_debug_svma = svma; - di->bss_debug_bias = inrw->bias; + di->bss_debug_bias = inrw1->bias; TRACE_SYMTAB("acquiring .dynbss svma = %#lx .. %#lx\n", di->bss_svma, di->bss_svma + di->bss_size - 1); @@ -2478,6 +2489,13 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) /* Accept .bss where mapped as rw (data), even if zero-sized */ if (0 == VG_(strcmp)(name, ".bss")) { + + if (inrw2) { + inrw = inrw2; + } else { + inrw = inrw1; + } + if (inrw && dynbss_present) { vg_assert(di->bss_present); dynbss_present = False; @@ -2544,15 +2562,15 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) } if (0 == VG_(strcmp)(name, ".sdynbss")) { - if (inrw && !di->sbss_present) { + if (inrw1 && !di->sbss_present) { sdynbss_present = True; di->sbss_present = True; di->sbss_svma = svma; - di->sbss_avma = svma + inrw->bias; + di->sbss_avma = svma + inrw1->bias; di->sbss_size = size; - di->sbss_bias = inrw->bias; + di->sbss_bias = inrw1->bias; di->sbss_debug_svma = svma; - di->sbss_debug_bias = inrw->bias; + di->sbss_debug_bias = inrw1->bias; TRACE_SYMTAB("acquiring .sdynbss svma = %#lx .. %#lx\n", di->sbss_svma, di->sbss_svma + di->sbss_size - 1); @@ -2566,7 +2584,7 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) /* Accept .sbss where mapped as rw (data) */ if (0 == VG_(strcmp)(name, ".sbss")) { - if (inrw && sdynbss_present) { + if (inrw1 && sdynbss_present) { vg_assert(di->sbss_present); sdynbss_present = False; vg_assert(di->sbss_svma + di->sbss_size == svma); @@ -2574,18 +2592,18 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) TRACE_SYMTAB("acquiring .sbss svma = %#lx .. %#lx\n", svma, svma + size - 1); TRACE_SYMTAB("acquiring .sbss avma = %#lx .. %#lx\n", - svma + inrw->bias, svma + inrw->bias + size - 1); + svma + inrw1->bias, svma + inrw1->bias + size - 1); TRACE_SYMTAB("acquiring .sbss bias = %#lx\n", (UWord)di->sbss_bias); } else - if (inrw && !di->sbss_present) { + if (inrw1 && !di->sbss_present) { di->sbss_present = True; di->sbss_svma = svma; - di->sbss_avma = svma + inrw->bias; + di->sbss_avma = svma + inrw1->bias; di->sbss_size = size; - di->sbss_bias = inrw->bias; + di->sbss_bias = inrw1->bias; di->sbss_debug_svma = svma; - di->sbss_debug_bias = inrw->bias; + di->sbss_debug_bias = inrw1->bias; TRACE_SYMTAB("acquiring .sbss svma = %#lx .. %#lx\n", di->sbss_svma, di->sbss_svma + di->sbss_size - 1); @@ -2600,9 +2618,9 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) /* Accept .got where mapped as rw (data) */ if (0 == VG_(strcmp)(name, ".got")) { - if (inrw && !di->got_present) { + if (inrw1 && !di->got_present) { di->got_present = True; - di->got_avma = svma + inrw->bias; + di->got_avma = svma + inrw1->bias; di->got_size = size; TRACE_SYMTAB("acquiring .got avma = %#lx\n", di->got_avma); } else { @@ -2612,6 +2630,13 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) /* Accept .got.plt where mapped as rw (data) */ if (0 == VG_(strcmp)(name, ".got.plt")) { + + if (inrw2) { + inrw = inrw2; + } else { + inrw = inrw1; + } + if (inrw && !di->gotplt_present) { di->gotplt_present = True; di->gotplt_avma = svma + inrw->bias; @@ -2643,9 +2668,9 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) # elif defined(VGP_ppc32_linux) /* Accept .plt where mapped as rw (data) */ if (0 == VG_(strcmp)(name, ".plt")) { - if (inrw && !di->plt_present) { + if (inrw1 && !di->plt_present) { di->plt_present = True; - di->plt_avma = svma + inrw->bias; + di->plt_avma = svma + inrw1->bias; di->plt_size = size; TRACE_SYMTAB("acquiring .plt avma = %#lx\n", di->plt_avma); } else { @@ -2655,13 +2680,13 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) # elif defined(VGP_ppc64be_linux) || defined(VGP_ppc64le_linux) /* Accept .plt where mapped as rw (data), or unmapped */ if (0 == VG_(strcmp)(name, ".plt")) { - if (inrw && !di->plt_present) { + if (inrw1 && !di->plt_present) { di->plt_present = True; - di->plt_avma = svma + inrw->bias; + di->plt_avma = svma + inrw1->bias; di->plt_size = size; TRACE_SYMTAB("acquiring .plt avma = %#lx\n", di->plt_avma); } else - if ((!inrw) && (!inrx) && size > 0 && !di->plt_present) { + if ((!inrw1) && (!inrx) && size > 0 && !di->plt_present) { /* File contains a .plt, but it didn't get mapped. Presumably it is not required on this platform. At least don't reject the situation as invalid. */ @@ -2678,9 +2703,9 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) /* Accept .opd where mapped as rw (data) */ if (0 == VG_(strcmp)(name, ".opd")) { - if (inrw && !di->opd_present) { + if (inrw1 && !di->opd_present) { di->opd_present = True; - di->opd_avma = svma + inrw->bias; + di->opd_avma = svma + inrw1->bias; di->opd_size = size; TRACE_SYMTAB("acquiring .opd avma = %#lx\n", di->opd_avma); } else { @@ -2700,8 +2725,8 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) di->ehframe_avma[di->n_ehframe]); di->n_ehframe++; } else - if (inrw && di->n_ehframe < N_EHFRAME_SECTS) { - di->ehframe_avma[di->n_ehframe] = svma + inrw->bias; + if (inrw1 && di->n_ehframe < N_EHFRAME_SECTS) { + di->ehframe_avma[di->n_ehframe] = svma + inrw1->bias; di->ehframe_size[di->n_ehframe] = size; TRACE_SYMTAB("acquiring .eh_frame avma = %#lx\n", di->ehframe_avma[di->n_ehframe]); @@ -3606,6 +3631,94 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) /* NOTREACHED */ } +Bool ML_(check_elf_and_get_rw_loads) ( Int fd, const HChar* filename, Int * rw_load_count ) +{ + Bool res, ok; + UWord i; + DiImage* mimg = NULL; + DiOffT ehdr_mioff = 0; + DiOffT phdr_mioff = 0; + UWord phdr_mnent = 0U; + UWord phdr_ment_szB = 0U; + + res = False; + + mimg = ML_(img_from_fd)(fd, filename); + if (mimg == NULL) { + VG_(message)(Vg_UserMsg, "warning: connection to image %s failed\n", + filename ); + VG_(message)(Vg_UserMsg, " cannot read program headers \n" ); + return False; + } + + ok = is_elf_object_file_by_DiImage(mimg, False); + if (!ok) { + goto out; + } + + ElfXX_Ehdr ehdr_m; + Elf64_Word flag_x; +#if defined(VGA_amd64) || defined(VGA_ppc64be) || defined(VGA_ppc64le) || defined(VGA_arm) || defined(VGA_arm64) + flag_x = PF_X; +#else + flag_x = 0; +#endif + vg_assert(ehdr_mioff == 0); // ensured by its initialisation + ok = ML_(img_valid)(mimg, ehdr_mioff, sizeof(ehdr_m)); + vg_assert(ok); // ML_(is_elf_object_file) should ensure this + ML_(img_get)(&ehdr_m, mimg, ehdr_mioff, sizeof(ehdr_m)); + + phdr_mioff = ehdr_mioff + ehdr_m.e_phoff; + phdr_mnent = ehdr_m.e_phnum; + phdr_ment_szB = ehdr_m.e_phentsize; + + for (i = 0U; i < phdr_mnent; i++) { + ElfXX_Phdr a_phdr; + ML_(img_get)(&a_phdr, mimg, + INDEX_BIS(phdr_mioff, i, phdr_ment_szB), + sizeof(a_phdr)); + + if (a_phdr.p_type == PT_LOAD) { + if (a_phdr.p_memsz > 0) { + if (((a_phdr.p_flags & (PF_R | PF_W)) == (PF_R | PF_W)) && + ((a_phdr.p_flags & flag_x) == 0)) { + ++*rw_load_count; + } + + /* + * Hold your horses + * Just because The ELF file contains 2 RW PT_LOAD segments it + * doesn't mean that Valgrind will also make 2 calls to + * VG_(di_notify_mmap). If the stars are all aligned + * (which usually means that the ELF file is the client + * executable with the segment offset for the + * second PT_LOAD falls exactly on 0x1000) then the NSegements + * will get merged and VG_(di_notify_mmap) only gets called once. */ + if (*rw_load_count == 2 && + ehdr_m.e_type == ET_EXEC && + a_phdr.p_offset == VG_PGROUNDDN(a_phdr.p_offset) ) + { + *rw_load_count = 1; + } + } + } + } /* for (i = 0; i < phdr_Mnent; i++) ... */ + + res = True; + + out: + { + /* Last, but not least, detach from the image(s). */ + if (mimg) ML_(img_free)(mimg); + + return res; + } /* out: */ + + /* NOTREACHED */ +} + + + #endif // defined(VGO_linux) || defined(VGO_solaris) || defined(VGO_freebsd) /*--------------------------------------------------------------------*/ diff --git a/coregrind/m_debuginfo/readpdb.c b/coregrind/m_debuginfo/readpdb.c index a53cf48c44..f3a3817d89 100644 --- a/coregrind/m_debuginfo/readpdb.c +++ b/coregrind/m_debuginfo/readpdb.c @@ -2363,7 +2363,7 @@ Bool ML_(read_pdb_debug_info)( map.rx = False; map.rw = True; VG_(addToXA)(di->fsm.maps, &map); - di->fsm.have_rw_map = True; + di->fsm.rw_map_count = 1; di->data_present = True; if (di->data_avma == 0) { @@ -2385,7 +2385,7 @@ Bool ML_(read_pdb_debug_info)( } } - if (di->fsm.have_rx_map && di->fsm.have_rw_map && !di->have_dinfo) { + if (di->fsm.have_rx_map && di->fsm.rw_map_count && !di->have_dinfo) { vg_assert(di->fsm.filename); TRACE_SYMTAB("\n"); TRACE_SYMTAB("------ start PE OBJECT with PDB INFO " diff --git a/coregrind/m_debuginfo/storage.c b/coregrind/m_debuginfo/storage.c index 9ba74076c1..6eb932747f 100644 --- a/coregrind/m_debuginfo/storage.c +++ b/coregrind/m_debuginfo/storage.c @@ -616,7 +616,7 @@ void ML_(addLineInfo) ( struct _DebugInfo* di, /* Rule out ones which are completely outside the r-x mapped area. See "Comment_Regarding_Text_Range_Checks" elsewhere in this file for background and rationale. */ - vg_assert(di->fsm.have_rx_map && di->fsm.have_rw_map); + vg_assert(di->fsm.have_rx_map && di->fsm.rw_map_count); if (ML_(find_rx_mapping)(di, this, this + size - 1) == NULL) { if (0) VG_(message)(Vg_DebugMsg, @@ -798,7 +798,7 @@ void ML_(addDiCfSI) ( struct _DebugInfo* di, "warning: DiCfSI %#lx .. %#lx is huge; length = %u (%s)\n", base, base + len - 1, len, di->soname); - vg_assert(di->fsm.have_rx_map && di->fsm.have_rw_map); + vg_assert(di->fsm.have_rx_map && di->fsm.rw_map_count); /* Find mapping where at least one end of the CFSI falls into. */ map = ML_(find_rx_mapping)(di, base, base); map2 = ML_(find_rx_mapping)(di, base + len - 1, @@ -1304,7 +1304,7 @@ void ML_(addVar)( struct _DebugInfo* di, /* This is assured us by top level steering logic in debuginfo.c, and it is re-checked at the start of ML_(read_elf_debug_info). */ - vg_assert(di->fsm.have_rx_map && di->fsm.have_rw_map); + vg_assert(di->fsm.have_rx_map && di->fsm.rw_map_count); if (level > 0 && ML_(find_rx_mapping)(di, aMin, aMax) == NULL) { if (VG_(clo_verbosity) > 1) { VG_(message)(Vg_DebugMsg, diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am index 474ef5c4c9..c8fa5b5cbf 100644 --- a/memcheck/tests/Makefile.am +++ b/memcheck/tests/Makefile.am @@ -342,6 +342,7 @@ EXTRA_DIST = \ varinfo4.stderr.exp-freebsd \ varinfo5.vgtest varinfo5.stdout.exp varinfo5.stderr.exp \ varinfo5.stderr.exp-ppc64 \ + varinfo5.stderr.exp-freebsd \ varinfo6.vgtest varinfo6.stdout.exp varinfo6.stderr.exp \ varinfo6.stderr.exp-ppc64 \ varinforestrict.vgtest varinforestrict.stderr.exp \ diff --git a/memcheck/tests/varinfo5.stderr.exp-freebsd b/memcheck/tests/varinfo5.stderr.exp-freebsd new file mode 100644 index 0000000000..df30c00d40 --- /dev/null +++ b/memcheck/tests/varinfo5.stderr.exp-freebsd @@ -0,0 +1,191 @@ +Uninitialised byte(s) found during client check request + at 0x........: croak (tests/varinfo5so.c:29) + by 0x........: varinfo1_main (tests/varinfo5so.c:52) + by 0x........: varinfo5_main (tests/varinfo5so.c:154) + by 0x........: main (tests/varinfo5.c:5) + Address 0x........ is 1 bytes inside a block of size 3 alloc'd + at 0x........: malloc (vg_replace_malloc.c:...) + by 0x........: varinfo1_main (tests/varinfo5so.c:50) + by 0x........: varinfo5_main (tests/varinfo5so.c:154) + by 0x........: main (tests/varinfo5.c:5) + +Uninitialised byte(s) found during client check request + at 0x........: croak (tests/varinfo5so.c:29) + by 0x........: varinfo1_main (tests/varinfo5so.c:55) + by 0x........: varinfo5_main (tests/varinfo5so.c:154) + by 0x........: main (tests/varinfo5.c:5) + Location 0x........ is 0 bytes inside global var "global_u1" + declared at varinfo5so.c:38 + +Uninitialised byte(s) found during client check request + at 0x........: croak (tests/varinfo5so.c:29) + by 0x........: varinfo1_main (tests/varinfo5so.c:56) + by 0x........: varinfo5_main (tests/varinfo5so.c:154) + by 0x........: main (tests/varinfo5.c:5) + Location 0x........ is 0 bytes inside global var "global_i1" + declared at varinfo5so.c:40 + +Uninitialised byte(s) found during client check request + at 0x........: croak (tests/varinfo5so.c:29) + by 0x........: varinfo1_main (tests/varinfo5so.c:57) + by 0x........: varinfo5_main (tests/varinfo5so.c:154) + by 0x........: main (tests/varinfo5.c:5) + Location 0x........ is 0 bytes inside global_u2[3], + a global variable declared at varinfo5so.c:42 + +Uninitialised byte(s) found during client check request + at 0x........: croak (tests/varinfo5so.c:29) + by 0x........: varinfo1_main (tests/varinfo5so.c:58) + by 0x........: varinfo5_main (tests/varinfo5so.c:154) + by 0x........: main (tests/varinfo5.c:5) + Location 0x........ is 0 bytes inside global_i2[7], + a global variable declared at varinfo5so.c:44 + +Uninitialised byte(s) found during client check request + at 0x........: croak (tests/varinfo5so.c:29) + by 0x........: varinfo1_main (tests/varinfo5so.c:59) + by 0x........: varinfo5_main (tests/varinfo5so.c:154) + by 0x........: main (tests/varinfo5.c:5) + Location 0x........ is 0 bytes inside local var "local" + declared at varinfo5so.c:49, in frame #X of thread 1 + +Uninitialised byte(s) found during client check request + at 0x........: croak (tests/varinfo5so.c:29) + by 0x........: foo2 (tests/varinfo5so.c:71) + by 0x........: varinfo2_main (tests/varinfo5so.c:81) + by 0x........: varinfo5_main (tests/varinfo5so.c:155) + by 0x........: main (tests/varinfo5.c:5) + Location 0x........ is 0 bytes inside var[7], + declared at varinfo5so.c:69, in frame #X of thread 1 + +Uninitialised byte(s) found during client check request + at 0x........: croak (tests/varinfo5so.c:29) + by 0x........: foo2 (tests/varinfo5so.c:73) + by 0x........: varinfo2_main (tests/varinfo5so.c:81) + by 0x........: varinfo5_main (tests/varinfo5so.c:155) + by 0x........: main (tests/varinfo5.c:5) + Location 0x........ is 2 bytes inside var.bar, + declared at varinfo5so.c:72, in frame #X of thread 1 + +Uninitialised byte(s) found during client check request + at 0x........: croak (tests/varinfo5so.c:29) + by 0x........: foo2 (tests/varinfo5so.c:76) + by 0x........: varinfo2_main (tests/varinfo5so.c:81) + by 0x........: varinfo5_main (tests/varinfo5so.c:155) + by 0x........: main (tests/varinfo5.c:5) + Address 0x........ is on thread 1's stack + in frame #X, created by foo2 (varinfo5so.c:66) + +Uninitialised byte(s) found during client check request + at 0x........: croak (tests/varinfo5so.c:29) + by 0x........: foo3 (tests/varinfo5so.c:106) + by 0x........: varinfo3_main (tests/varinfo5so.c:118) + by 0x........: varinfo5_main (tests/varinfo5so.c:156) + by 0x........: main (tests/varinfo5.c:5) + Location 0x........ is 0 bytes inside static_global_def[1], + a global variable declared at varinfo5so.c:87 + +Uninitialised byte(s) found during client check request + at 0x........: croak (tests/varinfo5so.c:29) + by 0x........: foo3 (tests/varinfo5so.c:107) + by 0x........: varinfo3_main (tests/varinfo5so.c:118) + by 0x........: varinfo5_main (tests/varinfo5so.c:156) + by 0x........: main (tests/varinfo5.c:5) + Location 0x........ is 0 bytes inside nonstatic_global_def[2], + a global variable declared at varinfo5so.c:88 + +Uninitialised byte(s) found during client check request + at 0x........: croak (tests/varinfo5so.c:29) + by 0x........: foo3 (tests/varinfo5so.c:108) + by 0x........: varinfo3_main (tests/varinfo5so.c:118) + by 0x........: varinfo5_main (tests/varinfo5so.c:156) + by 0x........: main (tests/varinfo5.c:5) + Location 0x........ is 0 bytes inside static_global_undef[3], + a global variable declared at varinfo5so.c:89 + +Uninitialised byte(s) found during client check request + at 0x........: croak (tests/varinfo5so.c:29) + by 0x........: foo3 (tests/varinfo5so.c:109) + by 0x........: varinfo3_main (tests/varinfo5so.c:118) + by 0x........: varinfo5_main (tests/varinfo5so.c:156) + by 0x........: main (tests/varinfo5.c:5) + Location 0x........ is 0 bytes inside nonstatic_global_undef[4], + a global variable declared at varinfo5so.c:90 + +Uninitialised byte(s) found during client check request + at 0x........: croak (tests/varinfo5so.c:29) + by 0x........: bar3 (tests/varinfo5so.c:94) + by 0x........: foo3 (tests/varinfo5so.c:110) + by 0x........: varinfo3_main (tests/varinfo5so.c:118) + by 0x........: varinfo5_main (tests/varinfo5so.c:156) + by 0x........: main (tests/varinfo5.c:5) + Address 0x........ is 5 bytes inside data symbol "foo3.static_local_def" + +Uninitialised byte(s) found during client check request + at 0x........: croak (tests/varinfo5so.c:29) + by 0x........: bar3 (tests/varinfo5so.c:95) + by 0x........: foo3 (tests/varinfo5so.c:110) + by 0x........: varinfo3_main (tests/varinfo5so.c:118) + by 0x........: varinfo5_main (tests/varinfo5so.c:156) + by 0x........: main (tests/varinfo5.c:5) + Address 0x........ is on thread 1's stack + in frame #X, created by foo3 (varinfo5so.c:101) + +Uninitialised byte(s) found during client check request + at 0x........: croak (tests/varinfo5so.c:29) + by 0x........: bar3 (tests/varinfo5so.c:96) + by 0x........: foo3 (tests/varinfo5so.c:110) + by 0x........: varinfo3_main (tests/varinfo5so.c:118) + by 0x........: varinfo5_main (tests/varinfo5so.c:156) + by 0x........: main (tests/varinfo5.c:5) + Address 0x........ is 7 bytes inside data symbol "foo3.static_local_undef" + +Uninitialised byte(s) found during client check request + at 0x........: croak (tests/varinfo5so.c:29) + by 0x........: bar3 (tests/varinfo5so.c:97) + by 0x........: foo3 (tests/varinfo5so.c:110) + by 0x........: varinfo3_main (tests/varinfo5so.c:118) + by 0x........: varinfo5_main (tests/varinfo5so.c:156) + by 0x........: main (tests/varinfo5.c:5) + Address 0x........ is on thread 1's stack + in frame #X, created by foo3 (varinfo5so.c:101) + +Uninitialised byte(s) found during client check request + at 0x........: croak (tests/varinfo5so.c:29) + by 0x........: blah4 (tests/varinfo5so.c:137) + by 0x........: varinfo4_main (tests/varinfo5so.c:146) + by 0x........: varinfo5_main (tests/varinfo5so.c:157) + by 0x........: main (tests/varinfo5.c:5) + Location 0x........ is 1 byte inside a[3].xyzzy[21].c1, + declared at varinfo5so.c:135, in frame #X of thread 1 + +Uninitialised byte(s) found during client check request + at 0x........: croak (tests/varinfo5so.c:29) + by 0x........: blah4 (tests/varinfo5so.c:138) + by 0x........: varinfo4_main (tests/varinfo5so.c:146) + by 0x........: varinfo5_main (tests/varinfo5so.c:157) + by 0x........: main (tests/varinfo5.c:5) + Location 0x........ is 0 bytes inside a[5].bong, + declared at varinfo5so.c:135, in frame #X of thread 1 + +Uninitialised byte(s) found during client check request + at 0x........: croak (tests/varinfo5so.c:29) + by 0x........: blah4 (tests/varinfo5so.c:139) + by 0x........: varinfo4_main (tests/varinfo5so.c:146) + by 0x........: varinfo5_main (tests/varinfo5so.c:157) + by 0x........: main (tests/varinfo5.c:5) + Location 0x........ is 1 byte inside a[3].xyzzy[21].c2[2], + declared at varinfo5so.c:135, in frame #X of thread 1 + +answer is 0 +Uninitialised byte(s) found during client check request + at 0x........: croak (tests/varinfo5so.c:29) + by 0x........: fun_c (tests/varinfo5so.c:164) + by 0x........: fun_b (./varinfo5so.c:168) + by 0x........: fun_a (./varinfo5so.c:172) + by 0x........: inlinetest (./varinfo5so.c:178) + by 0x........: varinfo5_main (tests/varinfo5so.c:158) + by 0x........: main (tests/varinfo5.c:5) + Address 0x........ is on thread 1's stack + in frame #X, created by inlinetest (varinfo5so.c:176) + |
|
From: Paul F. <pa...@so...> - 2022-06-08 21:18:21
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=67b8fef50bfaed0ce5a1d8130836bcef0eafcd4b commit 67b8fef50bfaed0ce5a1d8130836bcef0eafcd4b Author: Paul Floyd <pj...@wa...> Date: Wed Jun 8 23:17:09 2022 +0200 Regtest memcheck/tests/amd64/shr_edx does not build on macOS Make it conditional Diff: --- memcheck/tests/amd64/Makefile.am | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/memcheck/tests/amd64/Makefile.am b/memcheck/tests/amd64/Makefile.am index 8b8785613c..a5a78aa310 100644 --- a/memcheck/tests/amd64/Makefile.am +++ b/memcheck/tests/amd64/Makefile.am @@ -46,8 +46,8 @@ check_PROGRAMS = \ insn-pmovmskb \ sh-mem-vec128 \ sse_memory \ - xor-undef-amd64 \ - shr_edx + xor-undef-amd64 + if BUILD_AVX_TESTS check_PROGRAMS += sh-mem-vec256 xsave-avx endif @@ -60,6 +60,13 @@ if !COMPILER_IS_CLANG more_x87_fp endif +# initially this was a "not clang" test +# but the problem is macOS, not clang +if !VGCONF_OS_IS_DARWIN + check_PROGRAMS += \ + shr_edx +endif + AM_CFLAGS += @FLAG_M64@ AM_CXXFLAGS += @FLAG_M64@ AM_CCASFLAGS += @FLAG_M64@ |
|
From: Paul F. <pa...@so...> - 2022-06-07 18:38:56
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=26cfb342f1ed33839804357e294772e1af28b5e8 commit 26cfb342f1ed33839804357e294772e1af28b5e8 Author: Paul Floyd <pj...@wa...> Date: Tue Jun 7 20:38:17 2022 +0200 A little bit in indentation Diff: --- coregrind/m_scheduler/scheduler.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/coregrind/m_scheduler/scheduler.c b/coregrind/m_scheduler/scheduler.c index ea36cd4f56..00cc0c6889 100644 --- a/coregrind/m_scheduler/scheduler.c +++ b/coregrind/m_scheduler/scheduler.c @@ -309,8 +309,8 @@ ThreadId VG_(alloc_ThreadState) ( void ) Int i; for (i = 1; i < VG_N_THREADS; i++) { if (VG_(threads)[i].status == VgTs_Empty) { - VG_(threads)[i].status = VgTs_Init; - VG_(threads)[i].exitreason = VgSrc_None; + VG_(threads)[i].status = VgTs_Init; + VG_(threads)[i].exitreason = VgSrc_None; if (VG_(threads)[i].thread_name) VG_(free)(VG_(threads)[i].thread_name); VG_(threads)[i].thread_name = NULL; @@ -469,9 +469,9 @@ void VG_(get_thread_out_of_syscall)(ThreadId tid) if (VG_(threads)[tid].status == VgTs_WaitSys) { if (VG_(clo_trace_signals)) { - VG_(message)(Vg_DebugMsg, + VG_(message)(Vg_DebugMsg, "get_thread_out_of_syscall zaps tid %u lwp %d\n", - tid, VG_(threads)[tid].os_state.lwpid); + tid, VG_(threads)[tid].os_state.lwpid); } # if defined(VGO_darwin) { @@ -657,7 +657,7 @@ static void sched_fork_cleanup(ThreadId me) for (tid = 1; tid < VG_N_THREADS; tid++) { if (tid != me) { mostly_clear_thread_record(tid); - VG_(threads)[tid].status = VgTs_Empty; + VG_(threads)[tid].status = VgTs_Empty; VG_(clear_syscallInfo)(tid); } } |
|
From: Paul F. <pa...@so...> - 2022-06-06 20:38:09
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=3ce76737204b5f439324096d238674d52e7cd406 commit 3ce76737204b5f439324096d238674d52e7cd406 Author: Paul Floyd <pj...@wa...> Date: Mon Jun 6 22:32:53 2022 +0200 Add syscall wrappers for FreeBSD funlinkat and copy_file_range Aslo add a smoketest for /bin/cp, which uses copy_file_range Diff: --- coregrind/m_syswrap/priv_syswrap-freebsd.h | 4 +-- coregrind/m_syswrap/syswrap-freebsd.c | 51 ++++++++++++++++++++++++++++-- none/tests/freebsd/Makefile.am | 2 ++ none/tests/freebsd/cp.stderr.exp | 0 none/tests/freebsd/cp.vgtest | 7 ++++ 5 files changed, 59 insertions(+), 5 deletions(-) diff --git a/coregrind/m_syswrap/priv_syswrap-freebsd.h b/coregrind/m_syswrap/priv_syswrap-freebsd.h index 70fc431cc0..437047c533 100644 --- a/coregrind/m_syswrap/priv_syswrap-freebsd.h +++ b/coregrind/m_syswrap/priv_syswrap-freebsd.h @@ -526,8 +526,8 @@ DECL_TEMPLATE(freebsd, sys_fhreadlink) // 567 #if (FREEBSD_VERS >= FREEBSD_12_2) -// unimpl __NR_funlinkat 568 -// unimpl __NR_copy_file_range 569 +DECL_TEMPLATE(freebsd, sys_funlinkat) // 568 +DECL_TEMPLATE(freebsd, sys_copy_file_range) // 569 DECL_TEMPLATE(freebsd, sys___sysctlbyname) // 570 #if (FREEBSD_VERS >= FREEBSD_13_0) diff --git a/coregrind/m_syswrap/syswrap-freebsd.c b/coregrind/m_syswrap/syswrap-freebsd.c index b8f5250b94..20718badd6 100644 --- a/coregrind/m_syswrap/syswrap-freebsd.c +++ b/coregrind/m_syswrap/syswrap-freebsd.c @@ -5200,7 +5200,8 @@ PRE(sys_symlinkat) PRE(sys_unlinkat) { *flags |= SfMayBlock; - PRINT("sys_unlinkat ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x(%s) )", ARG1,ARG2,(char*)ARG2); + PRINT("sys_unlinkat ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u ", + ARG1, ARG2, (char*)ARG2, ARG3); PRE_REG_READ3(int, "unlinkat", int, fd, const char *, path, int, flag); PRE_MEM_RASCIIZ( "unlinkat(path)", ARG2 ); } @@ -6185,6 +6186,50 @@ POST(sys_fhreadlink) #if (FREEBSD_VERS >= FREEBSD_12_2) +// SYS_unlinkat 568 +// int funlinkat(int dfd, const char *path, int fd, int flag); +PRE(sys_funlinkat) +{ + *flags |= SfMayBlock; + PRINT("sys_funlinkat ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u, %" FMT_REGWORD"u )", + SARG1, ARG2, (char*)ARG2, ARG4, ARG5); + PRE_REG_READ4(int, "funlinkat", int, dfd, const char *, path, int, fd, int, flag); + PRE_MEM_RASCIIZ( "funlinkat(path)", ARG2 ); +} + +// SYS_copy_file_range 569 +// ssize_t copy_file_range(int infd, off_t *inoffp, int outfd, off_t *outoffp, +// size_t len, unsigned int flags); +PRE(sys_copy_file_range) +{ + PRINT("sys_copy_file_range (%" FMT_REGWORD"d, %#" FMT_REGWORD "x, %" FMT_REGWORD "d, %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "d, %" FMT_REGWORD "d)", + SARG1, ARG2, SARG3, ARG4, (char*)ARG4, SARG5, SARG6); + + PRE_REG_READ6(vki_ssize_t, "copy_file_range", + int, "infd", + vki_off_t *, "inoffp", + int, "outfd", + vki_off_t *, "outoffp", + vki_size_t, "len", + unsigned int, "flags"); + + /* File descriptors are "specially" tracked by valgrind. + valgrind itself uses some, so make sure someone didn't + put in one of our own... */ + if (!ML_(fd_allowed)(ARG1, "copy_file_range(infd)", tid, False) || + !ML_(fd_allowed)(ARG3, "copy_file_range(infd)", tid, False)) { + SET_STATUS_Failure( VKI_EBADF ); + } else { + /* Now see if the offsets are defined. PRE_MEM_READ will + double check it can dereference them. */ + if (ARG2 != 0) + PRE_MEM_READ( "copy_file_range(inoffp)", ARG2, sizeof(vki_off_t)); + if (ARG4 != 0) + PRE_MEM_READ( "copy_file_range(outoffp)", ARG4, sizeof(vki_off_t)); + } +} + + // SYS___sysctlbyname 570 // int sysctlbyname(const char *name, void *oldp, size_t *oldlenp, // const void *newp, size_t newlen); @@ -7031,8 +7076,8 @@ const SyscallTableEntry ML_(syscall_table)[] = { #endif // FREEBSD_VERS >= FREEBSD_12 #if (FREEBSD_VERS >= FREEBSD_12_2) - // unimpl __NR_funlinkat 568 - // unimpl __NR_copy_file_range 569 + BSDX_(__NR_funlinkat, sys_funlinkat), // 568 + BSDX_(__NR_copy_file_range, sys_copy_file_range), // 569 BSDXY(__NR___sysctlbyname, sys___sysctlbyname), // 570 #if (FREEBSD_VERS >= FREEBSD_13_0) diff --git a/none/tests/freebsd/Makefile.am b/none/tests/freebsd/Makefile.am index 4b94071b4b..4a29928238 100644 --- a/none/tests/freebsd/Makefile.am +++ b/none/tests/freebsd/Makefile.am @@ -8,6 +8,8 @@ EXTRA_DIST = \ auxv.stderr.exp-32on64 \ auxv.stderr.exp-freebsd13 \ auxv.stderr.exp-freebsd131 \ + cp.vgtest \ + cp.stderr.exp \ osrel.vgtest \ osrel.stderr.exp \ osrel.stdout.exp \ diff --git a/none/tests/freebsd/cp.stderr.exp b/none/tests/freebsd/cp.stderr.exp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/none/tests/freebsd/cp.vgtest b/none/tests/freebsd/cp.vgtest new file mode 100644 index 0000000000..931fffbf01 --- /dev/null +++ b/none/tests/freebsd/cp.vgtest @@ -0,0 +1,7 @@ +# basic smoke test, but even this can fail +# the copy_file_range syscall was added in FreeBSD 12 +# and then used in the cp command +prog: /bin/cp +args: cp.vgtest cp.out +vgopts: -q +cleanup: rm cp.out |
|
From: Paul F. <pa...@so...> - 2022-06-06 13:59:14
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=6cc2d94d93fa5350355b8cedb0d6b5309fcc588c commit 6cc2d94d93fa5350355b8cedb0d6b5309fcc588c Author: Paul Floyd <pj...@wa...> Date: Mon Jun 6 15:18:29 2022 +0200 Use a different way to tell where the syscall handler was interrupted on FreeBSD and macOS I was using a global variable. This would be set to '1' just before calling the function to save cflags and cleared just after, then using the variable to fill in the 'outside_rnage_ condition in VG_(fixup_guest_state_after_syscall_interrupted) Even though I haven't experienced any isseus with that, the comments just before do_syscall_for_client made me want to try an alternative. This code is very ugly and won't please the language lawyers. Functions aren't guaranteed to have an address and there is no guarantee that the binary layout will reflect the source layout. Sadly C doesn't have something like "sizeof(*function)" to give the size of a function in bytes. The next best that I could manage was to use dummy 'marker' functions just after the ones I want the end address of and then use the address of 'marker - 1' I did think of one other way to do this. That would be to generate a C file containing the function sizes. This would require 1. "put_flag_size.c" would depend on the VEX guest_(x86|amd64)_helpers object files 2. Extract the sizes, for instance echo -n "const size_t x86_put_eflag_c_size = 0x" > put_flag_size.c nm -F sysv libvex_x86_freebsd_a-guest_x86_helpers.o | awk -F\| '/LibVEX_GuestX86_put_eflag_c/{print $5}' >> put_flag_size.c echo ";" >> put_flag_size.c That seems fairly difficult to do in automake and I'm not sure if it would be robust. Diff: --- VEX/priv/guest_amd64_helpers.c | 28 ++++++++++++++++++++++++ VEX/priv/guest_x86_helpers.c | 23 +++++++++++++++++++ VEX/pub/libvex_guest_amd64.h | 7 ++++++ VEX/pub/libvex_guest_x86.h | 6 +++++ coregrind/m_syswrap/syscall-amd64-darwin.S | 5 ----- coregrind/m_syswrap/syscall-amd64-freebsd.S | 8 ------- coregrind/m_syswrap/syscall-x86-darwin.S | 4 ---- coregrind/m_syswrap/syscall-x86-freebsd.S | 7 ------ coregrind/m_syswrap/syswrap-main.c | 34 ++++++++++++++++++++++++----- 9 files changed, 93 insertions(+), 29 deletions(-) diff --git a/VEX/priv/guest_amd64_helpers.c b/VEX/priv/guest_amd64_helpers.c index ba71c1b62f..abd2a1e370 100644 --- a/VEX/priv/guest_amd64_helpers.c +++ b/VEX/priv/guest_amd64_helpers.c @@ -768,6 +768,25 @@ ULong amd64g_calculate_rflags_all_WRK ( ULong cc_op, } } +#if defined(VGO_freebsd) || defined(VGO_darwin) + +/* This dummy function is just used to have an address just after + amd64g_calculate_rflags_all_WRK */ + +static +void _______VVVVVVVV_amd64g_calculate_rflags_all_WRK_VVVVVVVV_______ (void) +{ +} + +/* Export addresses of amd64g_calculate_rflags_all_WRK and + _______VVVVVVVV_amd64g_calculate_rflags_all_WRK_VVVVVVVV_______ + Used in syswrap-main.c / VG_(post_syscall) in the case where + the above function was interrupted and we need to work out + what needs to be done for the resumption */ + +Addr addr_amd64g_calculate_rflags_all_WRK = (Addr)amd64g_calculate_rflags_all_WRK; +Addr addr________VVVVVVVV_amd64g_calculate_rflags_all_WRK_VVVVVVVV_______ = (Addr)_______VVVVVVVV_amd64g_calculate_rflags_all_WRK_VVVVVVVV_______; +#endif /* CALLED FROM GENERATED CODE: CLEAN HELPER */ /* Calculate all the 6 flags from the supplied thunk parameters. */ @@ -994,6 +1013,15 @@ LibVEX_GuestAMD64_put_rflag_c ( ULong new_carry_flag, vex_state->guest_CC_NDEP = 0; } +#if defined(VGO_freebsd) || defined(VGO_darwin) +/* Used in syswrap-main.c / VG_(post_syscall) in the case where + the above function was interrupted and we need to work out + what needs to be done for the resumption. These functions + are extern so no need for 'addr' global variables */ +void _______VVVVVVVV_after_GuestAMD64_put_rflag_c_VVVVVVVV_______ (void) +{ +} +#endif /*---------------------------------------------------------------*/ /*--- %rflags translation-time function specialisers. ---*/ diff --git a/VEX/priv/guest_x86_helpers.c b/VEX/priv/guest_x86_helpers.c index c0a4d33edc..7b229cb795 100644 --- a/VEX/priv/guest_x86_helpers.c +++ b/VEX/priv/guest_x86_helpers.c @@ -567,6 +567,20 @@ UInt x86g_calculate_eflags_all_WRK ( UInt cc_op, } } +#if defined(VGO_freebsd) || defined(VGO_darwin) + +/* see guest_amd64_helpers.c + Used in syswrap-main.c / VG_(post_syscall) for signal + resumption */ + +static void _______VVVVVVVV_after_x86g_calculate_eflags_all_WRK_VVVVVVVV_______ (void) +{ +} + +Addr addr_x86g_calculate_eflags_all_WRK = (Addr)x86g_calculate_eflags_all_WRK; +Addr addr________VVVVVVVV_x86g_calculate_eflags_all_WRK_VVVVVVVV_______ = (Addr)_______VVVVVVVV_after_x86g_calculate_eflags_all_WRK_VVVVVVVV_______; +#endif + /* CALLED FROM GENERATED CODE: CLEAN HELPER */ /* Calculate all the 6 flags from the supplied thunk parameters. */ @@ -790,6 +804,15 @@ LibVEX_GuestX86_put_eflag_c ( UInt new_carry_flag, vex_state->guest_CC_NDEP = 0; } +#if defined(VGO_freebsd) || defined(VGO_darwin) + +/* Used in syswrap-main.c / VG_(post_syscall) for signal resumption */ + +void _______VVVVVVVV_after_LibVEX_GuestX86_put_eflag_c_VVVVVVVV_______ (void) +{ +} +#endif + /*---------------------------------------------------------------*/ /*--- %eflags translation-time function specialisers. ---*/ diff --git a/VEX/pub/libvex_guest_amd64.h b/VEX/pub/libvex_guest_amd64.h index 1518ba304c..864b54b04e 100644 --- a/VEX/pub/libvex_guest_amd64.h +++ b/VEX/pub/libvex_guest_amd64.h @@ -203,6 +203,13 @@ void LibVEX_GuestAMD64_put_rflag_c ( ULong new_carry_flag, /*MOD*/VexGuestAMD64State* vex_state ); +#if defined(VGO_freebsd) || defined(VGO_darwin) +void _______VVVVVVVV_after_GuestAMD64_put_rflag_c_VVVVVVVV_______ (void); +extern Addr addr_amd64g_calculate_rflags_all_WRK; +extern Addr addr________VVVVVVVV_amd64g_calculate_rflags_all_WRK_VVVVVVVV_______; +#endif + + /* Do FXSAVE from the supplied VexGuestAMD64tate structure and store the result at the given address which represents a buffer of at least 416 bytes. */ diff --git a/VEX/pub/libvex_guest_x86.h b/VEX/pub/libvex_guest_x86.h index fabafe113c..53f72acb8c 100644 --- a/VEX/pub/libvex_guest_x86.h +++ b/VEX/pub/libvex_guest_x86.h @@ -292,6 +292,12 @@ void LibVEX_GuestX86_put_eflag_c ( UInt new_carry_flag, /*MOD*/VexGuestX86State* vex_state ); +#if defined(VGO_freebsd) || defined(VGO_darwin) +extern void _______VVVVVVVV_after_LibVEX_GuestX86_put_eflag_c_VVVVVVVV_______ (void); +extern Addr addr_x86g_calculate_eflags_all_WRK; +extern Addr addr________VVVVVVVV_x86g_calculate_eflags_all_WRK_VVVVVVVV_______; +#endif + /* Do x87 save from the supplied VexGuestX86State structure and store the result at the given address which represents a buffer of at least 108 bytes. */ diff --git a/coregrind/m_syswrap/syscall-amd64-darwin.S b/coregrind/m_syswrap/syscall-amd64-darwin.S index 8a970fa088..ed93a851eb 100644 --- a/coregrind/m_syswrap/syscall-amd64-darwin.S +++ b/coregrind/m_syswrap/syscall-amd64-darwin.S @@ -248,11 +248,6 @@ ML_(blksys_complete_UNIX): .quad MK_L_SCCLASS_N(UNIX,3) ML_(blksys_committed_UNIX): .quad MK_L_SCCLASS_N(UNIX,4) ML_(blksys_finished_UNIX): .quad MK_L_SCCLASS_N(UNIX,5) -.data -globl ML_(blksys_saving_cflag) -ML_(blksys_saving_cflag): .quad 0 -.previous - #endif // defined(VGP_amd64_darwin) /* Let the linker know we don't need an executable stack */ diff --git a/coregrind/m_syswrap/syscall-amd64-freebsd.S b/coregrind/m_syswrap/syscall-amd64-freebsd.S index 55d53f0b76..8f084c3e19 100644 --- a/coregrind/m_syswrap/syscall-amd64-freebsd.S +++ b/coregrind/m_syswrap/syscall-amd64-freebsd.S @@ -153,9 +153,7 @@ ML_(do_syscall_for_client_WRK): movq %rax, %rdi /* arg1 = new flag */ movq %r11, %rsi /* arg2 = vex state */ addq $24, %rsp /* remove syscall parameters */ - movq $0x1, ML_(blksys_saving_cflag) call LibVEX_GuestAMD64_put_rflag_c - movq $0x0, ML_(blksys_saving_cflag) 4: /* Re-block signals. If eip is in [4,5), then the syscall is complete and we needn't worry about it. */ @@ -208,12 +206,6 @@ ML_(blksys_committed): .quad 4b ML_(blksys_finished): .quad 5b .previous - .data - .globl ML_(blksys_saving_cflag) - ML_(blksys_saving_cflag): .quad 0 - .previous - - #endif /* defined(VGP_amd64_freebsd) */ /* Let the linker know we don't need an executable stack */ diff --git a/coregrind/m_syswrap/syscall-x86-darwin.S b/coregrind/m_syswrap/syscall-x86-darwin.S index cbeadc52f8..9032422685 100644 --- a/coregrind/m_syswrap/syscall-x86-darwin.S +++ b/coregrind/m_syswrap/syscall-x86-darwin.S @@ -246,10 +246,6 @@ ML_(blksys_complete_UNIX): .long MK_L_SCCLASS_N(UNIX,3) ML_(blksys_committed_UNIX): .long MK_L_SCCLASS_N(UNIX,4) ML_(blksys_finished_UNIX): .long MK_L_SCCLASS_N(UNIX,5) -.data -.globl ML_(blksys_saving_cflag) -ML_(blksys_saving_cflag): .long 0 -.previous #endif // defined(VGP_x86_darwin) /* Let the linker know we don't need an executable stack */ diff --git a/coregrind/m_syswrap/syscall-x86-freebsd.S b/coregrind/m_syswrap/syscall-x86-freebsd.S index 523d3d2e0d..1faa74c4d6 100644 --- a/coregrind/m_syswrap/syscall-x86-freebsd.S +++ b/coregrind/m_syswrap/syscall-x86-freebsd.S @@ -143,9 +143,7 @@ ML_(do_syscall_for_client_WRK): movl $0, 0(%esp) movb 12(%esp), %al movb %al, 0(%esp) - movl $0x1, ML_(blksys_saving_cflag) call LibVEX_GuestX86_put_eflag_c - movl $0x0, ML_(blksys_saving_cflag) addl $12, %esp 4: /* Re-block signals. If eip is in [4,5), then the syscall is @@ -193,11 +191,6 @@ ML_(blksys_committed): .long 4b ML_(blksys_finished): .long 5b .previous - .data - .globl ML_(blksys_saving_cflag) - ML_(blksys_saving_cflag): .long 0 - .previous - #endif // defined(VGP_x86_freebsd) /* Let the linker know we don't need an executable stack */ diff --git a/coregrind/m_syswrap/syswrap-main.c b/coregrind/m_syswrap/syswrap-main.c index 5824a1dbea..5077a7da73 100644 --- a/coregrind/m_syswrap/syswrap-main.c +++ b/coregrind/m_syswrap/syswrap-main.c @@ -2569,9 +2569,6 @@ void VG_(post_syscall) (ThreadId tid) extern const Addr ML_(blksys_complete); extern const Addr ML_(blksys_committed); extern const Addr ML_(blksys_finished); -#if defined(VGO_freebsd) - extern const Addr ML_(blksys_saving_cflag); -#endif #elif defined(VGO_darwin) /* Darwin requires extra uglyness */ extern const Addr ML_(blksys_setup_MACH); @@ -2589,7 +2586,6 @@ void VG_(post_syscall) (ThreadId tid) extern const Addr ML_(blksys_complete_UNIX); extern const Addr ML_(blksys_committed_UNIX); extern const Addr ML_(blksys_finished_UNIX); - extern const Addr ML_(blksys_saving_cflag); #elif defined(VGO_solaris) extern const Addr ML_(blksys_setup); extern const Addr ML_(blksys_complete); @@ -3123,7 +3119,35 @@ VG_(fixup_guest_state_after_syscall_interrupted)( ThreadId tid, #if defined(VGO_freebsd) || defined(VGO_darwin) if (outside_range) { - if (ML_(blksys_saving_cflag)) + /* This is not guaranteed to work since the compiler / link editor + could lay out the binary functions in a different order to + the source file. However, it seems to work. */ + +#if defined (VGA_amd64) + + vg_assert((Addr)_______VVVVVVVV_after_GuestAMD64_put_rflag_c_VVVVVVVV_______ > + (Addr)LibVEX_GuestAMD64_put_rflag_c ); + + vg_assert(addr________VVVVVVVV_amd64g_calculate_rflags_all_WRK_VVVVVVVV_______ > + addr_amd64g_calculate_rflags_all_WRK); + + if ((ip >= (Addr)LibVEX_GuestAMD64_put_rflag_c && + ip < (Addr)_______VVVVVVVV_after_GuestAMD64_put_rflag_c_VVVVVVVV_______) || + (ip >= addr_amd64g_calculate_rflags_all_WRK && + ip < addr________VVVVVVVV_amd64g_calculate_rflags_all_WRK_VVVVVVVV_______)) +#else + + vg_assert((Addr)_______VVVVVVVV_after_LibVEX_GuestX86_put_eflag_c_VVVVVVVV_______ > + (Addr)LibVEX_GuestX86_put_eflag_c); + + vg_assert(addr________VVVVVVVV_x86g_calculate_eflags_all_WRK_VVVVVVVV_______> + addr_x86g_calculate_eflags_all_WRK); + + if ((ip >= (Addr)LibVEX_GuestX86_put_eflag_c && + ip < (Addr)_______VVVVVVVV_after_LibVEX_GuestX86_put_eflag_c_VVVVVVVV_______) || + (ip >= addr_x86g_calculate_eflags_all_WRK && + ip < addr________VVVVVVVV_x86g_calculate_eflags_all_WRK_VVVVVVVV_______)) +#endif { outside_range = False; in_complete_to_committed = True; |
|
From: Paul F. <pa...@so...> - 2022-06-06 09:23:48
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=eeaf547e6c345834032c73f63595dc52a9fbf585 commit eeaf547e6c345834032c73f63595dc52a9fbf585 Author: Paul Floyd <pj...@wa...> Date: Mon Jun 6 11:20:39 2022 +0200 Fix FreeBSD x86 allocation of GDT for threads on x86 Also update README.freebsd This is about the last significant failure that is x86 FreeBSD specific. Diff: --- README.freebsd | 12 +++----- coregrind/m_syswrap/syswrap-x86-freebsd.c | 50 +++++++++++++++++++++---------- 2 files changed, 39 insertions(+), 23 deletions(-) diff --git a/README.freebsd b/README.freebsd index 8a8981439c..f33ba2f9b6 100644 --- a/README.freebsd +++ b/README.freebsd @@ -21,7 +21,7 @@ $ ./configure --prefix=/where/ever $ gmake $ gmake install -Known Limitations (December 2020) +Known Limitations (June 2022) 0. Be aware that if you use a wrapper script and run Valgrind on the wrapper script Valgrind may hit restrictions if the wrapper script runs any @@ -31,13 +31,9 @@ Known Limitations (December 2020) application. 1. There are some limitations when running Valgrind on code that was compiled with clang. These issues are not present with code compiled with GCC. - a) There may be missing source information concerning variables. - b) The client request mechanism may not work entirely correctly. - c) Code that uses OpenMP will generate spurious errors. -2. There are some limitations specific to i386 - a) In some cases signals are mishandled causing Valgrind to terminate and - report a SIGSEGV. - b) Applications that create and join many threads may crash. + a) There may be missing source information concerning variables due + to DWARF extensions ised by GCC. + b) Code that uses OpenMP will generate spurious errors. Notes for Developers ~~~~~~~~~~~~~~~~~~~~ diff --git a/coregrind/m_syswrap/syswrap-x86-freebsd.c b/coregrind/m_syswrap/syswrap-x86-freebsd.c index 4abd44cda6..fe46e1eabd 100644 --- a/coregrind/m_syswrap/syswrap-x86-freebsd.c +++ b/coregrind/m_syswrap/syswrap-x86-freebsd.c @@ -351,7 +351,6 @@ static VexGuestX86SegDescr* alloc_zeroed_x86_GDT ( void ) return VG_(arena_calloc)(VG_AR_CORE, "di.syswrap-x86.azxG.1", nbytes, 1); } -#if 0 /* Create a zeroed-out LDT. */ static VexGuestX86SegDescr* alloc_zeroed_x86_LDT ( void ) { @@ -408,7 +407,6 @@ static void deallocate_LGDTs_for_thread ( VexGuestX86State* vex ) vex->guest_GDT = (HWord)NULL; } } -#endif static SysRes sys_set_thread_area ( ThreadId tid, Int *idxptr, void *base) { @@ -475,6 +473,36 @@ static SysRes sys_get_thread_area ( ThreadId tid, Int idx, void ** basep ) return VG_(mk_SysRes_Success)( 0 ); } +static +void x86_setup_LDT_GDT ( /*OUT*/ ThreadArchState *child, + /*IN*/ ThreadArchState *parent ) +{ + /* We inherit our parent's LDT. */ + if (parent->vex.guest_LDT == (HWord)NULL) { + /* We hope this is the common case. */ + child->vex.guest_LDT = (HWord)NULL; + } else { + /* No luck .. we have to take a copy of the parent's. */ + child->vex.guest_LDT = (HWord)alloc_zeroed_x86_LDT(); + copy_LDT_from_to( (VexGuestX86SegDescr*)(HWord)parent->vex.guest_LDT, + (VexGuestX86SegDescr*)(HWord)child->vex.guest_LDT ); + } + + /* Either we start with an empty GDT (the usual case) or inherit a + copy of our parents' one (Quadrics Elan3 driver -style clone + only). */ + child->vex.guest_GDT = (HWord)NULL; + + if (parent->vex.guest_GDT != (HWord)NULL) { + //child->vex.guest_GDT = (HWord)alloc_system_x86_GDT(); + child->vex.guest_GDT = (HWord)alloc_zeroed_x86_GDT(); + copy_GDT_from_to( (VexGuestX86SegDescr*)(HWord)parent->vex.guest_GDT, + (VexGuestX86SegDescr*)(HWord)child->vex.guest_GDT ); + } +} + + + /* --------------------------------------------------------------------- More thread stuff ------------------------------------------------------------------ */ @@ -488,19 +516,7 @@ void VG_(cleanup_thread) ( ThreadArchState* arch ) * Alternatively the rtld use is after the start of the next thread and we haven't * reallocated this memory */ - /*deallocate_LGDTs_for_thread( &arch->vex );*/ - - /* - * This was plan B, just recycle the slot - * It fixes none/tests/manythreads - * but it breaks drd/tests/fork-parallel - */ -#if 0 - VexGuestX86SegDescr* gdt = (VexGuestX86SegDescr*) arch->vex.guest_GDT; - if (gdt) - translate_to_hw_format(0, &gdt[arch->vex.guest_GS >> 3]); -#endif - + deallocate_LGDTs_for_thread( &arch->vex ); } @@ -1068,6 +1084,8 @@ PRE(sys_thr_new) ctst->arch.vex.guest_EDX = 0; LibVEX_GuestX86_put_eflag_c(0, &ctst->arch.vex); + x86_setup_LDT_GDT(&ctst->arch, &ptst->arch); + ctst->os_state.parent = tid; /* inherit signal mask */ @@ -1087,7 +1105,9 @@ PRE(sys_thr_new) if (debug) VG_(printf)("clone child has SETTLS: tls at %#lx\n", (Addr)tp.tls_base); + sys_set_thread_area( ctid, &idx, tp.tls_base ); + ctst->arch.vex.guest_GS = (idx << 3) | 3; /* GSEL(GUGS_SEL, SEL_UPL) */ tp.tls_base = 0; /* Don't have the kernel do it too */ |
|
From: Paul F. <pa...@so...> - 2022-06-02 19:05:07
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=036a55f77d00c046628d0ec52c19deccda5f81f2 commit 036a55f77d00c046628d0ec52c19deccda5f81f2 Author: Paul Floyd <pj...@wa...> Date: Thu Jun 2 21:02:59 2022 +0200 Remove expected from EXTRA_DIST Diff: --- memcheck/tests/Makefile.am | 1 - 1 file changed, 1 deletion(-) diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am index 302006e8bc..474ef5c4c9 100644 --- a/memcheck/tests/Makefile.am +++ b/memcheck/tests/Makefile.am @@ -145,7 +145,6 @@ EXTRA_DIST = \ descr_belowsp.vgtest descr_belowsp.stderr.exp \ doublefree.stderr.exp doublefree.vgtest \ dw4.vgtest dw4.stderr.exp dw4.stderr.exp-solaris dw4.stdout.exp \ - dw4.stderr.exp-freebsd \ err_disable1.vgtest err_disable1.stderr.exp \ err_disable2.vgtest err_disable2.stderr.exp \ err_disable3.vgtest err_disable3.stderr.exp \ |
|
From: Paul F. <pa...@so...> - 2022-06-02 18:33:16
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=7b0cd3ac2884d2557a476e5010d44e60ff531846 commit 7b0cd3ac2884d2557a476e5010d44e60ff531846 Author: Paul Floyd <pj...@wa...> Date: Thu Jun 2 20:31:12 2022 +0200 Add code that makes 1st page after brk inaccessible. Also remove FreeBSD expected. Note: this code is also mssing from Solaris and macOS initimg's. Diff: --- coregrind/m_initimg/initimg-freebsd.c | 9 +++++++ memcheck/tests/dw4.stderr.exp-freebsd | 49 ----------------------------------- 2 files changed, 9 insertions(+), 49 deletions(-) diff --git a/coregrind/m_initimg/initimg-freebsd.c b/coregrind/m_initimg/initimg-freebsd.c index 6029ffb69b..fcf05c86ac 100644 --- a/coregrind/m_initimg/initimg-freebsd.c +++ b/coregrind/m_initimg/initimg-freebsd.c @@ -986,6 +986,15 @@ void VG_(ii_finalise_image)( IIFinaliseImageInfo iifii ) /* Tell the tool that we just wrote to the registers. */ VG_TRACK( post_reg_write, Vg_CoreStartup, /*tid*/1, /*offset*/0, sizeof(VexGuestArchState)); + + /* Tell the tool about the client data segment and then kill it which will + make it inaccessible/unaddressable. */ + const NSegment *seg = VG_(am_find_nsegment)(VG_(brk_base)); + vg_assert(seg); + vg_assert(seg->kind == SkAnonC); + VG_TRACK(new_mem_brk, VG_(brk_base), seg->end + 1 - VG_(brk_base), + 1/*tid*/); + VG_TRACK(die_mem_brk, VG_(brk_base), seg->end + 1 - VG_(brk_base)); } #endif // defined(VGO_freebsd) diff --git a/memcheck/tests/dw4.stderr.exp-freebsd b/memcheck/tests/dw4.stderr.exp-freebsd deleted file mode 100644 index e396a43b8a..0000000000 --- a/memcheck/tests/dw4.stderr.exp-freebsd +++ /dev/null @@ -1,49 +0,0 @@ -Uninitialised byte(s) found during client check request - at 0x........: croak (dw4.c:32) - by 0x........: main (dw4.c:59) - Address 0x........ is 4 bytes inside a block of size ... alloc'd - at 0x........: malloc (vg_replace_malloc.c:...) - by 0x........: main (dw4.c:52) - -Uninitialised byte(s) found during client check request - at 0x........: croak (dw4.c:32) - by 0x........: main (dw4.c:61) - Location 0x........ is 0 bytes inside S2[0].i, - a global variable declared at dw4.c:47 - -Uninitialised byte(s) found during client check request - at 0x........: croak (dw4.c:32) - by 0x........: main (dw4.c:62) - Location 0x........ is 0 bytes inside local.i, - declared at dw4.c:51, in frame #1 of thread 1 - -Uninitialised byte(s) found during client check request - at 0x........: croak (dw4.c:32) - by 0x........: main (dw4.c:68) - Address 0x........ is in a rw- anonymous segment - -Uninitialised byte(s) found during client check request - at 0x........: croak (dw4.c:32) - by 0x........: main (dw4.c:82) - Address 0x........ is in a rw- mapped file valgrind-dw4-test.PID segment - -Uninitialised byte(s) found during client check request - at 0x........: croak (dw4.c:32) - by 0x........: main (dw4.c:87) - Address 0x........ is 0 bytes after the brk data segment limit 0x........ - -Uninitialised byte(s) found during client check request - at 0x........: croak (dw4.c:32) - by 0x........: main (dw4.c:89) - Address 0x........ is in the brk data segment 0x........-0x........ - -Uninitialised byte(s) found during client check request - at 0x........: croak (dw4.c:32) - by 0x........: main (dw4.c:91) - Address 0x........ is in the brk data segment 0x........-0x........ - -Unaddressable byte(s) found during client check request - at 0x........: croak (dw4.c:25) - by 0x........: main (dw4.c:93) - Address 0x........ is 1024 bytes after the brk data segment limit 0x........ - |
|
From: Paul F. <pa...@so...> - 2022-06-01 20:12:18
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=4fb52a67b5650ecc3c7d90d39ab2dc67b4476505 commit 4fb52a67b5650ecc3c7d90d39ab2dc67b4476505 Author: Paul Floyd <pj...@wa...> Date: Wed Jun 1 22:09:50 2022 +0200 Cleanup of str* and mem* functions Add function checks to configure.ac Use the configure HAVE_ macro rather than OS-dependent tests. I suspect that a lot of the tests hve been obsolete for many years. Add wrappers to FreeBSD. :w Diff: --- configure.ac | 5 +++++ dhat/tests/copy.c | 6 +++--- memcheck/tests/str_tester.c | 24 +++++++++++------------- shared/vg_replace_strmem.c | 15 +++++++++++++++ 4 files changed, 34 insertions(+), 16 deletions(-) diff --git a/configure.ac b/configure.ac index eda617fc58..369daa173a 100755 --- a/configure.ac +++ b/configure.ac @@ -4790,6 +4790,11 @@ AC_CHECK_FUNCS([ \ swapcontext \ syscall \ utimensat \ + mempcpy \ + stpncpy \ + strchrnul \ + memrchr \ + strndup \ ]) # AC_CHECK_LIB adds any library found to the variable LIBS, and links these diff --git a/dhat/tests/copy.c b/dhat/tests/copy.c index ccaf8ba901..18479d782b 100644 --- a/dhat/tests/copy.c +++ b/dhat/tests/copy.c @@ -43,10 +43,10 @@ void f(char* a, char* b, wchar_t* wa, wchar_t* wb) { memcpy (a, b, 1000); // Redirects to memmove memcpy (a, b, 1000); // Redirects to memmove memmove(a, b, 1000); -#if defined(VGO_solaris) || defined(VGO_darwin) || (defined(VGO_freebsd) && defined(__GNUC__)) - memcpy(a, b, 1000); -#else +#if defined(HAVE_MEMPCPY) mempcpy(a, b, 1000); +#else + memcpy(a, b, 1000); #endif bcopy (a, b, 1000); // Redirects to memmove strcpy (a, b); diff --git a/memcheck/tests/str_tester.c b/memcheck/tests/str_tester.c index 01354eb132..1201bbfc22 100644 --- a/memcheck/tests/str_tester.c +++ b/memcheck/tests/str_tester.c @@ -33,6 +33,7 @@ #include <string.h> #include <strings.h> #include <fcntl.h> +#include "../../config.h" #ifndef HAVE_GNU_LD #define _sys_nerr sys_nerr @@ -264,8 +265,7 @@ test_stpcpy (void) SIMPLE_COPY(stpcpy, 16, "6666666666666666", 59); } -// DDD: better done by testing for the function. -#if !defined(__APPLE__) && !defined(__FreeBSD__) +#if defined(HAVE_STPNCPY) static void test_stpncpy (void) { @@ -466,8 +466,7 @@ test_strchr (void) } } -// DDD: better done by testing for the function. -#if !defined(__APPLE__) && !defined(__FreeBSD__) +#if defined(HAVE_STRCHRNUL) static void test_strchrnul (void) { @@ -578,8 +577,7 @@ test_strrchr (void) } } -// DDD: better done by testing for the function. -#if !defined(__APPLE__) && !defined(__sun) && !defined(__FreeBSD__) +#if defined(HAVE_MEMRCHR) static void test_memrchr (void) { @@ -1071,7 +1069,7 @@ test_memcpy (void) } } -#if !defined(__APPLE__) && !defined(__sun) && !defined(__FreeBSD__) +#if defined(HAVE_MEMPCPY) static void test_mempcpy (void) { @@ -1287,7 +1285,7 @@ test_bzero (void) equal(one, "abcdef", 4); /* Zero-length copy. */ } -#if !defined(__APPLE__) && !defined(__FreeBSD__) +#if defined(HAVE_STRNDUP) static void test_strndup (void) { @@ -1422,7 +1420,7 @@ main (void) /* A closely related function is stpcpy. */ test_stpcpy (); -#if !defined(__APPLE__) && !defined(__FreeBSD__) +#if defined(HAVE_STPNCPY) /* stpncpy. */ test_stpncpy (); #endif @@ -1445,7 +1443,7 @@ main (void) /* strchr. */ test_strchr (); -# if !defined(__APPLE__) && !defined(__FreeBSD__) +# if defined(HAVE_STRCHRNUL) /* strchrnul. */ test_strchrnul (); # endif @@ -1461,7 +1459,7 @@ main (void) /* strrchr. */ test_strrchr (); -# if !defined(__APPLE__) && !defined(__sun) && !defined(__FreeBSD__) +# if defined(HAVE_MEMRCHR) /* memrchr. */ test_memrchr (); # endif @@ -1502,7 +1500,7 @@ main (void) /* memmove - must work on overlap. */ test_memmove (); -# if !defined(__APPLE__) && !defined(__sun) && !defined(__FreeBSD__) +# if defined(HAVE_MEMPCPY) /* mempcpy */ test_mempcpy (); # endif @@ -1522,7 +1520,7 @@ main (void) /* bcmp - somewhat like memcmp. */ test_bcmp (); -#if !defined(__APPLE__) && !defined(__FreeBSD__) +#if defined(HAVE_STRNDUP) /* strndup. */ test_strndup (); #endif diff --git a/shared/vg_replace_strmem.c b/shared/vg_replace_strmem.c index 5396e83be0..aab1413917 100644 --- a/shared/vg_replace_strmem.c +++ b/shared/vg_replace_strmem.c @@ -461,6 +461,10 @@ static inline void my_exit ( int x ) STRNLEN(VG_Z_LIBC_SONAME, strnlen) STRNLEN(VG_Z_LIBC_SONAME, __GI_strnlen) +#elif defined(VGO_freebsd) + + STRNLEN(VG_Z_LIBC_SONAME, srtnlen) + #elif defined(VGO_darwin) # if DARWIN_VERS == DARWIN_10_9 STRNLEN(libsystemZucZddylib, strnlen) @@ -853,6 +857,9 @@ static inline void my_exit ( int x ) STRCASECMP_L(VG_Z_LIBC_SONAME, __GI_strcasecmp_l) STRCASECMP_L(VG_Z_LIBC_SONAME, __GI___strcasecmp_l) +#elif defined(VGO_freebsd) + STRCASECMP_L(VG_Z_LIBC_SONAME, strcasecmp_l) + #elif defined(VGO_darwin) //STRCASECMP_L(VG_Z_LIBC_SONAME, strcasecmp_l) @@ -891,6 +898,9 @@ static inline void my_exit ( int x ) STRNCASECMP_L(VG_Z_LIBC_SONAME, __GI_strncasecmp_l) STRNCASECMP_L(VG_Z_LIBC_SONAME, __GI___strncasecmp_l) +#elif defined(VGO_freebsd) + STRNCASECMP_L(VG_Z_LIBC_SONAME, strncasecmp_l) + #elif defined(VGO_darwin) //STRNCASECMP_L(VG_Z_LIBC_SONAME, strncasecmp_l) //STRNCASECMP_L(VG_Z_DYLD, strncasecmp_l) @@ -972,6 +982,9 @@ static inline void my_exit ( int x ) MEMCHR(VG_Z_LIBC_SONAME, memchr) MEMCHR(VG_Z_LIBC_SONAME, __GI_memchr) +#elif defined(VGO_freebsd) + MEMCHR(VG_Z_LIBC_SONAME, memchr) + #elif defined(VGO_darwin) # if DARWIN_VERS == DARWIN_10_9 MEMCHR(VG_Z_DYLD, memchr) @@ -1673,6 +1686,8 @@ static inline void my_exit ( int x ) GLIBC25_MEMPCPY(VG_Z_LD_LINUX_SO_3, mempcpy) /* ld-linux.so.3 */ GLIBC25_MEMPCPY(VG_Z_LD_LINUX_X86_64_SO_2, mempcpy) /* ld-linux-x86-64.so.2 */ +#elif defined(VGO_freebsd) + GLIBC25_MEMPCPY(VG_Z_LIBC_SONAME, mempcpy) #elif defined(VGO_darwin) //GLIBC25_MEMPCPY(VG_Z_LIBC_SONAME, mempcpy) |
|
From: Paul F. <pa...@so...> - 2022-06-01 19:55:02
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=7289e2639cf636ee75284208c471e7b9176e97d8 commit 7289e2639cf636ee75284208c471e7b9176e97d8 Author: Paul Floyd <pj...@wa...> Date: Wed Jun 1 21:54:19 2022 +0200 Remove alignment warning from a FreeBSD regtest Diff: --- memcheck/tests/freebsd/Makefile.am | 2 ++ 1 file changed, 2 insertions(+) diff --git a/memcheck/tests/freebsd/Makefile.am b/memcheck/tests/freebsd/Makefile.am index 472f92125e..cf32e115da 100644 --- a/memcheck/tests/freebsd/Makefile.am +++ b/memcheck/tests/freebsd/Makefile.am @@ -108,3 +108,5 @@ scalar_13_plus_CFLAGS = ${AM_CFLAGS} -g endif scalar_CFLAGS = ${AM_CFLAGS} -g + +errno_aligned_allocs_CFLAGS = ${AM_CFLAGS} -Wno-non-power-of-two-alignment |