Bug 9585 - GNU/Linux x86, gdb freezes after fork wit detach-on-fork off and follow-fork-mode child
Summary: GNU/Linux x86, gdb freezes after fork wit detach-on-fork off and follow-fork-...
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: 6.7
: P2 critical
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-21 15:58 UTC by aviseldom
Modified: 2012-10-24 15:52 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
CrackMe#1.exe (5.16 KB, application/octet-stream)
, aviseldom
Details
gdb log with debugging info (1.10 KB, text/plain)
2010-04-07 23:11 UTC, Flávio Etrusco
Details
gdb with sched-multiple on (954 bytes, text/plain)
2010-04-08 01:28 UTC, Flávio Etrusco
Details

Note You need to log in before you can comment on or make changes to this bug.
Description aviseldom 2008-07-21 15:58:02 UTC
[Converted from Gnats 2480]

I'm trying to debug a simple console program running under wine, the                               
problem is that gdb freezes when wine creates a new process, I'm using                             
follow-fork-mode child and detach-on-fork off, I've even tried to put a                            
catchpoint at the fork and attach a new instance of gdb to the new                                 
process but it can't be attached even as root, thanks for you help.

Release:
gdb 6.7.1

Environment:
Linux Manchester 2.6.21.1 #2 SMP Wed Jan 2 01:40:41 CET 2008 i686 GNU/Linux

How-To-Repeat:
gdb /usr/lib/wine/wine.bin
set args CrackMe#1.exe (http://crackmes.de/users/br0ken/crackme1/)
set follow-fork-mode child
set detach-on-fork off
run

---- trying with a catchpoint

gdb /usr/lib/wine/wine.bin
set args CrackMe#1.exe (http://crackmes.de/users/br0ken/crackme1/)
catch fork

...

$gdb
attach PID
Comment 1 matthijstijink 2009-11-02 17:30:15 UTC
I confirm this behaviour. I didn't use wine, but with a lot of programs I tried
gdb just hangs.

I tried running a simple bash script but even that doesn't work. Sometimes
Ctrl-C can stop the process so you can quit gdb, but other times gdb hangs and
I have to kill it.

If you use 'set print inferior-events', you see that the new process is
started, but nothing happens.
Comment 2 matthijstijink 2009-11-02 17:32:29 UTC
My architecture is x86_64, by the way
Comment 3 Pedro Alves 2010-04-06 10:33:35 UTC
Can someone confirm this still happens with the latest release?  Seeing
"set debug infrun 1" and "set debug lin-lwp 1" output would also be
interesting.
Comment 4 Flávio Etrusco 2010-04-07 23:03:15 UTC
TBH I don't know whether this issue is the same I'm experiencing.
My problem appears to be that a forked (notice that I don't really not what
syscall it uses) process doesn't freeze execution. If I Ctrl+C I can change
inferiors and invoke 'continue'. Then this process forks another process, again
I Ctrl+C and change the inferior, then when I run it it seems to finish and gets
listed as 'null' in the inferior list. Then I can't continue the inferior, gdb
says they have no threads.
Funny thing is that I ran with the parameters you suggested. Before I ran it the
second time I enabled logging, than the execution did not freeze! I'll copy it
from the terminal and attach it.
Comment 5 Flávio Etrusco 2010-04-07 23:11:42 UTC
Created attachment 4709 [details]
gdb log with debugging info
Comment 6 Pedro Alves 2010-04-07 23:33:25 UTC
> My problem appears to be that a forked (notice that I don't really not what
syscall it uses) process doesn't freeze execution. 

Why would it?  Did you have "catch fork"/"catch vfork" set?

> If I Ctrl+C I can change
> inferiors and invoke 'continue'. Then this process forks another process,
again I Ctrl+C and change the inferior,

Did you mean to use "set schedule-multiple on" to have all inferiors
running simultaneously?

> then when I run it it seems to finish and gets
> listed as 'null' in the inferior list.

If the inferior exited, then it will have no process id, hence <null>.

> gdb says they have no threads.

If the program isn't running anymore, it can't have any threads.

I think most of your problems will go away with "set schedule-multiple on".

(gdb) help set schedule-multiple
Set mode for resuming threads of all processes.
When on, execution commands (such as 'continue' or 'next') resume all
threads of all processes.  When off (which is the default), execution
commands only resume the threads of the current process.  The set of
threads that are resumed is further refined by the scheduler-locking
mode (see help set scheduler-locking).
Comment 7 Flávio Etrusco 2010-04-08 01:25:16 UTC
Thanks for the tip on "set schedule-multiple on", I've been looking for a
setting like this for quite some time in the documentation(s). 
But I anyway, trying gdb behavior seems erratic, not even running the child process.
Also, unfortunately the option didn't fix the problem for me.


>  Did you have "catch fork"/"catch vfork" set?
No.


> If the inferior exited, then it will have no process id, hence <null>.
Sure.

>> gdb says they have no threads.
> If the program isn't running anymore, it can't have any threads.
I meant the other inferiors, 1 and 2, not the exited inferior 3.


> I think most of your problems will go away with "set schedule-multiple on".
I'll attach the session (should have done it before...). 
Thanks.
Comment 8 Flávio Etrusco 2010-04-08 01:26:58 UTC
Forgot to attach "show version":

(gdb) show version
GNU gdb (GDB) 7.1-ubuntu
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) 
Comment 9 Flávio Etrusco 2010-04-08 01:28:16 UTC
Created attachment 4710 [details]
gdb with sched-multiple on
Comment 10 Pedro Alves 2010-04-08 15:19:31 UTC
These issues don't seem to have anything to do with gdb freezing, and we're
going quite offtopic by now.  Please open a new bug report.  While doing so,
please paste the relevant bit of the GDB session in the bug report body, and
describe what you think is wrong, so one doesn't have to open an attachment
and guess to quickly analyse the issue.  Thanks.
Comment 11 Pedro Alves 2012-10-24 15:52:10 UTC
> Pedro Alves 2010-04-06 10:33:35 UTC
>
> Can someone confirm this still happens with the latest release?  Seeing
> "set debug infrun 1" and "set debug lin-lwp 1" output would also be
> interesting.

No feedback on the original reported freeze in a couple years, and given this was reported against 6.7, last we heard was in 2009, and we've had numerous fixes to the fork support since, I'm closing this.

Thanks.
Comment 12 Pedro Alves 2012-10-24 15:52:26 UTC
As above.