Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Vasil Dimov <vd@FreeBSD.org>
To: John Baldwin <jhb@freebsd.org>
Cc: Luis Machado <lgustavo@codesourcery.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] PR threads/20743: Don't attempt to suspend or resume exited threads.
Date: Wed, 28 Dec 2016 08:07:00 -0000	[thread overview]
Message-ID: <20161228080707.GA4007@nitro> (raw)
In-Reply-To: <2893581.89CAWbS1EM@ralph.baldwin.cx>

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

On Tue, Dec 27, 2016 at 13:03:27 -0800, John Baldwin wrote:
[...]
> I have tried changing fbsd_wait() to return a TARGET_WAITKIND_SPURIOUS
> instead of explicitly continuing the process, but that doesn't help, and it
> means that the ptid being returned is still T1 in that case.
> 
> I'm not sure if I should explicitly be calling delete_exited_threads() in
> fbsd_resume() before calling iterate_threads()?  Alternatively, fbsd_resume()
> could use ALL_NONEXITED_THREADS() instead of iterate_threads() (it isn't
> clear to me which of these is preferred since both are in use).
> 
> I added the assertion for my own sanity.  I suspect gdb should never try to
> invoke target_resume() with a ptid of an exited thread, but if for some
> reason it did the effect on FreeBSD would be a hang since we would suspend
> all the other threads and when the process was continued via PT_CONTINUE it
> would have nothing to do and would never return from wait().  I'd rather have
> gdb fail an assertion in that case rather than hang.
[...]

Hi,

I am not sure if this is related, but since I get a hang I would rather
mention it: with the John's patch (including the assert) gdb does not
emit the "ptrace: No such process" error, but when I attempt to quit,
it hangs:

  --- cut ---
  ^C
  Thread 1 received signal SIGINT, Interrupt.
  [Switching to LWP 100746 of process 3453]
  0x0000000804e59c7a in _poll () from /lib/libc.so.7
  (gdb) q
  A debugging session is active.

  	Inferior 1 [process 3453] will be killed.

  Quit anyway? (y or n) y

  (hangs here)
  --- cut ---

It has hung here:

  --- cut ---
  (top-gdb) bt
  #0  0x0000000803526df8 in _wait4 () from /lib/libc.so.7
  During symbol reading, cannot get low and high bounds for subprogram DIE at 76931.
  During symbol reading, incomplete CFI data; unspecified registers (e.g., rax) at 0x803a53a8e.
  #1  0x0000000803a53abc in __thr_wait4 (pid=3453, pid@entry=<optimized out>, 
      status=0x7fffffffe304, status@entry=<optimized out>, options=0, 
      options@entry=<optimized out>, rusage=0x0, rusage@entry=<optimized out>)
      at /usr/src/lib/libthr/thread/thr_syscalls.c:563
  #2  0x0000000000540d85 in inf_ptrace_mourn_inferior(target_ops*) ()
  #3  0x000000000067c28f in target_mourn_inferior() ()
  #4  0x0000000000540c6d in inf_ptrace_kill(target_ops*) ()
  #5  0x000000000072769a in kill_or_detach(inferior*, void*) ()
  #6  0x000000000074bdc9 in iterate_over_inferiors(int (*)(inferior*, void*), void*) ()
  #7  0x00000000007272b2 in quit_force(char*, int) ()
  #8  0x0000000000576f74 in cmd_func(cmd_list_element*, char*, int) ()
  #9  0x000000000072698d in execute_command(char*, int) ()
  #10 0x000000000065b2d0 in command_line_handler(char*) ()
  #11 0x000000000065aaf2 in gdb_rl_callback_handler(char*) ()
  #12 0x0000000801c41d7a in rl_callback_read_char () from /usr/local/lib/libreadline.so.6
  #13 0x000000000065a880 in gdb_rl_callback_read_char_wrapper(void*) ()
  #14 0x000000000065ae80 in stdin_event_handler(int, void*) ()
  #15 0x0000000000659cf3 in gdb_wait_for_event(int) ()
  #16 0x00000000006598a3 in gdb_do_one_event() ()
  #17 0x0000000000659df0 in start_event_loop() ()
  #18 0x0000000000654c5c in captured_command_loop(void*) ()
  #19 0x0000000000650037 in catch_errors(int (*)(void*), void*, char*, return_mask) ()
  #20 0x0000000000654696 in gdb_main(captured_main_args*) ()
  #21 0x0000000000408643 in main ()
  (top-gdb)
  --- cut ---

Calling delete_exited_threads before iterate_over_threads in fbsd_resume
does not fix the hang.

inf_ptrace_mourn_inferior calls waitpid and it hangs on the pid of the
program being debugged, which is in TX state:
T       Marks a stopped process.
X       The process is being traced or debugged.

-- 
Vasil Dimov
gro.DSBeerF@dv
%
People can be divided into three groups:
Those who make things happen,
Those who watch things happen and
Those who wonder what happened.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

  reply	other threads:[~2016-12-28  8:07 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-23 21:30 John Baldwin
2016-12-23 21:43 ` Luis Machado
2016-12-27 16:43   ` Vasil Dimov
2016-12-27 21:03     ` John Baldwin
2016-12-28  8:07       ` Vasil Dimov [this message]
2016-12-28 17:37         ` John Baldwin
2017-01-12 16:29           ` Luis Machado
2017-01-12 19:17             ` John Baldwin
2017-01-13  1:27               ` Luis Machado
2017-01-13  1:53                 ` John Baldwin
2017-01-19 11:54                   ` Pedro Alves
2017-01-06 19:35       ` John Baldwin
2017-01-19 11:56       ` 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=20161228080707.GA4007@nitro \
    --to=vd@freebsd.org \
    --cc=gdb-patches@sourceware.org \
    --cc=jhb@freebsd.org \
    --cc=lgustavo@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