Bug 434849 - The vdso is not available when running on ppc64*
Summary: The vdso is not available when running on ppc64*
Status: RESOLVED DUPLICATE of bug 446123
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-03-23 19:42 UTC by Tulio Magno Quites Machado Filho
Modified: 2021-11-29 15:33 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tulio Magno Quites Machado Filho 2021-03-23 19:42:38 UTC
When running valgrind on ppc64le, the value of AT_SYSINFO_EHDR is hidden from the application.  That is the address where the vDSO has been stored by Linux.

A way to reproduce it is to request the loader (ld.so) to print the auxiliary vector: LD_SHOW_AUXV=1 ./valgrind /bin/true

This is going to print the auxv 2 times:
1. When ld.so runs valgrind;
2. When /bin/true is executed under valgrind.

Notice the absence of AT_SYSINFO_EHDR in the second execution:

AT_DCACHEBSIZE:       0x80
AT_ICACHEBSIZE:       0x80
AT_UCACHEBSIZE:       0x0
AT_SYSINFO_EHDR:      0x7fff9f640000
AT_L1I_CACHESIZE:     32768
AT_L1I_CACHEGEOMETRY: 128B line size, Unknown associativity
AT_L1D_CACHESIZE:     32768
AT_L1D_CACHEGEOMETRY: 128B line size, Unknown associativity
AT_L2_CACHESIZE:      0
AT_L2_CACHEGEOMETRY:  Unknown line size, Unknown associativity
AT_L3_CACHESIZE:      0
AT_L3_CACHEGEOMETRY:  Unknown line size, Unknown associativity
AT_HWCAP:             true_le archpmu vsx arch_2_06 dfp ic_snoop smt mmu fpu altivec ppc64 ppc32
AT_PAGESZ:            65536
AT_CLKTCK:            100
AT_PHDR:              0x10000040
AT_PHENT:             56
AT_PHNUM:             9
AT_BASE:              0x7fff9f660000
AT_FLAGS:             0x0
AT_ENTRY:             0x10001508
AT_UID:               1000
AT_EUID:              1000
AT_GID:               100
AT_EGID:              100
AT_SECURE:            0
AT_RANDOM:            0x7fffed9aa3b2
AT_HWCAP2:            scv darn ieee128 arch_3_00 vcrypto tar isel ebb dscr arch_2_07
AT_EXECFN:            ./valgrind
AT_PLATFORM:          power9
AT_BASE_PLATFORM:     power9
==19155== Memcheck, a memory error detector
==19155== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==19155== Using Valgrind-3.18.0.GIT and LibVEX; rerun with -h for copyright info
==19155== Command: /bin/true
==19155== 
AT_DCACHEBSIZE:       0x80
AT_ICACHEBSIZE:       0x80
AT_UCACHEBSIZE:       0x0
AT_HWCAP:             true_le archpmu vsx arch_2_06 dfp ic_snoop smt mmu fpu altivec ppc64 ppc32
AT_PAGESZ:            65536
AT_CLKTCK:            100
AT_PHDR:              0x180040
AT_PHENT:             56
AT_PHNUM:             9
AT_BASE:              0x4000000
AT_FLAGS:             0x0
AT_ENTRY:             0x181c44
AT_UID:               1000
AT_EUID:              1000
AT_GID:               100
AT_EGID:              100
AT_SECURE:            0
AT_RANDOM:            0x1fff00ffd7
AT_HWCAP2:            ieee128 arch_3_00 tar isel ebb dscr arch_2_07
AT_EXECFN:            /bin/true
AT_PLATFORM:          power9
AT_BASE_PLATFORM:     power9
==19155== 
==19155== HEAP SUMMARY:
==19155==     in use at exit: 0 bytes in 0 blocks
==19155==   total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==19155== 
==19155== All heap blocks were freed -- no leaks are possible
==19155== 
==19155== For lists of detected and suppressed errors, rerun with: -s
==19155== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Comment 1 Carl Love 2021-03-25 19:39:07 UTC
The issue does not appear to be just on the PPC platform.  I tried the same test on my Intel laptop running a REL release

more /etc/redhat-release
Red Hat Enterprise Linux release 8.3 (Ootpa)

 and see the same issue

 LD_SHOW_AUXV=1 valgrind /bin/true
AT_SYSINFO_EHDR: 0x7ffc587c4000
AT_HWCAP:        bfebfbff
AT_PAGESZ:       4096
AT_CLKTCK:       100
AT_PHDR:         0x559a635f1040
AT_PHENT:        56
AT_PHNUM:        11
AT_BASE:         0x7f5ced33d000
AT_FLAGS:        0x0
AT_ENTRY:        0x559a635f2580
AT_UID:          1000
AT_EUID:         1000
AT_GID:          1000
AT_EGID:         1000
AT_SECURE:       0
AT_RANDOM:       0x7ffc5864ab99
AT_HWCAP2:       0x0
AT_EXECFN:       /usr/bin/valgrind
AT_PLATFORM:     x86_64
==39447== Memcheck, a memory error detector
==39447== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==39447== Using Valgrind-3.16.0 and LibVEX; rerun with -h for copyright info
==39447== Command: /bin/true
==39447== 
AT_HWCAP:        bfebfbff
AT_PAGESZ:       4096
AT_CLKTCK:       100
AT_PHDR:         0x108040
AT_PHENT:        56
AT_PHNUM:        10
AT_BASE:         0x4000000
AT_FLAGS:        0x0
AT_ENTRY:        0x109740
AT_UID:          1000
AT_EUID:         1000
AT_GID:          1000
AT_EGID:         1000
AT_SECURE:       0
AT_RANDOM:       0x1fff000fdc
AT_EXECFN:       /bin/true
AT_PLATFORM:     x86_64
==39447== 
==39447== HEAP SUMMARY:
==39447==     in use at exit: 0 bytes in 0 blocks
==39447==   total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==39447== 
==39447== All heap blocks were freed -- no leaks are possible
==39447== 
==39447== For lists of detected and suppressed errors, rerun with: -s
==39447== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Comment 2 Mark Wielaard 2021-03-25 21:02:08 UTC
This is done deliberately, see coregrind/m_initimg/initimg-linux.c (setup_client_stack):

         case AT_SYSINFO_EHDR: { 
            /* Trash this, because we don't reproduce it */ 
            const NSegment* ehdrseg = VG_(am_find_nsegment)((Addr)auxv->u.a_ptr); 
            vg_assert(ehdrseg); 
            VG_(am_munmap_valgrind)(ehdrseg->start, ehdrseg->end - ehdrseg->start); 
            auxv->a_type = AT_IGNORE; 
            break; 
         } 

So the application should use actual syscalls instead of using that magic vdso page when running under valgrind.

Is there a reason you need AT_SYSINFO_EHDR?
Comment 3 Pedro Franco de Carvalho 2021-03-25 21:41:14 UTC
(In reply to Mark Wielaard from comment #2)
> This is done deliberately, see coregrind/m_initimg/initimg-linux.c
> (setup_client_stack):
> 
>          case AT_SYSINFO_EHDR: { 
>             /* Trash this, because we don't reproduce it */ 
>             const NSegment* ehdrseg =
> VG_(am_find_nsegment)((Addr)auxv->u.a_ptr); 
>             vg_assert(ehdrseg); 
>             VG_(am_munmap_valgrind)(ehdrseg->start, ehdrseg->end -
> ehdrseg->start); 
>             auxv->a_type = AT_IGNORE; 
>             break; 
>          } 
> 

It seems that this case statement is #ifdefed out for ppc, and some other arches, correct? So shouldn't AT_SYSINFO_EHDR, and the vDSO, be available for these arches?

> Is there a reason you need AT_SYSINFO_EHDR?

It's used in glibc for ppc for the backtrace function that prints out return addresses for all frames in a stack. The symbol from the vDSO for the signal trampoline is used to handle the backtrace when there's a signal, which doesn't work when it's run under Valgrind, due to the missing vDSO.
Comment 4 Mark Wielaard 2021-11-29 15:19:41 UTC
This was rediscovered in bug #446123 which has a bit more technical background.
We might simply have to keep track of the vdso too (we currently don't, that is why we remove AT_SYSINFO_EHDR)
Although in the case of glibc backtrace () we might also request a bug fix/workaround in glibc.

*** This bug has been marked as a duplicate of bug 446123 ***
Comment 5 Tulio Magno Quites Machado Filho 2021-11-29 15:33:36 UTC
(In reply to Mark Wielaard from comment #4)
> Although in the case of glibc backtrace () we might also request a bug
> fix/workaround in glibc.

glibc's backtrace implementation has been removed in version 2.35
Source: https://sourceware.org/git/?p=glibc.git;a=commit;h=82fd7314c7df8c5555dce027df6f2c98ca5a927f

So, I believe the fix you're expecting has already been implemented.