On Sat, Feb 13, 2016 at 12:31 PM, Michal Mazurek <akf...@jasminek.net> wrote: > When compiling a program that calls pledge(2) with "-pg" the resulting > binary will execute seemingly fine, but at the very end die with: > Abort trap (core dumped) > I think the problem lies in a call to profil(2). > > Is this a bug or a feature?
Seems like a bug. _mcleanup() is invoked via the atexit() in gcrt0.o (c.f. lib/csu/crt0.c) Fixing things so this works will require at least two things: 1) pledge will need to always permit profil(NULL,0,0,0) for the moncontrol(0) performed by _mcleanup() 2) pledge will need to permit opening and writing to "gmon.out" (ignore the $PROFDIR stuff) if and only if profil() had been used. (The fallback code to use setitimer() if sysctl() fails seems pointless: when would that fail and setitimer() succeed?) Philip Guenther