Bug 486538 - Running a program linked with mold causes the debuginfo reader to stop working
Summary: Running a program linked with mold causes the debuginfo reader to stop working
Status: RESOLVED NOT A BUG
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (other bugs)
Version First Reported In: 3.23.0
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Paul Floyd
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-05-04 04:50 UTC by limuyang202011
Modified: 2024-05-08 13:45 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description limuyang202011 2024-05-04 04:50:28 UTC
I reported this issue to mold's author,first,Then he say this maybe a valgrind issue,so I report this here.
Details in this https://github.com/rui314/mold/issues/1240
Comment 1 Paul Floyd 2024-05-04 06:42:43 UTC
Sounds like a duplicate of 

https://bugs.kde.org/show_bug.cgi?id=478837

Reopen if I'm mistaken.

*** This bug has been marked as a duplicate of bug 478837 ***
Comment 2 limuyang202011 2024-05-04 11:35:18 UTC
the example in github issue can reproduce this issue, too.Maybe you weren't fix this issue all.(In reply to Paul Floyd from comment #1)
Comment 3 Paul Floyd 2024-05-04 12:03:56 UTC
(In reply to limuyang202011 from comment #2)
> the example in github issue can reproduce this issue, too.Maybe you weren't
> fix this issue all.(In reply to Paul Floyd from comment #1)

I'm not able to reproduce this on FreeBSD.

Please can you do the following:
1. run objdump -p on your exacutable and post the PT_LOAD segments, which should look something like

    LOAD off    0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**12
         filesz 0x0000000000016580 memsz 0x0000000000016580 flags r--
    LOAD off    0x0000000000016580 vaddr 0x0000000000017580 paddr 0x0000000000017580 align 2**12
         filesz 0x000000000004092c memsz 0x000000000004092c flags r-x
    LOAD off    0x0000000000056eb0 vaddr 0x0000000000058eb0 paddr 0x0000000000058eb0 align 2**12
         filesz 0x0000000000002ef8 memsz 0x0000000000003150 flags rw-
    LOAD off    0x0000000000059da8 vaddr 0x000000000005cda8 paddr 0x000000000005cda8 align 2**12
         filesz 0x0000000000000080 memsz 0x0000000000000160 flags rw-

2. Run objdump -h on your exe and pipe it through a grep for rodata
e.g.

objdump -h  target/debug/rust_real_test | grep rodata
 14 .rodata            00005dd4 0000000000010410 DATA
 16 .rodata.str1.1     00000001 0000000000016206 DATA
 17 .rodata.cst4       0000004c 0000000000016208 DATA
 18 .rodata.cst8       00000040 0000000000016258 DATA
 19 .rodata.cst16      00000260 00000000000162a0 DATA
 20 .rodata.cst32      00000080 0000000000016500 DATA


3. run Valgrind -d -d -d on your exe. The output will be very long. I'm only interested in the but releated to reading your exe's elf segments which should look like this

--6368-- di_notify_mmap-0:
--6368-- di_notify_mmap-1: 0x108000-0x11efff r--
--6368-- di_notify_mmap-2: /usr/home/paulf/scratch/vg_examples/bug486538/target/debug/rust_real_test
--6368-- di_notify_mmap-3: is_rx_map 0, is_rw_map 0, is_ro_map 1
--6368-- check_elf_and_get_rw_loads: ++*rw_load_count to 1 for /usr/home/paulf/scratch/vg_examples/bug486538/target/debug/rust_real_test p_vaddr 0x58eb0 p_offset 356016, p_filesz 12024
--6368-- check_elf_and_get_rw_loads: ++*rw_load_count to 2 for /usr/home/paulf/scratch/vg_examples/bug486538/target/debug/rust_real_test p_vaddr 0x5cda8 p_offset 368040, p_filesz 128
--6368-- di_notify_mmap-4: noting details in DebugInfo* at 0x100287C220
--6368-- di_notify_mmap-6: no dinfo loaded /usr/home/paulf/scratch/vg_examples/bug486538/target/debug/rust_real_test (no rx or no rw mapping)
--6368-- di_notify_mmap-0:
--6368-- di_notify_mmap-1: 0x11f000-0x15ffff r-x
--6368-- di_notify_mmap-2: /usr/home/paulf/scratch/vg_examples/bug486538/target/debug/rust_real_test
--6368-- di_notify_mmap-3: is_rx_map 1, is_rw_map 0, is_ro_map 0
--6368-- check_elf_and_get_rw_loads: ++*rw_load_count to 1 for /usr/home/paulf/scratch/vg_examples/bug486538/target/debug/rust_real_test p_vaddr 0x58eb0 p_offset 356016, p_filesz 12024
--6368-- check_elf_and_get_rw_loads: ++*rw_load_count to 2 for /usr/home/paulf/scratch/vg_examples/bug486538/target/debug/rust_real_test p_vaddr 0x5cda8 p_offset 368040, p_filesz 128
--6368-- di_notify_mmap-4: noting details in DebugInfo* at 0x100287C220
--6368-- di_notify_mmap-6: no dinfo loaded /usr/home/paulf/scratch/vg_examples/bug486538/target/debug/rust_real_test (no rx or no rw mapping)
--6368-- di_notify_mmap-0:
--6368-- di_notify_mmap-1: 0x160000-0x163fff rw-
--6368-- di_notify_mmap-2: /usr/home/paulf/scratch/vg_examples/bug486538/target/debug/rust_real_test
--6368-- di_notify_mmap-3: is_rx_map 0, is_rw_map 1, is_ro_map 0
--6368-- check_elf_and_get_rw_loads: ++*rw_load_count to 1 for /usr/home/paulf/scratch/vg_examples/bug486538/target/debug/rust_real_test p_vaddr 0x58eb0 p_offset 356016, p_filesz 12024
--6368-- check_elf_and_get_rw_loads: ++*rw_load_count to 2 for /usr/home/paulf/scratch/vg_examples/bug486538/target/debug/rust_real_test p_vaddr 0x5cda8 p_offset 368040, p_filesz 128
--6368-- di_notify_mmap-4: noting details in DebugInfo* at 0x100287C220
--6368-- di_notify_mmap-6: no dinfo loaded /usr/home/paulf/scratch/vg_examples/bug486538/target/debug/rust_real_test (no rx or no rw mapping)
--6368-- di_notify_mmap-0:
--6368-- di_notify_mmap-1: 0x164000-0x164fff rw-
--6368-- di_notify_mmap-2: /usr/home/paulf/scratch/vg_examples/bug486538/target/debug/rust_real_test
--6368-- di_notify_mmap-3: is_rx_map 0, is_rw_map 1, is_ro_map 0
--6368-- check_elf_and_get_rw_loads: ++*rw_load_count to 1 for /usr/home/paulf/scratch/vg_examples/bug486538/target/debug/rust_real_test p_vaddr 0x58eb0 p_offset 356016, p_filesz 12024
--6368-- check_elf_and_get_rw_loads: ++*rw_load_count to 2 for /usr/home/paulf/scratch/vg_examples/bug486538/target/debug/rust_real_test p_vaddr 0x5cda8 p_offset 368040, p_filesz 128
--6368-- di_notify_mmap-4: noting details in DebugInfo* at 0x100287C220

4. Post the output of valgrind --version
Comment 4 limuyang202011 2024-05-04 12:13:50 UTC
1.Program Header:
    PHDR off    0x0000000000000040 vaddr 0x0000000000000040 paddr 0x0000000000000040 align 2**3
         filesz 0x00000000000002a0 memsz 0x00000000000002a0 flags r--
  INTERP off    0x00000000000002e0 vaddr 0x00000000000002e0 paddr 0x00000000000002e0 align 2**0
         filesz 0x000000000000001c memsz 0x000000000000001c flags r--
    NOTE off    0x0000000000000300 vaddr 0x0000000000000300 paddr 0x0000000000000300 align 2**3
         filesz 0x0000000000000064 memsz 0x0000000000000064 flags r--
    LOAD off    0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**12
         filesz 0x00000000004942b0 memsz 0x00000000004942b0 flags r--
    LOAD off    0x00000000004942b0 vaddr 0x00000000004952b0 paddr 0x00000000004952b0 align 2**12
         filesz 0x0000000000702632 memsz 0x0000000000702632 flags r-x
    LOAD off    0x0000000000b968e8 vaddr 0x0000000000b988e8 paddr 0x0000000000b988e8 align 2**12
         filesz 0x00000000000be378 memsz 0x00000000000be718 flags rw-
    LOAD off    0x0000000000c54c80 vaddr 0x0000000000c57c80 paddr 0x0000000000c57c80 align 2**12
         filesz 0x00000000000023a0 memsz 0x00000000000024a0 flags rw-
     TLS off    0x0000000000b968e8 vaddr 0x0000000000b988e8 paddr 0x0000000000b988e8 align 2**3
         filesz 0x0000000000000070 memsz 0x00000000000000f1 flags r--
 DYNAMIC off    0x0000000000c13e40 vaddr 0x0000000000c15e40 paddr 0x0000000000c15e40 align 2**3
         filesz 0x0000000000000220 memsz 0x0000000000000220 flags rw-
EH_FRAME off    0x000000000026090c vaddr 0x000000000026090c paddr 0x000000000026090c align 2**2
         filesz 0x000000000003d6f4 memsz 0x000000000003d6f4 flags r--
   STACK off    0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**0
         filesz 0x0000000000000000 memsz 0x0000000000000000 flags rw-
   RELRO off    0x0000000000b968e8 vaddr 0x0000000000b988e8 paddr 0x0000000000b988e8 align 2**0
         filesz 0x00000000000be378 memsz 0x00000000000be718 flags r--
2. 14 .rodata       001f1494  00000000002a2210  00000000002a2210  002a2210  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 15 .rodata.cst4  00000358  00000000004936a4  00000000004936a4  004936a4  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 16 .rodata.cst8  00000220  0000000000493a00  0000000000493a00  00493a00  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 17 .rodata.cst16 000004d0  0000000000493c20  0000000000493c20  00493c20  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 18 .rodata.cst32 000001c0  00000000004940f0  00000000004940f0  004940f0  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
3.--36489-- di_notify_mmap-0:
--36489-- di_notify_mmap-1: 0x108000-0x59cfff r--
--36489-- di_notify_mmap-2: /home/limuy/trc/target/debug/deps/libcore-6c7cd5e5f365782e
--36489-- di_notify_mmap-3: is_rx_map 0, is_rw_map 0, is_ro_map 1
--36489-- di_notify_mmap-4: noting details in DebugInfo* at 0x100287C4D0
--36489-- di_notify_mmap-6: no dinfo loaded /home/limuy/trc/target/debug/deps/libcore-6c7cd5e5f365782e (no rx or no rw mapping)
--36489-- di_notify_mmap-0:
--36489-- di_notify_mmap-1: 0x59d000-0xc9ffff r-x
--36489-- di_notify_mmap-2: /home/limuy/trc/target/debug/deps/libcore-6c7cd5e5f365782e
--36489-- di_notify_mmap-3: is_rx_map 1, is_rw_map 0, is_ro_map 0
--36489-- di_notify_mmap-4: noting details in DebugInfo* at 0x100287C4D0
--36489-- di_notify_mmap-6: no dinfo loaded /home/limuy/trc/target/debug/deps/libcore-6c7cd5e5f365782e (no rx or no rw mapping)
--36489-- di_notify_mmap-0:
--36489-- di_notify_mmap-1: 0xca0000-0xd5efff rw-
--36489-- di_notify_mmap-2: /home/limuy/trc/target/debug/deps/libcore-6c7cd5e5f365782e
--36489-- di_notify_mmap-3: is_rx_map 0, is_rw_map 1, is_ro_map 0
--36489-- di_notify_mmap-4: noting details in DebugInfo* at 0x100287C4D0
--36489-- di_notify_mmap-6: no dinfo loaded /home/limuy/trc/target/debug/deps/libcore-6c7cd5e5f365782e (no rx or no rw mapping)
--36489-- di_notify_mmap-0:
--36489-- di_notify_mmap-1: 0xd5f000-0xd62fff rw-
--36489-- di_notify_mmap-2: /home/limuy/trc/target/debug/deps/libcore-6c7cd5e5f365782e
--36489-- di_notify_mmap-3: is_rx_map 0, is_rw_map 1, is_ro_map 0
--36489-- di_notify_mmap-4: noting details in DebugInfo* at 0x100287C4D0
--36489-- di_notify_mmap-5: achieved accept state for /home/limuy/trc/target/debug/deps/libcore-6c7cd5e5f365782e
--36489-- di_notify_mmap-0:
--36489-- di_notify_mmap-1: 0x4000000-0x4000fff r--
--36489-- di_notify_mmap-2: /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
--36489-- di_notify_mmap-3: is_rx_map 0, is_rw_map 0, is_ro_map 1
--36489-- di_notify_mmap-4: noting details in DebugInfo* at 0x1002C7BB80
--36489-- di_notify_mmap-6: no dinfo loaded /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 (no rx or no rw mapping)
--36489-- di_notify_mmap-0:
--36489-- di_notify_mmap-1: 0x4001000-0x4025fff r-x
--36489-- di_notify_mmap-2: /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
--36489-- di_notify_mmap-3: is_rx_map 1, is_rw_map 0, is_ro_map 0
--36489-- di_notify_mmap-4: noting details in DebugInfo* at 0x1002C7BB80
--36489-- di_notify_mmap-6: no dinfo loaded /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 (no rx or no rw mapping)
--36489-- di_notify_mmap-0:
--36489-- di_notify_mmap-1: 0x4026000-0x402ffff r--
--36489-- di_notify_mmap-2: /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
--36489-- di_notify_mmap-3: is_rx_map 0, is_rw_map 0, is_ro_map 1
--36489-- di_notify_mmap-4: noting details in DebugInfo* at 0x1002C7BB80
--36489-- di_notify_mmap-6: no dinfo loaded /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 (no rx or no rw mapping)
--36489-- di_notify_mmap-0:
--36489-- di_notify_mmap-1: 0x4030000-0x4033fff rw-
--36489-- di_notify_mmap-2: /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
--36489-- di_notify_mmap-3: is_rx_map 0, is_rw_map 1, is_ro_map 0
--36489-- di_notify_mmap-4: noting details in DebugInfo* at 0x1002C7BB80
--36489-- di_notify_mmap-5: achieved accept state for /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
--36489-- di_notify_mmap-0:
--36489-- di_notify_mmap-1: 0x58000000-0x58000fff r--
--36489-- di_notify_mmap-2: /home/limuy/valgrind/build/libexec/valgrind/memcheck-amd64-linux
--36489-- di_notify_mmap-3: is_rx_map 0, is_rw_map 0, is_ro_map 1
--36489-- di_notify_mmap-4: noting details in DebugInfo* at 0x1002B506B0
--36489-- di_notify_mmap-6: no dinfo loaded /home/limuy/valgrind/build/libexec/valgrind/memcheck-amd64-linux (no rx or no rw mapping)
--36489-- di_notify_mmap-0:
--36489-- di_notify_mmap-1: 0x58001000-0x581d9fff r-x
--36489-- di_notify_mmap-2: /home/limuy/valgrind/build/libexec/valgrind/memcheck-amd64-linux
--36489-- di_notify_mmap-3: is_rx_map 1, is_rw_map 0, is_ro_map 0
--36489-- di_notify_mmap-4: noting details in DebugInfo* at 0x1002B506B0
--36489-- di_notify_mmap-6: no dinfo loaded /home/limuy/valgrind/build/libexec/valgrind/memcheck-amd64-linux (no rx or no rw mapping)
--36489-- di_notify_mmap-0:
--36489-- di_notify_mmap-1: 0x581da000-0x58282fff r--
--36489-- di_notify_mmap-2: /home/limuy/valgrind/build/libexec/valgrind/memcheck-amd64-linux
--36489-- di_notify_mmap-3: is_rx_map 0, is_rw_map 0, is_ro_map 1
--36489-- di_notify_mmap-4: noting details in DebugInfo* at 0x1002B506B0
--36489-- di_notify_mmap-6: no dinfo loaded /home/limuy/valgrind/build/libexec/valgrind/memcheck-amd64-linux (no rx or no rw mapping)
--36489-- di_notify_mmap-0:
--36489-- di_notify_mmap-1: 0x58283000-0x58288fff rw-
--36489-- di_notify_mmap-2: /home/limuy/valgrind/build/libexec/valgrind/memcheck-amd64-linux
--36489-- di_notify_mmap-3: is_rx_map 0, is_rw_map 1, is_ro_map 0
--36489-- di_notify_mmap-4: noting details in DebugInfo* at 0x1002B506B0
--36489-- di_notify_mmap-5: achieved accept state for /home/limuy/valgrind/build/libexec/valgrind/memcheck-amd64-linux
--36489-- di_notify_mmap-0:
--36489-- di_notify_mmap-1: 0x4834000-0x4835fff rw-
--36489-- di_notify_mmap-0:
--36489-- di_notify_mmap-1: 0x4836000-0x483afff r--
--36489-- di_notify_mmap-2: /home/limuy/valgrind/build/libexec/valgrind/vgpreload_core-amd64-linux.so
--36489-- di_notify_mmap-3: is_rx_map 0, is_rw_map 0, is_ro_map 1
--36489-- di_notify_mmap-4: noting details in DebugInfo* at 0x100319BA90
--36489-- di_notify_mmap-6: no dinfo loaded /home/limuy/valgrind/build/libexec/valgrind/vgpreload_core-amd64-linux.so (no rx or no rw mapping)
--36489-- di_notify_mmap-0:
--36489-- di_notify_mmap-1: 0x4837000-0x4837fff r-x
--36489-- di_notify_mmap-2: /home/limuy/valgrind/build/libexec/valgrind/vgpreload_core-amd64-linux.so
--36489-- di_notify_mmap-3: is_rx_map 1, is_rw_map 0, is_ro_map 0
--36489-- di_notify_mmap-4: noting details in DebugInfo* at 0x100319BA90
--36489-- di_notify_mmap-6: no dinfo loaded /home/limuy/valgrind/build/libexec/valgrind/vgpreload_core-amd64-linux.so (no rx or no rw mapping)
--36489-- di_notify_mmap-0:
--36489-- di_notify_mmap-1: 0x4838000-0x483afff r--
--36489-- di_notify_mmap-2: /home/limuy/valgrind/build/libexec/valgrind/vgpreload_core-amd64-linux.so
--36489-- di_notify_mmap-3: is_rx_map 0, is_rw_map 0, is_ro_map 1
--36489-- di_notify_mmap-4: noting details in DebugInfo* at 0x100319BA90
--36489-- di_notify_mmap-6: no dinfo loaded /home/limuy/valgrind/build/libexec/valgrind/vgpreload_core-amd64-linux.so (no rx or no rw mapping)
--36489-- di_notify_mmap-0:
--36489-- di_notify_mmap-1: 0x4839000-0x483afff rw-
--36489-- di_notify_mmap-2: /home/limuy/valgrind/build/libexec/valgrind/vgpreload_core-amd64-linux.so
--36489-- di_notify_mmap-3: is_rx_map 0, is_rw_map 1, is_ro_map 0
--36489-- di_notify_mmap-4: noting details in DebugInfo* at 0x100319BA90
--36489-- di_notify_mmap-5: achieved accept state for /home/limuy/valgrind/build/libexec/valgrind/vgpreload_core-amd64-linux.so
--36489-- di_notify_mmap-0:
--36489-- di_notify_mmap-1: 0x483b000-0x4855fff r--
--36489-- di_notify_mmap-2: /home/limuy/valgrind/build/libexec/valgrind/vgpreload_memcheck-amd64-linux.so
--36489-- di_notify_mmap-3: is_rx_map 0, is_rw_map 0, is_ro_map 1
--36489-- di_notify_mmap-4: noting details in DebugInfo* at 0x1003483D50
--36489-- di_notify_mmap-6: no dinfo loaded /home/limuy/valgrind/build/libexec/valgrind/vgpreload_memcheck-amd64-linux.so (no rx or no rw mapping)
--36489-- di_notify_mmap-0:
--36489-- di_notify_mmap-1: 0x4840000-0x484ffff r-x
--36489-- di_notify_mmap-2: /home/limuy/valgrind/build/libexec/valgrind/vgpreload_memcheck-amd64-linux.so
--36489-- di_notify_mmap-3: is_rx_map 1, is_rw_map 0, is_ro_map 0
--36489-- di_notify_mmap-4: noting details in DebugInfo* at 0x1003483D50
--36489-- di_notify_mmap-6: no dinfo loaded /home/limuy/valgrind/build/libexec/valgrind/vgpreload_memcheck-amd64-linux.so (no rx or no rw mapping)
--36489-- di_notify_mmap-0:
--36489-- di_notify_mmap-1: 0x4850000-0x4855fff r--
--36489-- di_notify_mmap-2: /home/limuy/valgrind/build/libexec/valgrind/vgpreload_memcheck-amd64-linux.so
--36489-- di_notify_mmap-3: is_rx_map 0, is_rw_map 0, is_ro_map 1
--36489-- di_notify_mmap-4: noting details in DebugInfo* at 0x1003483D50
--36489-- di_notify_mmap-6: no dinfo loaded /home/limuy/valgrind/build/libexec/valgrind/vgpreload_memcheck-amd64-linux.so (no rx or no rw mapping)
--36489-- di_notify_mmap-0:
--36489-- di_notify_mmap-1: 0x4854000-0x4855fff rw-
--36489-- di_notify_mmap-2: /home/limuy/valgrind/build/libexec/valgrind/vgpreload_memcheck-amd64-linux.so
--36489-- di_notify_mmap-3: is_rx_map 0, is_rw_map 1, is_ro_map 0
--36489-- di_notify_mmap-4: noting details in DebugInfo* at 0x1003483D50
--36489-- di_notify_mmap-5: achieved accept state for /home/limuy/valgrind/build/libexec/valgrind/vgpreload_memcheck-amd64-linux.so
--36489-- di_notify_mmap-0:
--36489-- di_notify_mmap-1: 0x4856000-0x4860fff r--
--36489-- di_notify_mmap-2: /etc/ld.so.cache
--36489-- di_notify_mmap-3: is_rx_map 0, is_rw_map 0, is_ro_map 1
--36489-- di_notify_mmap-0:
--36489-- di_notify_mmap-1: 0x4861000-0x488dfff r--
--36489-- di_notify_mmap-2: /usr/lib/x86_64-linux-gnu/libgcc_s.so.1
--36489-- di_notify_mmap-3: is_rx_map 0, is_rw_map 0, is_ro_map 1
--36489-- di_notify_mmap-4: noting details in DebugInfo* at 0x1002C82D30
--36489-- di_notify_mmap-6: no dinfo loaded /usr/lib/x86_64-linux-gnu/libgcc_s.so.1 (no rx or no rw mapping)
--36489-- di_notify_mmap-0:
--36489-- di_notify_mmap-1: 0x4865000-0x4887fff r-x
--36489-- di_notify_mmap-2: /usr/lib/x86_64-linux-gnu/libgcc_s.so.1
--36489-- di_notify_mmap-3: is_rx_map 1, is_rw_map 0, is_ro_map 0
--36489-- di_notify_mmap-4: noting details in DebugInfo* at 0x1002C82D30
--36489-- di_notify_mmap-6: no dinfo loaded /usr/lib/x86_64-linux-gnu/libgcc_s.so.1 (no rx or no rw mapping)
--36489-- di_notify_mmap-0:
--36489-- di_notify_mmap-1: 0x4888000-0x488dfff r--
--36489-- di_notify_mmap-2: /usr/lib/x86_64-linux-gnu/libgcc_s.so.1
--36489-- di_notify_mmap-3: is_rx_map 0, is_rw_map 0, is_ro_map 1
--36489-- di_notify_mmap-4: noting details in DebugInfo* at 0x1002C82D30
--36489-- di_notify_mmap-6: no dinfo loaded /usr/lib/x86_64-linux-gnu/libgcc_s.so.1 (no rx or no rw mapping)
--36489-- di_notify_mmap-0:
--36489-- di_notify_mmap-1: 0x488c000-0x488dfff rw-
--36489-- di_notify_mmap-2: /usr/lib/x86_64-linux-gnu/libgcc_s.so.1
--36489-- di_notify_mmap-3: is_rx_map 0, is_rw_map 1, is_ro_map 0
--36489-- di_notify_mmap-4: noting details in DebugInfo* at 0x1002C82D30
--36489-- di_notify_mmap-5: achieved accept state for /usr/lib/x86_64-linux-gnu/libgcc_s.so.1
--36489-- di_notify_mmap-0:
--36489-- di_notify_mmap-1: 0x488e000-0x496cfff r--
--36489-- di_notify_mmap-2: /usr/lib/x86_64-linux-gnu/libm.so.6
--36489-- di_notify_mmap-3: is_rx_map 0, is_rw_map 0, is_ro_map 1
--36489-- di_notify_mmap-4: noting details in DebugInfo* at 0x1002C83500
--36489-- di_notify_mmap-6: no dinfo loaded /usr/lib/x86_64-linux-gnu/libm.so.6 (no rx or no rw mapping)
--36489-- di_notify_mmap-0:
--36489-- di_notify_mmap-1: 0x489e000-0x4910fff r-x
--36489-- di_notify_mmap-2: /usr/lib/x86_64-linux-gnu/libm.so.6
--36489-- di_notify_mmap-3: is_rx_map 1, is_rw_map 0, is_ro_map 0
--36489-- di_notify_mmap-4: noting details in DebugInfo* at 0x1002C83500
--36489-- di_notify_mmap-6: no dinfo loaded /usr/lib/x86_64-linux-gnu/libm.so.6 (no rx or no rw mapping)
--36489-- di_notify_mmap-0:
--36489-- di_notify_mmap-1: 0x4911000-0x496cfff r--
--36489-- di_notify_mmap-2: /usr/lib/x86_64-linux-gnu/libm.so.6
--36489-- di_notify_mmap-3: is_rx_map 0, is_rw_map 0, is_ro_map 1
--36489-- di_notify_mmap-4: noting details in DebugInfo* at 0x1002C83500
--36489-- di_notify_mmap-6: no dinfo loaded /usr/lib/x86_64-linux-gnu/libm.so.6 (no rx or no rw mapping)
--36489-- di_notify_mmap-0:
--36489-- di_notify_mmap-1: 0x496b000-0x496cfff rw-
--36489-- di_notify_mmap-2: /usr/lib/x86_64-linux-gnu/libm.so.6
--36489-- di_notify_mmap-3: is_rx_map 0, is_rw_map 1, is_ro_map 0
--36489-- di_notify_mmap-4: noting details in DebugInfo* at 0x1002C83500
--36489-- di_notify_mmap-5: achieved accept state for /usr/lib/x86_64-linux-gnu/libm.so.6
--36489-- di_notify_mmap-0:
--36489-- di_notify_mmap-1: 0x496d000-0x4b4efff r--
--36489-- di_notify_mmap-2: /usr/lib/x86_64-linux-gnu/libc.so.6
--36489-- di_notify_mmap-3: is_rx_map 0, is_rw_map 0, is_ro_map 1
--36489-- di_notify_mmap-4: noting details in DebugInfo* at 0x1002D4C440
--36489-- di_notify_mmap-6: no dinfo loaded /usr/lib/x86_64-linux-gnu/libc.so.6 (no rx or no rw mapping)
--36489-- di_notify_mmap-0:
--36489-- di_notify_mmap-1: 0x4993000-0x4ae7fff r-x
--36489-- di_notify_mmap-2: /usr/lib/x86_64-linux-gnu/libc.so.6
--36489-- di_notify_mmap-3: is_rx_map 1, is_rw_map 0, is_ro_map 0
--36489-- di_notify_mmap-4: noting details in DebugInfo* at 0x1002D4C440
--36489-- di_notify_mmap-6: no dinfo loaded /usr/lib/x86_64-linux-gnu/libc.so.6 (no rx or no rw mapping)
--36489-- di_notify_mmap-0:
--36489-- di_notify_mmap-1: 0x4ae8000-0x4b4efff r--
--36489-- di_notify_mmap-2: /usr/lib/x86_64-linux-gnu/libc.so.6
--36489-- di_notify_mmap-3: is_rx_map 0, is_rw_map 0, is_ro_map 1
--36489-- di_notify_mmap-4: noting details in DebugInfo* at 0x1002D4C440
--36489-- di_notify_mmap-6: no dinfo loaded /usr/lib/x86_64-linux-gnu/libc.so.6 (no rx or no rw mapping)
--36489-- di_notify_mmap-0:
--36489-- di_notify_mmap-1: 0x4b3c000-0x4b41fff rw-
--36489-- di_notify_mmap-2: /usr/lib/x86_64-linux-gnu/libc.so.6
--36489-- di_notify_mmap-3: is_rx_map 0, is_rw_map 1, is_ro_map 0
--36489-- di_notify_mmap-4: noting details in DebugInfo* at 0x1002D4C440
--36489-- di_notify_mmap-5: achieved accept state for /usr/lib/x86_64-linux-gnu/libc.so.6
--36489-- di_notify_mmap-0:
--36489-- di_notify_mmap-1: 0x4b42000-0x4b4efff rw-
--36489-- di_notify_mmap-0:
--36489-- di_notify_mmap-1: 0x4b42000-0x4b50fff rw-
4.valgrind --version
valgrind-3.23.0
Comment 5 Paul Floyd 2024-05-07 20:07:43 UTC
I can't see a problem in your logs.

But looking at the code things do look wrong.

For example, when loading 
/usr/home/paulf/scratch/valgrind/memcheck/vgpreload_memcheck-amd64-freebsd.so

The PT_LOADs are
    LOAD off    0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**12
         filesz 0x0000000000005fc4 memsz 0x0000000000005fc4 flags r--
    LOAD off    0x0000000000005fd0 vaddr 0x0000000000006fd0 paddr 0x0000000000006fd0 align 2**12
         filesz 0x000000000000cfd0 memsz 0x000000000000cfd0 flags r-x
    LOAD off    0x0000000000012fa0 vaddr 0x0000000000014fa0 paddr 0x0000000000014fa0 align 2**12
         filesz 0x0000000000000190 memsz 0x0000000000000190 flags rw-
    LOAD off    0x0000000000013130 vaddr 0x0000000000016130 paddr 0x0000000000016130 align 2**12
         filesz 0x0000000000000058 memsz 0x00000000000000e8 flags rw-

And some debug traces with // comments
(these values come from the client mmap)
DEBUG: vgPlain_di_notify_mmap start 0x4846000 end 0x484BFFF size 6000 offset 0             // RO
DEBUG: vgPlain_di_notify_mmap start 0x484C000 end 0x4859FFF size e000 offset 5000      // RX
DEBUG: vgPlain_di_notify_mmap start 0x485A000 end 0x485BFFF size 2000 offset 12000   // RW1
DEBUG: vgPlain_di_notify_mmap start 0x485C000 end 0x485CFFF size 1000 offset 13000   // RW2

My reading of that is that the mmap offset is the ELF offset page rounded down.
The mmap size is harder to follow. The first RO one is page rounded up. The second RX and third RW1 look like they are page rounded up plus one page (because of the overlap?). The last RW2 looks just page rounded up.

ML_(read_elf_object) uses 

                  Bool offset_checks = a_phdr.p_offset >= map->foff
                                                     && a_phdr.p_offset <  map->foff + map->size
                                                    && a_phdr.p_offset + a_phdr.p_filesz <= map->foff + map->size;

That's mixing mmap and ELF values. RW1 gets added twice because 0x13130 is within both offset 0x12000 size 0x2000 and offset 0x13000 size 0x1000.
Comment 6 Paul Floyd 2024-05-08 13:31:18 UTC
After debugging this again I've come to the conclusion that the code is a mess but probably correct.

I've reproduced a DIFFERENT error from the GH report

[paulf@archlinux bug]$ ~/valgrind/vg-in-place ./wrong_exe 
==23366== Memcheck, a memory error detector
==23366== Copyright (C) 2002-2024, and GNU GPL'd, by Julian Seward et al.
==23366== Using Valgrind-3.24.0.GIT and LibVEX; rerun with -h for copyright info
==23366== Command: ./wrong_exe
==23366== 
==23366== Valgrind: debuginfo reader: ensure_valid failed:
==23366== Valgrind:   during call to ML_(img_strdup)
==23366== Valgrind:   request for range [36949181, +1) exceeds
==23366== Valgrind:   valid image size of 36802224 for image:
==23366== Valgrind:   "/home/paulf/bug/wrong_exe"
Comment 7 Paul Floyd 2024-05-08 13:45:16 UTC
dwarfdump -ka also gives me

*** DWARF CHECK: .debug_ranges: Address outside a valid .text range ***