GNU bug report logs - #43409
28.0.50; Segfault on non-UTF-8 path

Previous Next

Package: emacs;

Reported by: Lars Ingebrigtsen <larsi <at> gnus.org>

Date: Tue, 15 Sep 2020 00:17:01 UTC

Severity: normal

Found in version 28.0.50

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 43409 in the body.
You can then email your comments to 43409 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#43409; Package emacs. (Tue, 15 Sep 2020 00:17:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Lars Ingebrigtsen <larsi <at> gnus.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 15 Sep 2020 00:17:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.0.50; Segfault on non-UTF-8 path
Date: Tue, 15 Sep 2020 02:16:36 +0200
[Message part 1 (text/plain, inline)]
On Debian bullseye, with a file looking like this in a dired buffer:

[Message part 2 (image/png, inline)]
[Message part 3 (text/plain, inline)]
Hitting RET on that kills Emacs.  Running under gdb, I get this
backtrace:

#0  terminate_due_to_signal
    (sig=sig <at> entry=6, backtrace_limit=backtrace_limit <at> entry=40) at emacs.c:378
#1  0x00005555555984fe in emacs_abort () at sysdep.c:2280
#2  0x0000555555596a9a in multibyte_chars_in_text (ptr=<optimized out>, 
    ptr <at> entry=0x5555565f0870 "f\363o", nbytes=nbytes <at> entry=3)
    at character.c:447
#3  0x00005555555d412b in display_mode_element
    (it=<optimized out>, depth=<optimized out>, field_width=<optimized out>, precision=<optimized out>, elt=<optimized out>, props=<optimized out>, risky=<optimized out>) at xdisp.c:25644
#4  0x00005555555d54b0 in display_mode_element
    (it=0x7fffffffb840, depth=2, field_width=-1, precision=-1, elt=<optimized out>, props=XIL(0), risky=<optimized out>) at lisp.h:1423
#5  0x00005555555d63c2 in gui_consider_frame_title (frame=XIL(0x555555f64c45))
    at lisp.h:1007
#6  0x00005555555e15d9 in prepare_menu_bars () at xdisp.c:12666
#7  redisplay_internal () at xdisp.c:15514
#8  0x000055555568baeb in read_char
    (commandflag=1, map=XIL(0x5555563fb2b3), prev_event=XIL(0), used_mouse_menu=0x7fffffffe52b, end_time=0x0) at keyboard.c:2493
#9  0x000055555568e9c4 in read_key_sequence
    (keybuf=<optimized out>, prompt=XIL(0), dont_downcase_last=<optimized out>, can_return_switch_frame=true, fix_current_buffer=true, prevent_redisplay=<optimized out>) at keyboard.c:9547
#10 0x000055555569034c in command_loop_1 () at lisp.h:1007
#11 0x00005555556fbf17 in internal_condition_case
    (bfun=bfun <at> entry=0x555555690170 <command_loop_1>, handlers=handlers <at> entry=XIL(0x90), hfun=hfun <at> entry=0x555555686ad0 <cmd_error>) at eval.c:1356
#12 0x0000555555681504 in command_loop_2 (ignore=ignore <at> entry=XIL(0))
    at lisp.h:1007
#13 0x00005555556fbe71 in internal_catch
    (tag=tag <at> entry=XIL(0xd200), func=func <at> entry=0x5555556814e0 <command_loop_2>, arg=arg <at> entry=XIL(0)) at eval.c:1117
#14 0x00005555556814ab in command_loop () at lisp.h:1007
#15 0x00005555556866e6 in recursive_edit_1 () at keyboard.c:714
#16 0x0000555555686a12 in Frecursive_edit () at keyboard.c:786
#17 0x000055555559fb54 in main (argc=2, argv=<optimized out>) at emacs.c:2047

This is with

[larsi <at> stories ~]$ echo $LANG
en_US.UTF-8



In GNU Emacs 28.0.50 (build 4, x86_64-pc-linux-gnu, GTK+ Version 3.24.22, cairo version 1.16.0)
 of 2020-09-14 built on stories
Repository revision: e408f2fab24ea81f74d9b84dc83ee67d562846dc
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12008000
System Description: Debian GNU/Linux bullseye/sid


-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: https://lars.ingebrigtsen.no


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43409; Package emacs. (Tue, 15 Sep 2020 14:16:02 GMT) Full text and rfc822 format available.

Message #8 received at 43409 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 43409 <at> debbugs.gnu.org
Subject: Re: bug#43409: 28.0.50; Segfault on non-UTF-8 path
Date: Tue, 15 Sep 2020 17:15:06 +0300
> From: Lars Ingebrigtsen <larsi <at> gnus.org>
> Date: Tue, 15 Sep 2020 02:16:36 +0200
> 
> Hitting RET on that kills Emacs.  Running under gdb, I get this
> backtrace:
> 
> #0  terminate_due_to_signal
>     (sig=sig <at> entry=6, backtrace_limit=backtrace_limit <at> entry=40) at emacs.c:378
> #1  0x00005555555984fe in emacs_abort () at sysdep.c:2280
> #2  0x0000555555596a9a in multibyte_chars_in_text (ptr=<optimized out>, 
>     ptr <at> entry=0x5555565f0870 "f\363o", nbytes=nbytes <at> entry=3)
>     at character.c:447
> #3  0x00005555555d412b in display_mode_element
>     (it=<optimized out>, depth=<optimized out>, field_width=<optimized out>, precision=<optimized out>, elt=<optimized out>, props=<optimized out>, risky=<optimized out>) at xdisp.c:25644

My bad, sorry: I used a wrong API for the job.  Does the below solve
the problem?

diff --git a/src/xdisp.c b/src/xdisp.c
index 10ddb53dba..615f0ca7cf 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -25641,8 +25641,10 @@ display_mode_element (struct it *it, int depth, int field_width, int precision,
 		    /* Non-ASCII characters in SPEC should cause mode-line
 		       element be displayed as a multibyte string.  */
 		    ptrdiff_t nbytes = strlen (spec);
-		    if (multibyte_chars_in_text ((const unsigned char *)spec,
-						 nbytes) != nbytes)
+		    ptrdiff_t nchars, mb_nbytes;
+		    parse_str_as_multibyte ((const unsigned char *)spec, nbytes,
+					    &nchars, &mb_nbytes);
+		    if (!(nbytes == nchars || nbytes != mb_nbytes))
 		      multibyte = true;
 
 		    switch (mode_line_target)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43409; Package emacs. (Tue, 15 Sep 2020 15:13:02 GMT) Full text and rfc822 format available.

Message #11 received at 43409 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 43409 <at> debbugs.gnu.org
Subject: Re: bug#43409: 28.0.50; Segfault on non-UTF-8 path
Date: Tue, 15 Sep 2020 17:12:08 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

> My bad, sorry: I used a wrong API for the job.  Does the below solve
> the problem?

Yup, that fixes the problem.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Tue, 15 Sep 2020 15:46:01 GMT) Full text and rfc822 format available.

Notification sent to Lars Ingebrigtsen <larsi <at> gnus.org>:
bug acknowledged by developer. (Tue, 15 Sep 2020 15:46:02 GMT) Full text and rfc822 format available.

Message #16 received at 43409-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 43409-done <at> debbugs.gnu.org
Subject: Re: bug#43409: 28.0.50; Segfault on non-UTF-8 path
Date: Tue, 15 Sep 2020 18:45:03 +0300
> From: Lars Ingebrigtsen <larsi <at> gnus.org>
> Cc: 43409 <at> debbugs.gnu.org
> Date: Tue, 15 Sep 2020 17:12:08 +0200
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> > My bad, sorry: I used a wrong API for the job.  Does the below solve
> > the problem?
> 
> Yup, that fixes the problem.

Thanks, installed.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 14 Oct 2020 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 310 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.