[petsc-users] Attaching to gdb within screen

Jed Brown jed at 59A2.org
Wed Jun 22 06:25:30 CDT 2011


On Wed, Jun 22, 2011 at 03:07, John Fettig <john.fettig at gmail.com> wrote:

> I am trying to start my program in gdb, using the options
>
> -start_in_debugger -debug_terminal "screen -X -S debug screen"
>
> where I have a running screen named debug.  If I run with e.g. -np 4,
> all 4 processes report that they are being attached by gdb, but in the
> screen session only 2 new windows show up.  If I run with -np 2, only
> 1 new window shows up.
>

I've seen this, but only inconsistently (race condition) and only with Open
MPI (not with MPICH2).

Are you using MPICH2 or Open MPI? I think MPICH2 might be setting
SA_NOCLDSTOP which is saving us from the following race condition:

1. process is forked
2a. parent sleeps
2b. child gets parent PID and execs the screen attach command
3. screen attach command returns immediately, before actually running the
command (invoking gdb)
4. child exits, generates SIGCHLD which wakes up parent
5. parent continues onward, possibly completing and exiting
6. screen session gets around to invoking gdb and attaching to the parent
process, but it has already exited
(sometimes some of the processes have exited while others are still in
MPI_Finalize or similar)

I think the solution is to use sigaction(3) to set SA_NOCLDSTOP so that the
child terminating does not generate SIGCHLD. The man page points out that
this is typically the desired behavior.

Is there some obscure platform that supports signal(), but not sigaction()
or can we use sigaction() for everything?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110622/0871b739/attachment.htm>


More information about the petsc-users mailing list