From: Pedro Alves <palves@redhat.com>
To: Don Breazeal <donb@codesourcery.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 00/16 v3] Linux extended-remote fork and exec events
Date: Thu, 13 Nov 2014 14:58:00 -0000 [thread overview]
Message-ID: <5464C728.8090204@redhat.com> (raw)
In-Reply-To: <5464B6A0.9020602@redhat.com>
On 11/13/2014 01:48 PM, Pedro Alves wrote:
> On 11/13/2014 01:38 PM, Pedro Alves wrote:
>> On 10/31/2014 11:28 PM, Don Breazeal wrote:
>>>
>>> - gdb.threads/thread-execl.exp gives a couple of failures related to
>>> scheduler locking. As with the previous item, after spending some
>>> time on this I concluded that pursuing it further now would be
>>> feature-creep, and that this should be tracked with a bug report.
>>
>> Do you have more details on this?
>>
>> Looking at the exec race you mentioned, I thought that thread-execl.exp should
>> expose it, given that the point of the test is exactly a thread other than
>> the main thread execing. But then I stumbled on the fact that running it with
>> your series on top of currently mainline often crashes gdb:
>>
>> $ make check RUNTESTFLAGS="--target_board=native-extended-gdbserver thread-execl.exp"
>> ...
>> Running /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.threads/thread-execl.exp ...
>> ERROR: Process no longer exists
>>
>> === gdb Summary ===
>>
>> # of expected passes 9
>> # of unresolved testcases 1
>>
>> Odd that this doesn't trigger with native testing.
>
> Hmm, here's what valgrind shows (against gdbserver):
> $ valgrind ./gdb -data-directory=data-directory ./testsuite/gdb.threads/thread-execl -ex "tar extended-remote :9999" -ex "b thread_execler" -ex "c" -ex "set scheduler-locking on"
> ...
> Breakpoint 1, thread_execler (arg=0x0) at /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.threads/thread-execl.c:29
> 29 if (execl (image, image, NULL) == -1)
> (gdb) n
> Thread 32509.32509 is executing new program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/thread-execl
> [New Thread 32509.32532]
> ==32510== Invalid read of size 4
> ==32510== at 0x5AA7D8: delete_breakpoint (breakpoint.c:13989)
> ==32510== by 0x6285D3: delete_thread_breakpoint (thread.c:100)
> ==32510== by 0x628603: delete_step_resume_breakpoint (thread.c:109)
> ==32510== by 0x61622B: delete_thread_infrun_breakpoints (infrun.c:2928)
> ==32510== by 0x6162EF: for_each_just_stopped_thread (infrun.c:2958)
> ==32510== by 0x616311: delete_just_stopped_threads_infrun_breakpoints (infrun.c:2969)
> ==32510== by 0x616C96: fetch_inferior_event (infrun.c:3267)
> ==32510== by 0x63A2DE: inferior_event_handler (inf-loop.c:57)
> ==32510== by 0x4E0E56: remote_async_serial_handler (remote.c:11877)
> ==32510== by 0x4AF620: run_async_handler_and_reschedule (ser-base.c:137)
> ==32510== by 0x4AF6F0: fd_event (ser-base.c:182)
> ==32510== by 0x63806D: handle_file_event (event-loop.c:762)
> ==32510== Address 0xcf333e0 is 16 bytes inside a block of size 200 free'd
> ==32510== at 0x4A07577: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==32510== by 0x77CB74: xfree (common-utils.c:98)
> ==32510== by 0x5AA954: delete_breakpoint (breakpoint.c:14056)
> ==32510== by 0x5988BD: update_breakpoints_after_exec (breakpoint.c:3765)
> ==32510== by 0x61360F: follow_exec (infrun.c:1091)
> ==32510== by 0x6186FA: handle_inferior_event (infrun.c:4061)
> ==32510== by 0x616C55: fetch_inferior_event (infrun.c:3261)
> ==32510== by 0x63A2DE: inferior_event_handler (inf-loop.c:57)
> ==32510== by 0x4E0E56: remote_async_serial_handler (remote.c:11877)
> ==32510== by 0x4AF620: run_async_handler_and_reschedule (ser-base.c:137)
> ==32510== by 0x4AF6F0: fd_event (ser-base.c:182)
> ==32510== by 0x63806D: handle_file_event (event-loop.c:762)
> ==32510==
> [Switching to Thread 32509.32532]
>
> Breakpoint 1, thread_execler (arg=0x0) at /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.threads/thread-execl.c:29
> 29 if (execl (image, image, NULL) == -1)
> (gdb)
Ah. The breakpoint in question is the step-resume breakpoint
of the non-main thread, the one we "nexted".
And the issue is that with native debugging, the target deletes
all threads from GDB's list _before_ the exec event is reported:
...
infrun: stop_pc = 0x400640
infrun: stepped into subroutine
infrun: inserting step-resume breakpoint at 0x40076f <<<<<<
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [Thread 0x7ffff7fc4700 (LWP 555)] at 0x400640
infrun: prepare_to_wait
infrun: target_wait (-1, status) =
infrun: -1 [process -1],
infrun: status->kind = ignore
infrun: TARGET_WAITKIND_IGNORE
infrun: prepare_to_wait
infrun: target_wait (-1, status) =
infrun: -1 [process -1],
infrun: status->kind = ignore
infrun: TARGET_WAITKIND_IGNORE
infrun: prepare_to_wait
[Thread 0x7ffff7fc4700 (LWP 555) exited]
Breakpoint 3, delete_thread (ptid=...) at /home/pedro/gdb/mygit/src/gdb/thread.c:371
371 delete_thread_1 (ptid, 0 /* not silent */);
(top-gdb)
But when remote debugging, there are no thread exit events,
so GDB never deletes the thread that was "nexted". And that
thread still has a dangling reference to the step-resume
breakpoint.
With this hack:
---
gdb/linux-nat.c | 2 ++
gdb/linux-thread-db.c | 2 ++
2 files changed, 4 insertions(+)
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index e81a560..df1d6e7 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -892,7 +892,9 @@ exit_lwp (struct lwp_info *lp)
if (print_thread_events)
printf_unfiltered (_("[%s exited]\n"), target_pid_to_str (lp->ptid));
+#if 0
delete_thread (lp->ptid);
+#endif
}
delete_lwp (lp->ptid);
diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c
index c49b567..59f8ec1 100644
--- a/gdb/linux-thread-db.c
+++ b/gdb/linux-thread-db.c
@@ -597,6 +597,8 @@ enable_thread_event_reporting (void)
td_err_e err;
struct thread_db_info *info;
+ return;
+
info = get_thread_db_info (ptid_get_pid (inferior_ptid));
/* We cannot use the thread event reporting facility if these
--
1.9.3
We see the same bad references with native debugging:
Breakpoint 1, thread_execler (arg=0x0) at /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.threads/thread-execl.c:29
29 if (execl (image, image, NULL) == -1)
(gdb) n
[Thread 0x7ffff7fc4700 (LWP 28506) exited]
process 24152 is executing new program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/thread-execl
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 0x7ffff7fc4700 (LWP 4647)]
==12378== Invalid read of size 4
==12378== at 0x5AA5E8: delete_breakpoint (breakpoint.c:13989)
==12378== by 0x6283E3: delete_thread_breakpoint (thread.c:100)
==12378== by 0x628413: delete_step_resume_breakpoint (thread.c:109)
==12378== by 0x61603B: delete_thread_infrun_breakpoints (infrun.c:2928)
==12378== by 0x6160FF: for_each_just_stopped_thread (infrun.c:2958)
==12378== by 0x616121: delete_just_stopped_threads_infrun_breakpoints (infrun.c:2969)
==12378== by 0x616AA6: fetch_inferior_event (infrun.c:3267)
==12378== by 0x63A0EE: inferior_event_handler (inf-loop.c:57)
==12378== by 0x4BF44A: handle_target_event (linux-nat.c:4439)
==12378== by 0x637E7D: handle_file_event (event-loop.c:762)
==12378== by 0x637364: process_event (event-loop.c:339)
==12378== by 0x637406: gdb_do_one_event (event-loop.c:391)
==12378== Address 0xcebf910 is 16 bytes inside a block of size 200 free'd
==12378== at 0x4A07577: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==12378== by 0x77C984: xfree (common-utils.c:98)
==12378== by 0x5AA764: delete_breakpoint (breakpoint.c:14056)
==12378== by 0x5986CD: update_breakpoints_after_exec (breakpoint.c:3765)
==12378== by 0x61341F: follow_exec (infrun.c:1091)
==12378== by 0x61850A: handle_inferior_event (infrun.c:4061)
==12378== by 0x616A65: fetch_inferior_event (infrun.c:3261)
==12378== by 0x63A0EE: inferior_event_handler (inf-loop.c:57)
==12378== by 0x4BF44A: handle_target_event (linux-nat.c:4439)
==12378== by 0x637E7D: handle_file_event (event-loop.c:762)
==12378== by 0x637364: process_event (event-loop.c:339)
==12378== by 0x637406: gdb_do_one_event (event-loop.c:391)
==12378==
[Switching to Thread 0x7ffff7fc4700 (LWP 4647)]
Breakpoint 1, thread_execler (arg=0x0) at /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.threads/thread-execl.c:29
29 if (execl (image, image, NULL) == -1)
(gdb)
next prev parent reply other threads:[~2014-11-13 14:58 UTC|newest]
Thread overview: 109+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-07 18:00 [PATCH 00/10] Linux extended-remote fork events Don Breazeal
2014-08-07 18:00 ` [PATCH 07/10] Extended-remote arch-specific follow fork Don Breazeal
2014-08-07 18:00 ` [PATCH 01/10] Refactor native follow-fork Don Breazeal
2014-08-07 18:00 ` [PATCH 05/10] GDBserver clone breakpoint list Don Breazeal
2014-08-07 18:00 ` [PATCH 03/10] Refactor extended ptrace event status Don Breazeal
2014-08-07 18:00 ` [PATCH 02/10] Refactor follow-fork message printing Don Breazeal
2014-08-07 18:00 ` [PATCH 06/10] Extended-remote follow fork Don Breazeal
2014-08-07 18:00 ` [PATCH 04/10] Enhance extended ptrace event setup Don Breazeal
2014-08-13 17:50 ` Breazeal, Don
2014-08-07 18:01 ` [PATCH 10/10] Extended-remote fork event documentation Don Breazeal
[not found] ` <83tx5om6zs.fsf@gnu.org>
2014-08-08 15:35 ` Breazeal, Don
2014-08-07 18:01 ` [PATCH 08/10] Extended-remote follow vfork Don Breazeal
2014-08-07 18:01 ` [PATCH 09/10] Extended-remote fork catchpoints Don Breazeal
2014-08-21 0:29 ` [Patch 00/16 v2] Linux extended-remote fork and exec events Don Breazeal
2014-09-04 20:57 ` Breazeal, Don
2014-10-31 23:29 ` [PATCH 08/16 v3] Extended-remote follow vfork Don Breazeal
2014-10-31 23:29 ` [PATCH 06/16 v3] Extended-remote Linux follow fork Don Breazeal
2014-11-13 13:00 ` Pedro Alves
2014-11-13 18:53 ` Breazeal, Don
2014-11-13 18:59 ` Pedro Alves
2014-11-13 19:06 ` Breazeal, Don
2014-12-06 0:31 ` Breazeal, Don
2015-01-23 12:53 ` Pedro Alves
2015-01-23 17:18 ` Breazeal, Don
[not found] ` <1422222420-25421-1-git-send-email-donb@codesourcery.com>
2015-01-25 21:49 ` [PATCH v4 5/7] Arch-specific remote " Don Breazeal
2015-02-10 16:37 ` Pedro Alves
2015-01-25 21:49 ` [PATCH v4 6/7] Remote follow vfork Don Breazeal
2015-02-10 16:39 ` Pedro Alves
2015-01-25 21:50 ` [PATCH v4 2/7] Clone remote breakpoints Don Breazeal
2015-01-25 21:50 ` [PATCH v4 1/7] Identify remote fork event support Don Breazeal
2015-02-10 16:34 ` Pedro Alves
2015-01-25 21:58 ` [PATCH v4 7/7] Remote fork catch Don Breazeal
2015-01-26 0:07 ` [PATCH v4 3/7 v3] Extended-remote Linux follow fork Don Breazeal
2015-02-10 16:36 ` Pedro Alves
2015-01-26 0:20 ` [PATCH v4 4/7] Target remote " Don Breazeal
2015-01-12 22:39 ` [PATCH 06/16 v3] Extended-remote Linux " Don Breazeal
2015-01-12 22:49 ` Breazeal, Don
2014-10-31 23:29 ` [PATCH 05/16 v3] GDBserver clone breakpoint list Don Breazeal
2014-10-31 23:29 ` [PATCH 07/16 v3] Extended-remote arch-specific follow fork Don Breazeal
2014-10-31 23:29 ` [PATCH 00/16 v3] Linux extended-remote fork and exec events Don Breazeal
2014-11-12 15:54 ` Pedro Alves
2014-11-13 13:41 ` Pedro Alves
2014-11-13 13:51 ` Pedro Alves
2014-11-13 14:58 ` Pedro Alves [this message]
2014-11-13 19:14 ` Pedro Alves
2014-10-31 23:29 ` [PATCH 04/16 v3] Determine supported extended-remote features Don Breazeal
2014-11-13 12:59 ` Pedro Alves
2014-11-13 18:28 ` Breazeal, Don
2014-11-13 18:33 ` Pedro Alves
2014-11-13 19:08 ` Pedro Alves
2014-11-13 18:37 ` Breazeal, Don
2014-11-13 18:48 ` Pedro Alves
2014-12-06 0:30 ` Breazeal, Don
2015-01-12 22:36 ` Don Breazeal
2015-01-21 21:02 ` Breazeal, Don
2014-10-31 23:30 ` [PATCH 10/16 v3] Extended-remote fork event documentation Don Breazeal
2014-10-31 23:30 ` [PATCH 13/16 v3] Extended-remote exec catchpoints Don Breazeal
2014-10-31 23:30 ` [PATCH 12/16 v3] Extended-remote follow exec Don Breazeal
2014-10-31 23:30 ` [PATCH 09/16 v3] Extended-remote fork catchpoints Don Breazeal
2014-10-31 23:30 ` [PATCH 11/16 v3] Extended-remote Linux exit events Don Breazeal
2014-11-13 19:18 ` Pedro Alves
2014-10-31 23:31 ` [PATCH 15/16 v3] Extended-remote exec event documentation Don Breazeal
2014-10-31 23:31 ` [PATCH 14/16 v3] Suppress spurious warnings with extended-remote follow exec Don Breazeal
2014-10-31 23:31 ` [PATCH 16/16 v3] Non-stop follow exec tests Don Breazeal
2014-08-21 0:29 ` [PATCH 01/16 v2] Refactor native follow-fork Don Breazeal
2014-09-05 14:20 ` Pedro Alves
2014-09-05 18:56 ` Breazeal, Don
2014-09-05 20:20 ` Breazeal, Don
2014-09-09 10:57 ` Pedro Alves
2014-09-08 23:54 ` Breazeal, Don
2014-09-09 11:09 ` Pedro Alves
2014-09-12 16:50 ` Breazeal, Don
2014-09-22 15:53 ` Breazeal, Don
2014-09-26 18:13 ` Pedro Alves
2014-09-29 18:08 ` Breazeal, Don
2014-09-30 10:56 ` Pedro Alves
2014-09-30 18:43 ` Breazeal, Don
2014-08-21 0:30 ` [PATCH 03/16 v2] Refactor ptrace extended event status Don Breazeal
2014-09-09 11:31 ` Pedro Alves
2014-09-19 18:14 ` [pushed] " Breazeal, Don
2014-08-21 0:30 ` [PATCH 04/16 v2] Determine supported extended-remote features Don Breazeal
2014-10-15 16:17 ` Pedro Alves
2014-10-21 23:23 ` Breazeal, Don
2014-10-22 21:48 ` Pedro Alves
2014-10-31 23:38 ` Breazeal, Don
2014-08-21 0:30 ` [PATCH 02/16 v2] Refactor follow-fork message printing Don Breazeal
2014-09-26 19:52 ` Pedro Alves
2014-09-26 20:14 ` Breazeal, Don
2014-10-03 23:51 ` Breazeal, Don
2014-10-15 16:08 ` Pedro Alves
2014-10-22 23:47 ` Breazeal, Don
2014-10-24 12:35 ` Pedro Alves
2014-10-24 18:45 ` Breazeal, Don
2014-08-21 0:31 ` [PATCH 05/16 v2] GDBserver clone breakpoint list Don Breazeal
2014-10-15 17:40 ` Pedro Alves
2014-10-31 23:44 ` Breazeal, Don
2014-08-21 0:31 ` [PATCH 06/16 v2] Extended-remote Linux follow fork Don Breazeal
2014-09-19 20:57 ` Breazeal, Don
2014-08-21 0:31 ` [PATCH 07/16 v2] Extended-remote arch-specific " Don Breazeal
2014-09-19 21:26 ` Breazeal, Don
2014-08-21 0:32 ` [PATCH 08/16 v2] Extended-remote follow vfork Don Breazeal
2014-08-21 0:33 ` [PATCH 09/16 v2] Extended-remote fork catchpoints Don Breazeal
2014-08-21 0:33 ` [PATCH 11/16 v2] Extended-remote Linux exit events Don Breazeal
2014-08-21 0:33 ` [PATCH 10/16 v2] Extended-remote fork event documentation Don Breazeal
2014-08-21 0:34 ` [PATCH 13/16 v2] Extended-remote exec catchpoints Don Breazeal
2014-08-21 0:34 ` [PATCH 12/16 v2] Extended-remote follow exec Don Breazeal
2014-08-21 0:35 ` [PATCH 14/16 v2] Suppress spurious warnings with extended-remote " Don Breazeal
2014-08-21 0:36 ` [PATCH 16/16 v2] Non-stop follow exec tests Don Breazeal
2014-08-21 0:36 ` [PATCH 15/16 v2] Extended-remote exec event documentation Don Breazeal
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=5464C728.8090204@redhat.com \
--to=palves@redhat.com \
--cc=donb@codesourcery.com \
--cc=gdb-patches@sourceware.org \
/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