From: Mark Kettenis Subject: Re: gprof: Profiling a multi-threaded application (revived) To: "Theo de Raadt" Cc: naito.yuichiro@gmail.com, tech@openbsd.org, guenther@openbsd.org, mpi@openbsd.org Date: Thu, 12 Jun 2025 16:53:22 +0200 > From: "Theo de Raadt" > Date: Thu, 12 Jun 2025 08:16:31 -0600 > > Mark Kettenis wrote: > > > > Date: Fri, 06 Jun 2025 17:43:10 +0900 (JST) > > > From: Yuichiro NAITO > > > > Hi Yuichiro, > > > > This is changing the interface between libc and libpthread. This is > > tricky. Minimally this needs libc and libpthread minor bumps. But it > > is more complicated than that and I have trouble wrapping my head > > around exactly how that works again. guenther@ should know more. > > I am not concerned, because profiling only works in static binaries. The problem is the following bit of code: + /* Ignore errors. NULL is OK for a non-profiling case. */ + thread->gmonparam = _gmon_alloc(); which is executed unconditionally. That gmonparam member lives in a struct whose stotage is allocated by libc. So if you end up combining an old libc that doesn't allocate the storage for the gmonparam member with a new libpthread that writes to it you'll overwrite something else. That said, in that case you'd already lose because you have an unresolved reference to _gmon_alloc(), so your binary wouldn't run in the first place. > In dynamic binaries, I don't believe any of this code is active because > gcrt0 doesn't get linked in to create the conditions. > > As for the cranks. It adds a symbol between the two libraries, so it > needs minor cranks. But libc needs a major bump for removal of a > different symbol, so we'll just major bump both libraries. And that > ends any concern there, I think. I think a major bump for both would indeed be necessary. Unfortunately libpthread major bumps are something we haven't been able to do "right" in the past. In principle we'd need to do bump all the libs linked against libpthread. In base that means the xenocara libs, but I don't think we have a list. But those only really get used by ports and so we can just declare a flag day where we tell people some ports may not run until they run pkg_add -u?