From: Daniel Jacobowitz <drow@false.org>
To: Jan Kratochvil <lace@jankratochvil.net>
Cc: gdb-patches@sourceware.org
Subject: Re: RFC: Fix crash on i386 (%gs-)threaded programs using execve(2)
Date: Wed, 14 Jun 2006 14:25:00 -0000 [thread overview]
Message-ID: <20060614142552.GA15021@nevyn.them.org> (raw)
In-Reply-To: <20060614105510.GA12067@host0.dyn.jankratochvil.net>
On Wed, Jun 14, 2006 at 12:55:10PM +0200, Jan Kratochvil wrote:
> It is only a heuristic as execve(2) destroys %gs and gdb(1) fails to find the
> no longer existing threads through TLS. Patch will warn and turn off the gdb(1)
> threads support if it finds out %gs==0.
>
> On i386 with %gs based TLS NPTLS gdb calls glibc td_ta_map_lwp2thr() which
> calls ta_howto_reg_thread_area() (case ta_howto_reg_thread_area).
> After execve(2) it retrieves %gs as 0 and fails to ps_get_thread_area()
> as its idx must be 6 (glibc TLS descriptor) - value of the first/glibc Linux
> kernel GDT_ENTRY_TLS_MIN.
> It is now workarounded as to drop threading support if %gs==0.
>
> Do you have an idea for a cleaner solution than this hack of waiting till the
> threads are no longer accessible? Not aware of some indication which kernel
> syscall will replace the whole process memory space and the process registers.
Your problem combines two different issues:
- libthread_db doesn't do anything sensible at the beginning of
execution, before libpthread is initialized. I filed a bug in the
glibc bugzilla about this with a possible patch.
- gdb thinks threading is still active after an exec.
We already have a way to detect exec events: PTRACE_EVENT_EXEC.
Support for it is disabled, because it really doesn't work very well,
and no one has volunteered to fix it. The way we handle it doesn't
make much sense; gdb silently switches the current executable file from
the old program to the new programl which messes up what happens when
the user says "run".
But if you wanted to support any kind of execve debugging, that would
be the way to do it.
Oh, and please don't add more tests to the testsuite which would spin
forever if detached from GDB; we've already got a few and I'm convinced
in hindsight that it was a mistake. You only need it to exec once, so
you could make it quietly exit the second time.
--
Daniel Jacobowitz
CodeSourcery
next prev parent reply other threads:[~2006-06-14 14:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-14 10:55 Jan Kratochvil
2006-06-14 14:25 ` Daniel Jacobowitz [this message]
2006-06-15 20:36 ` Jan Kratochvil
2006-07-21 18:16 ` Jan Kratochvil
2006-07-21 18:44 ` Daniel Jacobowitz
2006-07-22 12:31 ` Jan Kratochvil
2006-07-24 19:03 ` Daniel Jacobowitz
2006-07-29 18:54 ` [patch] Linux MAY_FOLLOW_EXEC #2 [Re: RFC: Fix crash on i386 (%gs-)threaded programs using execve(2)] Jan Kratochvil
2006-07-31 20:39 ` Mark Kettenis
2006-08-05 16:43 ` [patch] Linux MAY_FOLLOW_EXEC #2 Jan Kratochvil
2006-08-08 16:01 ` Daniel Jacobowitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060614142552.GA15021@nevyn.them.org \
--to=drow@false.org \
--cc=gdb-patches@sourceware.org \
--cc=lace@jankratochvil.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox