Is gprof profiling (-pg) reentrant/thread-safe?
Carlos O'Donell
carlos@systemhalted.org
Tue May 3 15:23:00 GMT 2016
On Tue, May 3, 2016 at 10:36 AM, Stu Juengst <juengst@rubiconlabs.io> wrote:
> I was seeing some mysterious segmentation faults in my multi-threaded Linux application which was built with the -pg option for gprof profiling. They went away when I turned -pg off. I took a look at the mcount source for the version of glibc that I'm using (2.2.5) and see that it is updating linked lists in a single global structure (_gmonparam) with no synchronization mechanism to keep multiple threads from accessing this structure simultaneously. Am I missing something, or is gprof profiling not reentrant/thread-safe?
The profil() function in glibc is not thread safe, and it says this in
the manual.
It *should* be thread safe, but nobody has done the work to enhance it.
Please note that thread-safety and reetrancy are two distinct things.
Cheers,
Carlos.
More information about the Libc-help
mailing list