Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: palves@redhat.com (Pedro Alves)
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] gdbserver: don't pick a random thread if the current thread dies
Date: Mon, 24 Aug 2015 14:59:00 -0000	[thread overview]
Message-ID: <20150824145933.1A02B1249E@oc7340732750.ibm.com> (raw)
In-Reply-To: <1438872279-7416-1-git-send-email-palves@redhat.com> from "Pedro Alves" at Aug 06, 2015 03:44:39 PM

Pedro Alves wrote:

> 	* spu-low.c (spu_resume, spu_request_interrupt): Use the first
> 	thread's lwp instead of the current thread's.

>  static void
>  spu_request_interrupt (void)
>  {
> -  syscall (SYS_tkill, ptid_get_lwp (current_ptid), SIGINT);
> +  struct thread_info *thr = get_first_thread ();
> +
> +  syscall (SYS_tkill, ptid_get_lwp (thr), SIGINT);
>  }

This doesn't compile due to:

gdbserver/spu-low.c: In function 'spu_request_interrupt':
gdbserver/spu-low.c:639: error: incompatible type for argument 1 of 'ptid_get_lwp'

When adding the obvious fix ("ptid_of (thr)"), it does compile, but now
gdbserver crashes as soon as GDB attaches to it:

Program received signal SIGSEGV, Segmentation fault.                                                                                                                               
0x10008274 in read_ptid (buf=0x1005045a "0", obuf=0x0) at /home/uweigand/fsf/binutils-gdb/gdb/gdbserver/remote-utils.c:578
578       pid = ptid_get_pid (current_ptid);
(gdb) bt
#0  0x10008274 in read_ptid (buf=0x1005045a "0", obuf=0x0) at /home/uweigand/fsf/binutils-gdb/gdb/gdbserver/remote-utils.c:578
#1  0x1001045c in process_serial_event (err=<value optimized out>, client_data=<value optimized out>) at /home/uweigand/fsf/binutils-gdb/gdb/gdbserver/server.c:3864
#2  handle_serial_event (err=<value optimized out>, client_data=<value optimized out>) at /home/uweigand/fsf/binutils-gdb/gdb/gdbserver/server.c:4206
#3  0x100176c0 in handle_file_event (event_file_desc=<value optimized out>) at /home/uweigand/fsf/binutils-gdb/gdb/gdbserver/event-loop.c:429
#4  0x10017e90 in process_event () at /home/uweigand/fsf/binutils-gdb/gdb/gdbserver/event-loop.c:184
#5  start_event_loop () at /home/uweigand/fsf/binutils-gdb/gdb/gdbserver/event-loop.c:547
#6  0x1000ce3c in captured_main (argc=3, argv=0x1) at /home/uweigand/fsf/binutils-gdb/gdb/gdbserver/server.c:3559
#7  0x1000d370 in main (argc=3, argv=0xffbbf994) at /home/uweigand/fsf/binutils-gdb/gdb/gdbserver/server.c:3634
(gdb) list
573       /* No multi-process.  Just a tid.  */
574       tid = hex_or_minus_one (p, &pp);
575
576       /* Since the stub is not sending a process id, then default to
577          what's in the current inferior.  */
578       pid = ptid_get_pid (current_ptid);
579
580       if (obuf)
581         *obuf = pp;
582       return ptid_build (pid, tid, 0);


Looks like current_thread is NULL at this point.  Since this is generic
code, I'm not quite sure if this is a SPU-specific problem or not ...

Do you think this is related to your change?

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU/Linux compilers and toolchain
  Ulrich.Weigand@de.ibm.com


  parent reply	other threads:[~2015-08-24 14:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-06 14:54 Pedro Alves
2015-08-21 18:44 ` Pedro Alves
2015-08-24 14:59 ` Ulrich Weigand [this message]
2015-08-24 15:30   ` Pedro Alves
2015-08-24 15:47     ` Pedro Alves
2015-08-24 17:02     ` Pedro Alves
2015-08-24 17:08       ` Ulrich Weigand
2015-08-24 17:13         ` Pedro Alves
2015-08-24 18:39           ` Ulrich Weigand
2015-08-24 19:09             ` Pedro Alves

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=20150824145933.1A02B1249E@oc7340732750.ibm.com \
    --to=uweigand@de.ibm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.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