Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH v2] Release the GIL while running a gdb command or expression
Date: Wed, 24 Oct 2018 18:08:00 -0000	[thread overview]
Message-ID: <8b981b27-1e15-31d8-0342-492700468ecf@redhat.com> (raw)
In-Reply-To: <87sh15bm71.fsf@tromey.com>

On 10/16/2018 10:45 PM, Tom Tromey wrote:
>>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:
> 
> Tom> Also the Python code is calling print on a gdb stream in a background
> Tom> thread, which is a no-no.
> 
> If you ignore this then I have a version that works.  Racy in theory but
> maybe not in practice.
We have plenty of tests that shouldn't be racy in theory but are
in practice.  So I'd instead assume that in practice someone will
definitely run into the race.

Do we really need to rely on printing to check this?  If the
the gdb.execute command can run some more python code, then
we could try using a couple python mutexes for proving the
non-main thread runs.  

So the non-main thread would wait on mutex1 which starts owned
by the main thread.  The main thread unlocks mutex1 and blocks
on mutex2, waiting for the non-main thread to release it.
The non-main thread should now run, and is now the mutex1 owner.
It now releases mutex2.  The main thread now unblocks, and the
test succeeds.  If we don't release the GIL properly, then
the non-main thread won't run, and the testcase times out.

Or something along those lines.

Thanks,
Pedro Alves


  reply	other threads:[~2018-10-24 18:08 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-10 20:23 Tom Tromey
2018-10-12 14:52 ` Phil Muldoon
2018-10-12 16:49 ` Pedro Alves
2018-10-12 16:51   ` Pedro Alves
2018-10-16 12:48   ` Tom Tromey
2018-10-16 14:50     ` Pedro Alves
2018-10-12 16:56 ` Pedro Alves
2018-10-16 13:05   ` Tom Tromey
2018-10-16 14:51     ` Pedro Alves
2018-10-16 21:39       ` Tom Tromey
2018-10-16 21:45         ` Tom Tromey
2018-10-24 18:08           ` Pedro Alves [this message]
2018-10-25 12:46             ` Phil Muldoon
2018-11-04 15:54             ` Tom Tromey
2019-01-29 13:02               ` Tom Tromey

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=8b981b27-1e15-31d8-0342-492700468ecf@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.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