all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Richard Copley <rcopley@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 25279@debbugs.gnu.org
Subject: bug#25279: 26.0.50; Slowdown/crash on certain characters
Date: Tue, 27 Dec 2016 21:15:15 +0000	[thread overview]
Message-ID: <CAPM58ojRL6cKXrckegcqHoWMgZfFvhUGwvD=qkncznbyCyceSA@mail.gmail.com> (raw)
In-Reply-To: <CAPM58ohfwBJFZhYYUPhT00ObjGb2rWQTfcedQvERTNDZSxd=8A@mail.gmail.com>

On 27 December 2016 at 14:32, Richard Copley <rcopley@gmail.com> wrote:
> On 27 December 2016 at 14:15, Eli Zaretskii <eliz@gnu.org> wrote:
>>> From: Richard Copley <rcopley@gmail.com>
>>> Date: Tue, 27 Dec 2016 14:06:27 +0000
>>> Cc: 25279@debbugs.gnu.org
>>>
>>> >> But pressing C-g can cause the indefinite hang in SendMessage seen
>>> >> above.
>>> >
>>> > How many threads are in the program when the hang happens?
>>>
>>> 6, according to an earlier message in this bug.
>>>
>>> > Is the
>>> > input thread still running?  It should be stuck in w32_msg_pump or
>>> > w32_wnd_proc.
>>>
>>> Sounds like Thread 3 from that earlier message.
>>>
>>> Thread 3 (Thread 8808.0x2bfc):
>>> #0  0x00007ffc3eb69844 in ntdll!ZwWaitForAlertByThreadId () from
>>> C:\WINDOWS\SYSTEM32\ntdll.dll
>>> #1  0x00007ffc3eaefa87 in ntdll!RtlpUnWaitCriticalSection () from
>>> C:\WINDOWS\SYSTEM32\ntdll.dll
>>> #2  0x00007ffc3eaef98e in ntdll!RtlpUnWaitCriticalSection () from
>>> C:\WINDOWS\SYSTEM32\ntdll.dll
>>> #3  0x00007ffc3eaef81f in ntdll!RtlpUnWaitCriticalSection () from
>>> C:\WINDOWS\SYSTEM32\ntdll.dll
>>> #4  0x00007ffc3eaf0ce4 in ntdll!RtlEnterCriticalSection () from
>>> C:\WINDOWS\SYSTEM32\ntdll.dll
>>> #5  0x00007ffc3eaf0c10 in ntdll!RtlEnterCriticalSection () from
>>> C:\WINDOWS\SYSTEM32\ntdll.dll
>>> #6  0x0000000400216a9b in post_msg ()
>>> #7  0x00000004001f1920 in post_character_message ()
>>> #8  0x00000004001fc2b6 in w32_wnd_proc ()
>>> #9  0x00007ffc3dbe1c24 in USER32!CallWindowProcW () from
>>> C:\WINDOWS\System32\user32.dll
>>> #10 0x00007ffc3dbe156c in USER32!DispatchMessageW () from
>>> C:\WINDOWS\System32\user32.dll
>>> #11 0x00000004001f9dc3 in w32_msg_pump.isra ()
>>> #12 0x00000004001fa430 in w32_msg_worker ()
>>> #13 0x00007ffc3c038364 in KERNEL32!BaseThreadInitThunk () from
>>> C:\WINDOWS\System32\kernel32.dll
>>> #14 0x00007ffc3eb270d1 in ntdll!RtlUserThreadStart () from
>>> C:\WINDOWS\SYSTEM32\ntdll.dll
>>> #15 0x0000000000000000 in ?? ()
>>> Backtrace stopped: previous frame inner to this frame (corrupt stack?)
>>>
>>> > The backtrace you show seems to say that SendMessage doesn't return,
>>> > which might mean the thread it is sending the message to is either
>>> > dead or not responding.  That thread is the input thread.
>>>
>>> Maybe a deadly embrace then. I'll research how to ask GDB about the
>>> state of kernel sync objects.
>>
>> I think I see what's happening: it's a deadlock.  When you type C-g,
>> the input thread (which receives all keyboard input from Windows),
>> sets the quit-flag, then attempts to send the C-g character to the
>> main thread.  To send the message, it tries to enter critical section,
>> and waits for it.  Meanwhile, the main thread tries to tell the input
>> thread to draw the scroll bar, and calls SendMessage for that.
>> SendMessage waits for the input thread to receive the message, but the
>> input thread is stuck waiting for the main thread to exit the critical
>> section.
>
> Great! So we should enter the same critical section in the input thread
> before calling SendMessage.
>
> (I bet it's not that simple. I'm just trying to join in the fun.)

For the record: even being charitable and assuming I meant we should
enter the critical section in the main thread before telling the input
thread to draw the scroll bar, that's stupid and will make Emacs hang
on startup, as soon as it first draws the vertical scroll bar.

I can reproduce the hang on demand now, with the recipe below,
provided Symbola isn't installed, that is, provided MUSIC FLAT SIGN,
RIGHTWARDS DOUBLE ARROW or whatever other characters have the property
that:

> > The fonts Emacs finds for displaying these characters all have
> > non-Unicode registry fields, and that causes Emacs to desperately
> > look for a Unicode font each time it needs to display one of these
> > characters.

From "runemacs -Q":
Type "M-x insert-char RET MUSIC SPC FLAT SPC SIGN RET" (or whatever character).
Observe that moving point past the character is very slow.
In quick succession:
1. Type C-f to move point past the character.
2. Type C-g to signal quit.





  reply	other threads:[~2016-12-27 21:15 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-26 20:09 bug#25279: 26.0.50; Slowdown/crash on certain characters Richard Copley
2016-12-26 20:18 ` Richard Copley
2016-12-26 20:25 ` Eli Zaretskii
2016-12-26 20:40   ` Richard Copley
2016-12-26 20:49     ` Eli Zaretskii
2016-12-26 21:21       ` Richard Copley
2016-12-27  7:21         ` Eli Zaretskii
     [not found]           ` <CAPM58oiS8+TuR8WhKZmEZdWY_ac44xLDjnpYAD0aWqU6=mX7eg@mail.gmail.com>
2016-12-27 13:51             ` bug#25279: Fwd: " Richard Copley
     [not found]             ` <CAPM58oioMPAo=x8F1whs5YS3RMwceoadAT9TN7Macbx=SaxyJA@mail.gmail.com>
2016-12-27 13:53               ` Richard Copley
     [not found]               ` <838tr1wlg4.fsf@gnu.org>
     [not found]                 ` <CAPM58og6d1EqTEyMy6df27DXB_ERYOD5=pmFHC9MmoFmq+CDgw@mail.gmail.com>
     [not found]                   ` <837f6lwkju.fsf@gnu.org>
2016-12-27 14:06                     ` Richard Copley
2016-12-27 14:15                       ` Eli Zaretskii
2016-12-27 14:32                         ` Richard Copley
2016-12-27 21:15                           ` Richard Copley [this message]
2017-02-21 20:05                             ` Richard Copley
2017-02-21 20:28                               ` Eli Zaretskii
2017-02-21 20:33                                 ` Richard Copley
2017-02-21 20:38                                   ` Richard Copley
2017-02-23 16:19                                 ` Eli Zaretskii
2017-02-23 19:15                                   ` Richard Copley
2017-02-23 19:20                                     ` Richard Copley
2017-02-23 15:22                               ` 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='CAPM58ojRL6cKXrckegcqHoWMgZfFvhUGwvD=qkncznbyCyceSA@mail.gmail.com' \
    --to=rcopley@gmail.com \
    --cc=25279@debbugs.gnu.org \
    --cc=eliz@gnu.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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.