Subject: Re: bug#75199: 30.0.93; Emacs crashes when completing with corfu

From: Zhengyi Fu <[email-masked]>
Date: Mon, 30 Dec 2024 23:45:31 +0800

On 2024-12-30 23:24, Eli Zaretskii wrote:
>> From: Zhengyi Fu <[email-masked]>
>> Cc: Po Lu <[email-masked]>,  [email-masked]
>> Date: Mon, 30 Dec 2024 23:04:44 +0800
>> 
>> Eli Zaretskii <[email-masked]> writes:
>> 
>> > I don't understand how 'event', which was 0x7fffffffba70 in
>> > x_error_handler became a NULL pointer inside x_error_quitter, which
>> > x_error_handler calls.
>> >
>> > Po Lu, any ideas?
>> >
>> > Zhengyi Fu, can you configure Emacs 30.0.93 with --enable-checking and
>> > compile it with -O0, and see if you get more detailed diagnostics?
>> >
>> > Also, does disabling the X input method help in any way?  (I see you
>> > are using fcitx.)
>> 
>> This the backtrace I got after rebuilding Emacs with --enable-checking
>> and -O0 and disabling fcitx:
>> 
>> 
>> (gdb) r
>> Starting program: /home/zhengyi/src/emacs/src/emacs -Q -l 
>> \~/.emacs.d/straight/repos/corfu/corfu.el
>> [Thread debugging using libthread_db enabled]
>> Using host libthread_db library "/lib64/libthread_db.so.1".
>> [New Thread 0x7ffff1bfe6c0 (LWP 58332)]
>> [New Thread 0x7ffff126e6c0 (LWP 58333)]
>> [New Thread 0x7fffebfff6c0 (LWP 58334)]
>> [New Thread 0x7fffeb66f6c0 (LWP 58335)]
>> [Detaching after vfork from child process 58338]
>> [Detaching after vfork from child process 58343]
>> [Detaching after vfork from child process 58350]
>> [Detaching after vfork from child process 58351]
>> [Detaching after vfork from child process 58352]
>> [Detaching after vfork from child process 58353]
>> [Detaching after vfork from child process 58357]
>> [Detaching after vfork from child process 58361]
>> [Detaching after vfork from child process 58366]
>> [Detaching after vfork from child process 58370]
>> [Detaching after vfork from child process 58374]
>> [Detaching after vfork from child process 58379]
>> 
>> Thread 1 "emacs" hit Breakpoint 1, x_error_quitter (display=0x104d5d0, 
>> event=0x7fffffffb8c0) at xterm.c:27111
>> 27111	  if (event->error_code == BadName)
> 
> Thanks, but now it doesn't seem to be a crash?  What is the value of
> event->error_code?

It does crash if running asynchronously.  The error code is 2 
(BadValue).
With (x-synchrozie t), Emacs freezes after entering x_error_quitter.

> Earlier you wrote:
> 
>> The error is probably caused by the width value of 0 passed to
>> XCreatePixmapFromBitmapData().
>> 
>> It seems gui_intersect_rectangles() returns true even if the resulted
>> rectangle is empty.  Is that correct behavior?
> 
> Can you tell how this happens?  Is corfu doing something special with
> the fringes?

Sorry, by "width" I mean "height".

I'm not familiar enough with corfu implemantation to give any clue.