Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Pedro Alves <pedro@codesourcery.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [patch] Fix a crash on NULL event_thread
Date: Mon, 15 Sep 2008 18:59:00 -0000	[thread overview]
Message-ID: <20080915185627.GA25128@host0.dyn.jankratochvil.net> (raw)
In-Reply-To: <200809122344.55797.pedro@codesourcery.com>

[-- Attachment #1: Type: text/plain, Size: 1366 bytes --]

On Sat, 13 Sep 2008 00:44:55 +0200, Pedro Alves wrote:
> On Friday 12 September 2008 23:12:27, Jan Kratochvil wrote:
> > various testcases - such as gdb.threads/bp_in_thread.exp - crash HEAD. 
> > Tested only on Fedora kernel-2.6.27-0.317.rc5.git10.fc10.x86_64 but I
> > expect it can happen anywhere.
> >
> > LINUX_HANDLE_EXTENDED_WAIT calls ADD_LWP but not ADD_THREAD.
> 
> Hmm, it may be due to something having changed in the scheduling, as I'm
> on ubuntu's 2.6.24-19-generic x86_64 SMP (dual core), and I never saw
> that happen.

Yes, the Fedora kernels have a different ptrace implementation (based on
utrace by Roland McGrath) which has more free but still permitted timing.


> Would it be possible to add the thread to the thread list, in
> addition to the lwp?

IMO the reason for two lists is that really these two resources are different.
You can perfectly have tracked LWPs with no corresponding thread structures.
Attached a testcase using clone(2) which if you CTRL-C it has a state:
(gdb) plist thread_list ptid
$1 = {pid = 25112, lwp = 25112, tid = 0}
(gdb) plist lwp_list ptid
$2 = {pid = 25112, lwp = 25115, tid = 0}
$3 = {pid = 25112, lwp = 25112, tid = 0}

New thread notification will come from libthread_db but some time in between
we have no corresponding thread structures such as they will never exist for
standalone LWPs.


Regards,
Jan

[-- Attachment #2: clone-thread.c --]
[-- Type: text/plain, Size: 1063 bytes --]

#include <unistd.h>
#include <assert.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdlib.h>
#include <sched.h>
#include <sys/mman.h>

#define FLAGS (CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND \
	       | CLONE_THREAD | CLONE_SYSVSEM)

static int
child_func (void *arg)
{
  sleep (60);
  _exit (EXIT_SUCCESS);
  abort ();
}

int
main (void)
{
#ifndef PAGE_SIZE
#define PAGE_SIZE 0x1000
#endif
  const size_t stack_size = PAGE_SIZE;
  unsigned char *stack = mmap (NULL, stack_size, PROT_READ | PROT_WRITE,
			       MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
  int child_tid;

  assert (stack != NULL);
  assert (stack != MAP_FAILED);
  stack[0] = 0;
  stack[stack_size - 1] = 0;

#ifdef __ia64__
  extern int __clone2 (int (*fn) (void *arg), void *child_stack,
		       size_t stack_size, int flags, void *arg);
  child_tid = __clone2 (child_func, stack + stack_size, stack_size,
			FLAGS, NULL);
#else	/* !__ia64__ */
  child_tid = clone (child_func, stack + stack_size, FLAGS, NULL);
#endif	/* !__ia64__ */

  sleep (60);

  return EXIT_SUCCESS;
}

  reply	other threads:[~2008-09-15 18:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-12 22:17 Jan Kratochvil
2008-09-12 22:45 ` Pedro Alves
2008-09-15 18:59   ` Jan Kratochvil [this message]
2008-09-17 15:55     ` Pedro Alves
2008-09-17 18:04 ` Daniel Jacobowitz
2008-09-17 21:56   ` Jan Kratochvil

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=20080915185627.GA25128@host0.dyn.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@codesourcery.com \
    /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