On 2/03/2021 11:55 pm, Silas wrote:
On Mon, Mar 01, 2021 at 10:42:56AM +1100, MJ wrote:On 1/03/2021 10:35 am, RVP wrote:On FreeBSD-12.2 and OpenBSD-6.8 (both having Clang 10.0.1 as the native compiler), the program segfaults even when not linked with any external shared libs. It looks like profiling on the *BSDs needs static binaries (the profile libraries, /usr/lib/*_p.a, are all static anyway). -RVPThat's correct and as expected. Gprof does not profile shared libraries.I expected it to not produce the call graph for the shared libraries, but segfaulting is rather strange, no? I didn't find others reporting this, so I
Well yes, segfault is not a desired or expected outcome. My hunch is gprof neither likes shared libraries or threads. Perhaps it is just too old and broken for modern profiling?
started to think there is a problem with my environment, although I'm not using LD* environment variable or anything related. Should I file a PR? Curious fact: I can profile (generate binary, run the program and use gprof) the same program normally in NetBSD 8.0 armv7hf (Raspberry Pi 2).
Maybe dl_iterate_phdr() passes it's arguments back via %eax/%rax on x32/amd64 but uses the stack otherwise (I think SPARC does)? The former is more efficient but perhaps it's whatever gcc is hooking into with the profile (-pg) flags that's causing segmentation faults? I don't know. Perhaps a PR is in order? Mark.