* [gdbserver patch] [7.6.1] Fix fd leak regression
@ 2013-08-26 20:21 Jan Kratochvil
2013-08-27 10:17 ` Pedro Alves
0 siblings, 1 reply; 3+ messages in thread
From: Jan Kratochvil @ 2013-08-26 20:21 UTC (permalink / raw)
To: gdb-patches
Hi,
[7.5 regression] gdbserver leaks socket to inferior
https://sourceware.org/bugzilla/show_bug.cgi?id=15604
gdbserver :1234 true & sleep 1;ls -l /proc/`pidof true`/fd/3
Not including a testcase which I would find useful as it would test also the
*cloexec code in gdb/gdbserver. The problem is DejaGNU already leaks fd on
its own, it should be resolved first:
https://bugzilla.redhat.com/show_bug.cgi?id=1001220
(it is probably upstream DejaGNU bug)
No regressions on {x86_64,x86_64-m32,i686}-fedora21pre-linux-gnu in gdbserver
mode.
Thanks,
Jan
gdb/gdbserver/
2013-08-26 Jan Kratochvil <jan.kratochvil@redhat.com>
PR server/15604
* linux-low.c: Include filestuff.h.
(linux_create_inferior) <pid == 0>: Call close_most_fds.
* lynx-low.c: Include filestuff.h.
(lynx_create_inferior) <pid == 0>: Call close_most_fds.
* server.c: Include filestuff.h.
(main): Call notice_open_fds.
* spu-low.c: Include filestuff.h.
(spu_create_inferior) <pid == 0>: Call close_most_fds.
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 12208dc..7db1fc8 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -44,6 +44,7 @@
#include "gdb_stat.h"
#include <sys/vfs.h>
#include <sys/uio.h>
+#include "filestuff.h"
#ifndef ELFMAG0
/* Don't include <linux/elf.h> here. If it got included by gdb_proc_service.h
then ELFMAG0 will have been defined. If it didn't get included by
@@ -580,6 +581,7 @@ linux_create_inferior (char *program, char **allargs)
if (pid == 0)
{
+ close_most_fds ();
ptrace (PTRACE_TRACEME, 0, (PTRACE_TYPE_ARG3) 0, (PTRACE_TYPE_ARG4) 0);
#ifndef __ANDROID__ /* Bionic doesn't use SIGRTMIN the way glibc does. */
diff --git a/gdb/gdbserver/lynx-low.c b/gdb/gdbserver/lynx-low.c
index 4cf8683..3c75b62 100644
--- a/gdb/gdbserver/lynx-low.c
+++ b/gdb/gdbserver/lynx-low.c
@@ -27,6 +27,7 @@
#include <sys/types.h>
#include "gdb_wait.h"
#include <signal.h>
+#include "filestuff.h"
int using_threads = 1;
@@ -240,6 +241,8 @@ lynx_create_inferior (char *program, char **allargs)
{
int pgrp;
+ close_most_fds ();
+
/* Switch child to its own process group so that signals won't
directly affect gdbserver. */
pgrp = getpid();
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index a4b9129..ebdaba5 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -28,6 +28,7 @@
#endif
#include "gdb_wait.h"
#include "btrace-common.h"
+#include "filestuff.h"
/* The thread set with an `Hc' packet. `Hc' is deprecated in favor of
`vCont'. Note the multi-process extensions made `vCont' a
@@ -2850,6 +2851,10 @@ main (int argc, char *argv[])
exit (1);
}
+ /* Remember stdio descriptors. LISTEN_DESC must not be listed, it will be
+ opened by remote_prepare. */
+ notice_open_fds ();
+
/* We need to know whether the remote connection is stdio before
starting the inferior. Inferiors created in this scenario have
stdin,stdout redirected. So do this here before we call
diff --git a/gdb/gdbserver/spu-low.c b/gdb/gdbserver/spu-low.c
index 6e3974a..e604b9f 100644
--- a/gdb/gdbserver/spu-low.c
+++ b/gdb/gdbserver/spu-low.c
@@ -29,6 +29,7 @@
#include <unistd.h>
#include <errno.h>
#include <sys/syscall.h>
+#include "filestuff.h"
/* Some older glibc versions do not define this. */
#ifndef __WNOTHREAD
@@ -274,6 +275,7 @@ spu_create_inferior (char *program, char **allargs)
if (pid == 0)
{
+ close_most_fds ();
ptrace (PTRACE_TRACEME, 0, 0, 0);
setpgid (0, 0);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [gdbserver patch] [7.6.1] Fix fd leak regression
2013-08-26 20:21 [gdbserver patch] [7.6.1] Fix fd leak regression Jan Kratochvil
@ 2013-08-27 10:17 ` Pedro Alves
2013-08-28 17:46 ` [commit without 7.6.1] " Jan Kratochvil
0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2013-08-27 10:17 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: gdb-patches
On 08/26/2013 09:21 PM, Jan Kratochvil wrote:
> gdb/gdbserver/
> 2013-08-26 Jan Kratochvil <jan.kratochvil@redhat.com>
>
> PR server/15604
> * linux-low.c: Include filestuff.h.
> (linux_create_inferior) <pid == 0>: Call close_most_fds.
> * lynx-low.c: Include filestuff.h.
> (lynx_create_inferior) <pid == 0>: Call close_most_fds.
> * server.c: Include filestuff.h.
> (main): Call notice_open_fds.
> * spu-low.c: Include filestuff.h.
> (spu_create_inferior) <pid == 0>: Call close_most_fds.
OK, thanks.
--
Pedro Alves
^ permalink raw reply [flat|nested] 3+ messages in thread
* [commit without 7.6.1] [gdbserver patch] [7.6.1] Fix fd leak regression
2013-08-27 10:17 ` Pedro Alves
@ 2013-08-28 17:46 ` Jan Kratochvil
0 siblings, 0 replies; 3+ messages in thread
From: Jan Kratochvil @ 2013-08-28 17:46 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
On Tue, 27 Aug 2013 12:17:21 +0200, Pedro Alves wrote:
> On 08/26/2013 09:21 PM, Jan Kratochvil wrote:
>
> > gdb/gdbserver/
> > 2013-08-26 Jan Kratochvil <jan.kratochvil@redhat.com>
> >
> > PR server/15604
> > * linux-low.c: Include filestuff.h.
> > (linux_create_inferior) <pid == 0>: Call close_most_fds.
> > * lynx-low.c: Include filestuff.h.
> > (lynx_create_inferior) <pid == 0>: Call close_most_fds.
> > * server.c: Include filestuff.h.
> > (main): Call notice_open_fds.
> > * spu-low.c: Include filestuff.h.
> > (spu_create_inferior) <pid == 0>: Call close_most_fds.
>
> OK, thanks.
Checked in:
https://sourceware.org/ml/gdb-cvs/2013-08/msg00148.html
Although without 7.6.1 - 7.6 does not yet have gdb/common/filestuff.[ch] and
from various available solutions I think it is just OK to wait for 7.7.
Thanks,
Jan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-08-28 17:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-26 20:21 [gdbserver patch] [7.6.1] Fix fd leak regression Jan Kratochvil
2013-08-27 10:17 ` Pedro Alves
2013-08-28 17:46 ` [commit without 7.6.1] " Jan Kratochvil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).