From: Eli Zaretskii <eliz@gnu.org>
To: Pedro Alves <palves@redhat.com>
Cc: tom@tromey.com, gdb-patches@sourceware.org
Subject: Re: [PATCH] Readline: Cleanup some warnings
Date: Wed, 20 Mar 2019 17:39:00 -0000 [thread overview]
Message-ID: <83o965sax9.fsf@gnu.org> (raw)
In-Reply-To: <3fc20d2b-5a49-928a-b474-f812f43a2c12@redhat.com> (message from Pedro Alves on Wed, 20 Mar 2019 15:46:47 +0000)
> Cc: tom@tromey.com, gdb-patches@sourceware.org
> From: Pedro Alves <palves@redhat.com>
> Date: Wed, 20 Mar 2019 15:46:47 +0000
>
> > I agree: the right solution would be for the Readline's SIGINT handler
> > to stop the main thread (e.g., by using SuspendThread).
>
> I don't sure how having the SIGINT handler stop the main thread is
> a 100% correct solution. By the time you stop it, the main thread can well
> be already running readline code, halfway through updating some data
> structure, even if the mainline code disabled SIGINT temporarily,
> with _rl_block_sigint, because by the time the mainline code calls
> _rl_block_sigint, the SIGINT thread may have already have been spawned.
How is this different from what happens on Posix platforms, where the
SIGINT handler can be invoked at any moment, while Readline might be
doing anything at all?
> Also, you're not ever supposed to use SuspendThread for synchronization, I
> believe.
We are also not supposed to mix CRT and Win32 API functions, but we do
that all the time.
> MSDN at <https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-processthreadsapi-suspendthread> says:
>
> "This function is primarily designed for use by debuggers. It is not intended
> to be used for thread synchronization."
>
> And here <https://devblogs.microsoft.com/oldnewthing/?p=44743> it says:
>
> "The SuspendÂThread function tells the scheduler to suspend the thread
> but does not wait for an acknowledgment from the scheduler that the suspension
> has actually occurred."
GNU Make does it for many years, and I have yet to hear a single
complaint about that part.
> I think a mutex/lock for synchronization would be a better solution within
> readline. Make all mainline readline entry points grab a mutex on entry
> and release it on exit. Likewise, make the readline signal handler
> hold a mutex around any code that is unsafe to run in parallel
> with mainline code.
That's fine with me, but is much more complex, and will probably slow
down the code. I won't object if you want to do it that way, though.
> I'm not sure whether readline still installs its own signal handler
> internally in other situations, but it'd be worth it to check that.
> Maybe we never run any readline signal handler on Windows at all
> nowadays with recent readlines, which would simplify things for us,
> rendering the gdb hack in question obsolete.
Maybe we should bring Chet into this discussion.
next prev parent reply other threads:[~2019-03-20 17:39 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-30 8:57 Alan Hayward
2019-01-31 7:59 ` Joel Brobecker
2019-01-31 10:02 ` Alan Hayward
2019-01-31 17:24 ` Alan Hayward
[not found] ` <20190201080533.GA31043@adacore.com>
2019-02-01 12:47 ` Tom Tromey
2019-02-01 18:54 ` Philippe Waroquiers
2019-02-06 19:56 ` Pedro Alves
2019-03-17 17:30 ` Tom Tromey
2019-03-17 18:35 ` Eli Zaretskii
[not found] ` <87imwex333.fsf@tromey.com>
2019-03-19 18:37 ` Eli Zaretskii
2019-03-19 19:02 ` Pedro Alves
2019-03-19 19:04 ` Pedro Alves
2019-03-19 20:14 ` Eli Zaretskii
2019-03-20 8:55 ` Eli Zaretskii
2019-03-20 15:46 ` Pedro Alves
2019-03-20 15:50 ` Pedro Alves
2019-03-20 17:39 ` Eli Zaretskii [this message]
2019-03-20 17:50 ` Pedro Alves
2019-03-20 18:01 ` Eli Zaretskii
2019-03-20 18:28 ` Pedro Alves
2019-03-21 17:31 ` Pedro Alves
2019-03-21 18:30 ` Eli Zaretskii
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=83o965sax9.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.com \
--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