On 23/02/2010 14:35, Jan Stary whispered from the shadows...: > On Feb 23 13:36:56, Anthony Howe wrote: >> I have a daemon process I've written and trying to debug, however, >> whenever it crashes, I get no core file. >> >> 1. The daemon does a setrlimit of RLIMIT_CORE to RLIM_INFINITY (same as >> if I had done "ulimit -H -c unlimited" in the shell before starting the >> process). >> >> 2. The daemon sets its working directory to /var/tmp, which is writeable >> by every one, yet no core file appears. Likewise /var/crash has no core >> file. >> >> 3. The program does not use file system setuid bits, BUT does use the >> setuid() et al. system calls to drop privileges from root to some other >> user (which can write into /var/tmp). >> >> 4. A find / -name '*.core' finds nothing anywhere. >> >> 5. I've even tried sysctl kern.nosuidcoredump=0 and >> kern.nosuidcoredump=2 thinking that the setuid family of system >> functions might be resetting a flag when I drop privileges. >> >> 6. Even forcing a SIGABRT, which should produce a core, does not create >> one. >> >> >> What am I missing in order to get a daemon process on OpenBSD to dump >> core when it crashes? > > Depends on how exactly it "crashes", man sigaction(2). > Are you possibly catching the signals yourself?
I trap several signals, but not SIGABRT. I handle these myself... SIGHUP SIGINT SIGQUIT And ignore these... SIGPIPE SIGTERM SIGALRM SIGXCPU SIGXFSZ SIGVTALRM The daemon is threaded, so my server API handles; serverSignalsInit sets up pthread_sigmask to SIG_BLOCK and serverSignalsLoop is the only thread to receive signals, so other threads do not interfere. Part of my library code has works fine. The issue is core dumps and since SIGABRT should generate a core and I'm not blocking SIGABRT, the daemon should terminate with a core when I force SIGABRT. It don't. So I assume there is something else interfering with the generation of core files, possibly sysctl kern.nosuidcoredump; the daemon is not setuid, but does use setuid family of functions. setrlimits RLIMIT_CORE is set to infinity, and RLIMIT_FSIZE is unlimited too, so the there should be no problem concerning the size of the core file. Sending SIGABRT is just a means to force test core files are created. If I can do that, then when the daemon crashes I'll get a core file to work with. > The following coredumps as a charm: But that example is not a daemon. Its just a regular process. Daemon servers behave differently. > #include <stdlib.h> > > int > main() > { > abort(); > /* NOTREACHED */ > return 0; > } -- Anthony C Howe Skype: SirWumpus SnertSoft +33 6 11 89 73 78 Twitter: SirWumpus BarricadeMX & Milters http://snert.com/ http://nanozen.info/ http://snertsoft.com/