Running a program through gdb without "interfering"

Mel Flynn mel.flynn+fbsd.hackers at
Fri Oct 9 14:50:08 UTC 2009

On Friday 09 October 2009 11:38:29 Dag-Erling Smørgrav wrote:
> Mel Flynn <mel.flynn+fbsd.hackers at> writes:
> > is there a way to have a program run through gdb and gdb only record a
> > segfault, but otherwise let the program run?
> Yes, just run "gdb /path/to/program" and type "run".

Not what I was looking for. The segfaults are random and the only way to 
somewhat reliably reproduce it is to have portmaster invoke it as it's 
PM_SU_CMD. And no, running that same command again doesn't trigger the 
segfault, so it's "something environmental". Hence I'm looking for something 
gdb -batch -x script_with_run_cmd.gdb -exec /usr/local/bin/sudo $argv

where somehow I need $argv to be passed as arguments to sudo. I'm thinking i 
should just wrap it and mktemp(1) a new command script for gdb to use with set 
args $*, but if anyone has a more clever idea, I'd love to hear it.

> > [...] sudo *sometimes* segfaults [...] However, it doesn't dump core
> sudo(1) is setuid root.  You need to set kern.sugid_coredump to get it
> to dump core.

It still segfaults and doesn't dump:
Oct  9 04:34:18 smell kernel: pid 39476 (sudo), uid 0: exited on signal 11
Oct  9 04:36:32 smell kernel: pid 79657 (sudo), uid 0: exited on signal 11
Oct  9 04:36:43 smell kernel: pid 82390 (sudo), uid 0: exited on signal 11
Oct  9 04:51:46 smell kernel: pid 3601 (sudo), uid 0: exited on signal 11

find / -name '*.core' in the jail does not yield anything. 

> > [1] In order to get this working I had to put a statically compiled ps in
> > the jail, or the uid test would fail. It has the downside that it lists
> > both jail and host processes, [...]
> Uh, no.  Processes outside the jail are not visible inside it, no matter
> what version of ps(1) or top(1) or any other such program you use.

I'll write this off as pilot error, cause I cannot reproduce it. I saw bash as 
one of the processes listed in a blank ps run, which isn't installed in the 
jail, but since I don't have the terminal history anymore, it's entirely 
possible I ran ps on the host.

More information about the freebsd-hackers mailing list