Summary: | __libc_freeres inhibits cross-platform valgrind | ||
---|---|---|---|
Product: | [Developer tools] valgrind | Reporter: | John Reiser <jreiser> |
Component: | memcheck | Assignee: | Julian Seward <jseward> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | ivosh, mark, pjfloyd |
Priority: | NOR | ||
Version: | 3.13.0 | ||
Target Milestone: | --- | ||
Platform: | Fedora RPMs | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: | |||
Attachments: | Patch as per discussion |
Description
John Reiser
2017-09-15 05:11:03 UTC
If __libc_freeres is used by some library function that is invoked by vgpreload_core-arm-linux.so then vgpreload should implement such a function itself, with an implementation that does the explicit lookup and forwarding if found. Calling optional __gnu_cxx::__freeres() already leverages weak reference mechanism. So __libc__freeres() could use the same mechanism. After you make __libc_freeres() optional, please delete references to it in README_DEVELOPERS as it would be no longer needed. I hit this again today using valgrind-3.15.0 when the default libc on the target platform is glibc-2.29-12.fc30.aarch64 but the actual libc in the target application is from Android 28. __libc_freeres is not defined for all target app environments; therefore __libc_freeres MUST be a WEAK symbol! See comment #2. This could be done the same way as is done for __gnu_cxx::__freeres(). This looks fairly straightforward. Just change # if defined(VGO_linux) /* __libc_freeres() not yet available on Solaris. */ extern void __libc_freeres(void); if ((to_run & VG_RUN__LIBC_FREERES) != 0) { __libc_freeres(); } # endif to extern void __libc_freeres(void) __attribute__((weak)); if (((to_run & VG_RUN__LIBC_FREERES) != 0)) && (__libc_freeres != NULL)) { __libc_freeres(); } in vg_preloaded.c Created attachment 133107 [details]
Patch as per discussion
(In reply to Paul Floyd from comment #6) > Created attachment 133107 [details] > Patch as per discussion Looks correct to me. But I don't have any non-glibc system around to test it. (In reply to Mark Wielaard from comment #7) > Looks correct to me. > But I don't have any non-glibc system around to test it. Regtests are OK on Solaris and FreeBSD. However I don't have any non-libc Linux systems to test. John, could you test this patch? Yes, the patch works, just like the handling of __gnu_cxx::__freeres(). Tested on armv7hl. commit 35c9c33897ef89b08e1518ed16244e70bc6996da Author: Paul Floyd <pjfloyd@wanadoo.fr> Date: Mon Nov 9 16:31:40 2020 +0100 Bug 384729 - __libc_freeres inhibits cross-platform valgrind |