From: Pedro Alves <palves@redhat.com>
To: Yao Qi <qiyaoltc@gmail.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 2/2] Don't delete thread_info if refcount isn't zero
Date: Mon, 10 Apr 2017 15:57:00 -0000 [thread overview]
Message-ID: <492d5199-df50-9516-3781-12c319e48233@redhat.com> (raw)
In-Reply-To: <9c8ed015-2eb0-9b5c-affc-b5ba59179a7f@redhat.com>
I'm taking a look at adding the test mentioned below, and managed to
trigger an internal error:
src/gdb/inferior.c:66: internal-error: void set_current_inferior(inferior*): Assertion `inf != NULL' failed.
A problem internal to GDB has been detected,KFAIL: gdb.threads/threadapply.exp: kill_and_remove: try kill-and-remove: thread apply 1.1 kill-and-remove (GDB internal error)
I'll poke a bit more at it.
Thanks,
Pedro Alves
On 04/06/2017 11:18 AM, Pedro Alves wrote:
> The rest of the review comments below could be addressed separately
> (by anyone, not necessarily you), I'm just putting them out as
> I thought of them. I do think we should do it to avoid
> hard-to-debug corner cases around find_inferior_ptid finding
> an unrelated process that reused the old inferior's pid.
>
>> - if (tp
>> - && find_inferior_ptid (tp->ptid) != NULL)
>> - restore_current_thread (old->inferior_ptid);
>> + /* If an entry of thread_info was previously selected, it won't be
>> + deleted because we've increased its refcount. The thread represented
>> + by this thread_info entry may have already exited (due to normal exit,
>> + detach, etc), so the thread_info.state is THREAD_EXITED. */
>> + if (old->thread != NULL
>> + && find_inferior_ptid (old->thread->ptid) != NULL)
>> + restore_current_thread (old->thread->ptid);
>
> Note this was a look up by inferior ptid, not by (stable) inferior number,
> so we can genuinely find no inferior, even though the old inferior _object_
> will always be around when we get here, given that we mark it non-removable
> while the cleanup is installed [1]. Quite similar to increasing the
> thread's refcount, really.
>
> So this predicate would probably be better as:
>
> if (old->thread != NULL
> && old->thread != THREAD_EXITED
> && find_inferior_id (old->inf_id)->pid != 0)
>
> We could also store the inferior pointer in "old" directly,
> instead of the id, sparing the inferior look up:
>
> if (old->thread != NULL
> && old->thread != THREAD_EXITED
> && old->inf->pid != 0)
>
>
> [1] - We should probably have a test that does something like:
>
> define kill-and-remove
> kill inferiors 2
> remove-inferiors 2
> end
>
> # Start one inferior.
> start
>
> # Start another inferior.
> add-inferior 2
> inferior 2
> start
>
> # Kill and remove inferior 1 while thread 2.1 / inferior 2 is selected.
> thread apply 1.1 kill-and-remove
next prev parent reply other threads:[~2017-04-10 15:57 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-28 8:24 [PATCH 0/2] Fix thread_info refcount Yao Qi
2017-03-28 8:24 ` [PATCH 2/2] Delete thread_info is refcount is zero Yao Qi
2017-03-28 12:10 ` Pedro Alves
2017-04-05 21:15 ` [PATCH 0/2] Don't delete thread_info if refcount isn't zero Yao Qi
2017-04-05 21:15 ` [PATCH 2/2] " Yao Qi
2017-04-06 10:18 ` Pedro Alves
2017-04-07 9:22 ` Yao Qi
2017-04-07 10:29 ` Pedro Alves
2017-04-10 13:40 ` Yao Qi
2017-04-10 14:50 ` [pushed] GC gdb/thread.c:current_thread_cleanup_chain (Re: [PATCH 2/2] Don't delete thread_info if refcount isn't zero) Pedro Alves
2017-04-10 15:57 ` Pedro Alves [this message]
2017-04-05 21:15 ` [PATCH 1/2] Hoist code on marking thread as exited Yao Qi
2017-04-06 9:27 ` Pedro Alves
[not found] ` <1490689483-16084-2-git-send-email-yao.qi@linaro.org>
2017-03-28 12:12 ` [PATCH 1/2] Add constructor and destructor to thread_info Pedro Alves
2017-03-28 14:08 ` Yao Qi
2017-03-28 14:47 ` Pedro Alves
2017-03-28 15:40 ` Yao Qi
2017-03-28 22:35 ` Pedro Alves
2017-03-29 15:59 ` Yao Qi
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=492d5199-df50-9516-3781-12c319e48233@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=qiyaoltc@gmail.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