From unknown Tue Jun 17 22:07:43 2025 X-Loop: help-debbugs@gnu.org Subject: bug#37385: 27.0.50; Crash on multibyte assertion violation Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 11 Sep 2019 20:33:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 37385 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 37385@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.15682339447594 (code B ref -1); Wed, 11 Sep 2019 20:33:01 +0000 Received: (at submit) by debbugs.gnu.org; 11 Sep 2019 20:32:24 +0000 Received: from localhost ([127.0.0.1]:42801 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i89Hs-0001yP-47 for submit@debbugs.gnu.org; Wed, 11 Sep 2019 16:32:24 -0400 Received: from lists.gnu.org ([209.51.188.17]:60570) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i89Hq-0001yH-MK for submit@debbugs.gnu.org; Wed, 11 Sep 2019 16:32:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45651) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i89Ho-0003Vs-Qp for bug-gnu-emacs@gnu.org; Wed, 11 Sep 2019 16:32:22 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,RCVD_IN_DNSWL_NONE, URIBL_BLOCKED autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i89Hg-0003Z4-0f for bug-gnu-emacs@gnu.org; Wed, 11 Sep 2019 16:32:15 -0400 Received: from anteater.elm.relay.mailchannels.net ([23.83.212.3]:30115) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i89He-0003VJ-In for bug-gnu-emacs@gnu.org; Wed, 11 Sep 2019 16:32:11 -0400 X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id CC3C55E190D for ; Wed, 11 Sep 2019 20:32:02 +0000 (UTC) Received: from pdx1-sub0-mail-a53.g.dreamhost.com (100-96-91-237.trex.outbound.svc.cluster.local [100.96.91.237]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 4A86B5E1CA9 for ; Wed, 11 Sep 2019 20:32:02 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Received: from pdx1-sub0-mail-a53.g.dreamhost.com ([TEMPUNAVAIL]. [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.17.5); Wed, 11 Sep 2019 20:32:02 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jurta@jurta.org X-MailChannels-Auth-Id: dreamhost X-Troubled-Wide-Eyed: 38a9bdeb4e63ccf7_1568233922532_4207892381 X-MC-Loop-Signature: 1568233922532:2106337843 X-MC-Ingress-Time: 1568233922531 Received: from pdx1-sub0-mail-a53.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a53.g.dreamhost.com (Postfix) with ESMTP id EAC39837A6 for ; Wed, 11 Sep 2019 13:31:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=linkov.net; h=from:to :subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=linkov.net; bh=dhIJP/ycg0QfgHXADPf iADruANU=; b=V67PSIt9J5HUS237h5HNOw3N8WI3sOiROSuZyw7SuIXfXyj+TQ1 WviGGP8GOdvR2eB7uPKMtHjEPBd5PPtd3J16a3NKyf/DFPytWuxK1U9upZMX/fC1 uSVSRKhi1wzk2Vdx7+LBJQ2ODNVNriFhYsVjMV3FhB7q4OYKeRkRc0qA= Received: from mail.jurta.org (m91-129-108-240.cust.tele2.ee [91.129.108.240]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jurta@jurta.org) by pdx1-sub0-mail-a53.g.dreamhost.com (Postfix) with ESMTPSA id B9487837AB for ; Wed, 11 Sep 2019 13:31:57 -0700 (PDT) X-DH-BACKEND: pdx1-sub0-mail-a53 From: Juri Linkov Organization: LINKOV.NET Date: Wed, 11 Sep 2019 23:24:03 +0300 Message-ID: <87tv9ir38c.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: 0 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrtdefgdduvdegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgdpffftgfetoffjqffuvfenuceurghilhhouhhtmecufedttdenucenucfjughrpefhvffuohffkfgfgggtgfesthekredttderjeenucfhrhhomheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqeenucfkphepledurdduvdelrddutdekrddvgedtnecurfgrrhgrmhepmhhouggvpehsmhhtphdphhgvlhhopehmrghilhdrjhhurhhtrgdrohhrghdpihhnvghtpeeluddruddvledruddtkedrvdegtddprhgvthhurhhnqdhprghthheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqedpmhgrihhlfhhrohhmpehjuhhriheslhhinhhkohhvrdhnvghtpdhnrhgtphhtthhopegsuhhgqdhgnhhuqdgvmhgrtghssehgnhhurdhorhhgnecuvehluhhsthgvrhfuihiivgeptd Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 23.83.212.3 X-Spam-Score: -1.4 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) Testing the tabs branch helped to expose a bug in master: In GNU Emacs 27.0.50 (build 6, x86_64-pc-linux-gnu) of 2019-09-11 built on localhost Repository revision: 4d90fadf27ccbb98e0e174304cb4e3008bf364fc Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.1190600= 0 System Description: Linux Mint 19.1 Configured using: 'configure --with-x-toolkit=3Dno --enable-checking=3Dyes,glyphs --enable-check-lisp-object-type 'CFLAGS=3D-O0 -g3'' These steps reproduce the crash in master: 0. emacs -Q 1. Eval: (define-key global-map [menu-bar test] '("Test =E2=AE=BF" keymap= )) 2. Visit an image file, e.g. etc/images/attach.pbm #0 0x00005555557a61b8 in terminate_due_to_signal (sig=3D6, backtrace_lim= it=3D2147483647) at emacs.c:374 #1 0x00005555558c7555 in die (msg=3D0x555555ae73ee "SINGLE_BYTE_CHAR_P (= c)", file=3D0x555555ae4790 "xdisp.c", line=3D7250) at alloc.c:7256 #2 0x00005555555e9e56 in get_next_display_element (it=3D0x7fffffff89b0) = at xdisp.c:7250 #3 0x000055555562938c in display_string (string=3D0x0, lisp_string=3DXIL= (0x5555567a0204), face_string=3DXIL(0), face_string_pos=3D0, start=3D0, i= t=3D0x7fffffff89b0, field_width=3D7, precision=3D0, max_x=3D674, multibyt= e=3D-1) at xdisp.c:25489 #4 0x00005555556239db in display_menu_bar (w=3D0x5555565cae40) at xdisp.= c:23533 #5 0x000055555560d61e in redisplay_window (window=3DXIL(0x5555565cae45),= just_this_one_p=3Dfalse) at xdisp.c:17821 #6 0x0000555555603b79 in redisplay_window_0 (window=3DXIL(0x5555565cae45= )) at xdisp.c:15116 #7 0x0000555555921b23 in internal_condition_case_1 (bfun=3D0x555555603b3= 7 , arg=3DXIL(0x5555565cae45), handlers=3DXIL(0x7fffe= 995aad3), hfun=3D0x555555603aff ) at eval.c:1379 #8 0x0000555555603ad1 in redisplay_windows (window=3DXIL(0x5555565cae45)= ) at xdisp.c:15096 #9 0x00005555556024c2 in redisplay_internal () at xdisp.c:14579 #10 0x00005555555ffea3 in redisplay () at xdisp.c:13806 #11 0x00005555557b7948 in read_char (commandflag=3D1, map=3DXIL(0x555556a= 2aba3), prev_event=3DXIL(0), used_mouse_menu=3D0x7fffffffdd25, end_time=3D= 0x0) at keyboard.c:2472 #12 0x00005555557c930f in read_key_sequence (keybuf=3D0x7fffffffdf10, pro= mpt=3DXIL(0), dont_downcase_last=3Dfalse, can_return_switch_frame=3Dtrue,= fix_current_buffer=3Dtrue, prevent_redisplay=3Dfalse) at keyboard.c:9125 #13 0x00005555557b3d8b in command_loop_1 () at keyboard.c:1345 #14 0x0000555555921a48 in internal_condition_case (bfun=3D0x5555557b390d = , handlers=3DXIL(0x90), hfun=3D0x5555557b2ed7 = ) at eval.c:1355 #15 0x00005555557b34f4 in command_loop_2 (ignore=3DXIL(0)) at keyboard.c:= 1091 #16 0x0000555555920ea2 in internal_catch (tag=3DXIL(0xcdb0), func=3D0x555= 5557b34c7 , arg=3DXIL(0)) at eval.c:1116 #17 0x00005555557b3492 in command_loop () at keyboard.c:1070 #18 0x00005555557b29be in recursive_edit_1 () at keyboard.c:714 #19 0x00005555557b2bb6 in Frecursive_edit () at keyboard.c:786 #20 0x00005555557a8acc in main (argc=3D3, argv=3D0x7fffffffe368) at emacs= .c:2086 An assertion violation is in get_next_display_element: if (! it->multibyte_p && ! ASCII_CHAR_P (c)) { eassert (SINGLE_BYTE_CHAR_P (c)); The menu item uses a multibyte char: c =3D 11199 (#o25677, #x2bbf, ?=E2=AE=BF) But init_iterator sets multibyte_p in the menu-bar window to the value of enable-multibyte-characters in the current buffer where enable-multibyte-characters is nil when an image file is visited in image-mode: /* Are multibyte characters enabled in current_buffer? */ it->multibyte_p =3D !NILP (BVAR (current_buffer, enable_multibyte_chara= cters)); I tried the following fix and it prevents the crash: diff --git a/src/xdisp.c b/src/xdisp.c index 94f969f37c..5730145268 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -2984,7 +2984,9 @@ init_iterator (struct it *it, struct window *w, it->dp =3D window_display_table (w); =20 /* Are multibyte characters enabled in current_buffer? */ - it->multibyte_p =3D !NILP (BVAR (current_buffer, enable_multibyte_char= acters)); + it->multibyte_p =3D WINDOW_MENU_BAR_P (w) + || WINDOW_TOOL_BAR_P (w) + || !NILP (BVAR (current_buffer, enable_multibyte_characters)); =20 /* Get the position at which the redisplay_end_trigger hook should be run, if it is to be run at all. */ @@ -6864,7 +6866,9 @@ reseat_1 (struct it *it, struct text_pos pos, bool = set_stop_p) it->method =3D GET_FROM_BUFFER; it->object =3D it->w->contents; it->area =3D TEXT_AREA; - it->multibyte_p =3D !NILP (BVAR (current_buffer, enable_multibyte_char= acters)); + it->multibyte_p =3D WINDOW_MENU_BAR_P (it->w) + || WINDOW_TOOL_BAR_P (it->w) + || !NILP (BVAR (current_buffer, enable_multibyte_characters)); it->sp =3D 0; it->string_from_display_prop_p =3D false; it->string_from_prefix_prop_p =3D false; From unknown Tue Jun 17 22:07:43 2025 X-Loop: help-debbugs@gnu.org Subject: bug#37385: 27.0.50; Crash on multibyte assertion violation Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 12 Sep 2019 13:02:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 37385 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Juri Linkov Cc: 37385@debbugs.gnu.org Received: via spool by 37385-submit@debbugs.gnu.org id=B37385.15682933189623 (code B ref 37385); Thu, 12 Sep 2019 13:02:03 +0000 Received: (at 37385) by debbugs.gnu.org; 12 Sep 2019 13:01:58 +0000 Received: from localhost ([127.0.0.1]:43168 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i8OjW-0002V9-3P for submit@debbugs.gnu.org; Thu, 12 Sep 2019 09:01:58 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50666) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i8OjT-0002Uv-1r for 37385@debbugs.gnu.org; Thu, 12 Sep 2019 09:01:55 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:33574) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1i8OjN-00037B-Il; Thu, 12 Sep 2019 09:01:49 -0400 Received: from [176.228.60.248] (port=2432 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1i8OjI-0000tz-EI; Thu, 12 Sep 2019 09:01:47 -0400 Date: Thu, 12 Sep 2019 16:01:56 +0300 Message-Id: <83ftl11xdn.fsf@gnu.org> From: Eli Zaretskii In-reply-to: <87tv9ir38c.fsf@mail.linkov.net> (message from Juri Linkov on Wed, 11 Sep 2019 23:24:03 +0300) References: <87tv9ir38c.fsf@mail.linkov.net> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Juri Linkov > Date: Wed, 11 Sep 2019 23:24:03 +0300 > > Configured using: > 'configure --with-x-toolkit=no --enable-checking=yes,glyphs > --enable-check-lisp-object-type 'CFLAGS=-O0 -g3'' > > These steps reproduce the crash in master: > > 0. emacs -Q > 1. Eval: (define-key global-map [menu-bar test] '("Test ⮿" keymap)) > 2. Visit an image file, e.g. etc/images/attach.pbm > > #0 0x00005555557a61b8 in terminate_due_to_signal (sig=6, backtrace_limit=2147483647) at emacs.c:374 > #1 0x00005555558c7555 in die (msg=0x555555ae73ee "SINGLE_BYTE_CHAR_P (c)", file=0x555555ae4790 "xdisp.c", line=7250) at alloc.c:7256 > #2 0x00005555555e9e56 in get_next_display_element (it=0x7fffffff89b0) at xdisp.c:7250 > #3 0x000055555562938c in display_string (string=0x0, lisp_string=XIL(0x5555567a0204), face_string=XIL(0), face_string_pos=0, start=0, it=0x7fffffff89b0, field_width=7, precision=0, max_x=674, multibyte=-1) at xdisp.c:25489 > [...] > An assertion violation is in get_next_display_element: > > if (! it->multibyte_p && ! ASCII_CHAR_P (c)) > { > eassert (SINGLE_BYTE_CHAR_P (c)); > > The menu item uses a multibyte char: > > c = 11199 (#o25677, #x2bbf, ?⮿) > > But init_iterator sets multibyte_p in the menu-bar window to the > value of enable-multibyte-characters in the current buffer where > enable-multibyte-characters is nil when an image file is visited in > image-mode: > > /* Are multibyte characters enabled in current_buffer? */ > it->multibyte_p = !NILP (BVAR (current_buffer, enable_multibyte_characters)); > > I tried the following fix and it prevents the crash: Thanks, but this is a backward-incompatible change on too low a level. It is a long-standing "convention" in Emacs that Lisp strings rendered as part of, or in relation to, unibyte buffers are assumed unibyte by default, and I don't want to change that -- who knows how many places in the code rely on this implicit assumption? Also, the change in reseat_1 looks unnecessary, as I'd be surprised if that function was called in your use case (reseat_1 is used only when displaying buffers, not strings). Please try an alternative patch below. (I don't have access to an X build without a toolkit, so I cannot test this myself.) Stepping a notch back, I cannot say I like this "non-ASCII art" implementation for tabs. It has two annoying problems: . it looks unprofessional on GUI frames . it requires you to determine whether the frame/font used for the menu can display this character, which is not easy Why not use an image of a plus sign on GUI frames, and a simple ASCII "+" on TTY frames and frames that have no image support? I think the result will be much better. Thanks. diff --git a/src/xdisp.c b/src/xdisp.c index 94f969f..d342da5 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -12994,7 +12994,8 @@ redisplay_tool_bar (struct frame *f) /* Build a string that represents the contents of the tool-bar. */ build_desired_tool_bar_string (f); - reseat_to_string (&it, NULL, f->desired_tool_bar_string, 0, 0, 0, -1); + reseat_to_string (&it, NULL, f->desired_tool_bar_string, + 0, 0, 0, STRING_MULTIBYTE (f->desired_tool_bar_string)); /* FIXME: This should be controlled by a user option. But it doesn't make sense to have an R2L tool bar if the menu bar cannot be drawn also R2L, and making the menu bar R2L is tricky due @@ -23531,7 +23532,7 @@ display_menu_bar (struct window *w) /* Display the item, pad with one space. */ if (it.current_x < it.last_visible_x) display_string (NULL, string, Qnil, 0, 0, &it, - SCHARS (string) + 1, 0, 0, -1); + SCHARS (string) + 1, 0, 0, STRING_MULTIBYTE (string)); } /* Fill out the line with spaces. */ From unknown Tue Jun 17 22:07:43 2025 X-Loop: help-debbugs@gnu.org Subject: bug#37385: 27.0.50; Crash on multibyte assertion violation Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 12 Sep 2019 21:54:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 37385 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: 37385@debbugs.gnu.org Received: via spool by 37385-submit@debbugs.gnu.org id=B37385.15683252321169 (code B ref 37385); Thu, 12 Sep 2019 21:54:02 +0000 Received: (at 37385) by debbugs.gnu.org; 12 Sep 2019 21:53:52 +0000 Received: from localhost ([127.0.0.1]:44168 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i8X2F-0000In-PT for submit@debbugs.gnu.org; Thu, 12 Sep 2019 17:53:52 -0400 Received: from cheetah.birch.relay.mailchannels.net ([23.83.209.34]:52798) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i8X2C-0000Id-Pa for 37385@debbugs.gnu.org; Thu, 12 Sep 2019 17:53:49 -0400 X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id A17496A265F; Thu, 12 Sep 2019 21:53:47 +0000 (UTC) Received: from pdx1-sub0-mail-a35.g.dreamhost.com (100-96-83-181.trex.outbound.svc.cluster.local [100.96.83.181]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 21D576A28CF; Thu, 12 Sep 2019 21:53:47 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Received: from pdx1-sub0-mail-a35.g.dreamhost.com ([TEMPUNAVAIL]. [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.17.5); Thu, 12 Sep 2019 21:53:47 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jurta@jurta.org X-MailChannels-Auth-Id: dreamhost X-Absorbed-Spill: 20a07272191c2498_1568325227399_673520395 X-MC-Loop-Signature: 1568325227399:3832254115 X-MC-Ingress-Time: 1568325227398 Received: from pdx1-sub0-mail-a35.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a35.g.dreamhost.com (Postfix) with ESMTP id 1805980911; Thu, 12 Sep 2019 14:53:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=linkov.net; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=linkov.net; bh=pVKAUmHXxYpu9bpuNHQVDiur0NM=; b= wbAxhVx/v3PlR1oD0K4ZJs/uNqpEtNP7OPKolntUZ1LbaXh+bIOb39F+KTWrz3V0 0nDTyupnEsZWPkv1RgBin9yDYBSSmh+JBK+Tg7/EjCawFp32heWPKa79mJSYdNvA e7SsI2cvrjByxhwvZ5+W3WqBrDdn7Mx1bc0Bzc+t+lE= Received: from mail.jurta.org (m91-129-108-240.cust.tele2.ee [91.129.108.240]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jurta@jurta.org) by pdx1-sub0-mail-a35.g.dreamhost.com (Postfix) with ESMTPSA id 98DA580917; Thu, 12 Sep 2019 14:53:41 -0700 (PDT) X-DH-BACKEND: pdx1-sub0-mail-a35 From: Juri Linkov Organization: LINKOV.NET References: <87tv9ir38c.fsf@mail.linkov.net> <83ftl11xdn.fsf@gnu.org> Date: Fri, 13 Sep 2019 00:30:11 +0300 In-Reply-To: <83ftl11xdn.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 12 Sep 2019 16:01:56 +0300") Message-ID: <87v9txmbfw.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: -100 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrtdeigddtfecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucggtfgfnhhsuhgsshgtrhhisggvpdfftffgtefojffquffvnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvffuohhfffgjkfgfgggtsehttdertddtredtnecuhfhrohhmpefluhhrihcunfhinhhkohhvuceojhhurhhisehlihhnkhhovhdrnhgvtheqnecukfhppeeluddruddvledruddtkedrvdegtdenucfrrghrrghmpehmohguvgepshhmthhppdhhvghlohepmhgrihhlrdhjuhhrthgrrdhorhhgpdhinhgvthepledurdduvdelrddutdekrddvgedtpdhrvghtuhhrnhdqphgrthhhpefluhhrihcunfhinhhkohhvuceojhhurhhisehlihhnkhhovhdrnhgvtheqpdhmrghilhhfrhhomhepjhhurhhisehlihhnkhhovhdrnhgvthdpnhhrtghpthhtohepvghlihiisehgnhhurdhorhhgnecuvehluhhsthgvrhfuihiivgeptd X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) >> I tried the following fix and it prevents the crash: > > Thanks, but this is a backward-incompatible change on too low a level. > It is a long-standing "convention" in Emacs that Lisp strings rendered > as part of, or in relation to, unibyte buffers are assumed unibyte by > default, and I don't want to change that -- who knows how many places > in the code rely on this implicit assumption? > > Also, the change in reseat_1 looks unnecessary, as I'd be surprised if > that function was called in your use case (reseat_1 is used only when > displaying buffers, not strings). > > Please try an alternative patch below. (I don't have access to an X > build without a toolkit, so I cannot test this myself.) Thanks for the proper fix. I tried and it works without problems. Also I found third place (in addition to two places in your patch) where STRING_MULTIBYTE could be used for reseat_to_string. Is the following change needed as well? diff --git a/src/xdisp.c b/src/xdisp.c index 9f999c7903..af6faf9d34 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -13804,7 +13812,8 @@ tool_bar_height (struct frame *f, int *n_rows, bool pixelwise) temp_row->reversed_p = false; it.first_visible_x = 0; it.last_visible_x = WINDOW_PIXEL_WIDTH (w); - reseat_to_string (&it, NULL, f->desired_tool_bar_string, 0, 0, 0, -1); + reseat_to_string (&it, NULL, f->desired_tool_bar_string, + 0, 0, 0, STRING_MULTIBYTE (f->desired_tool_bar_string)); it.paragraph_embedding = L2R; while (!ITERATOR_AT_END_P (&it)) From unknown Tue Jun 17 22:07:43 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Juri Linkov Subject: bug#37385: closed (Re: bug#37385: 27.0.50; Crash on multibyte assertion violation) Message-ID: References: <831rwk1vre.fsf@gnu.org> <87tv9ir38c.fsf@mail.linkov.net> X-Gnu-PR-Message: they-closed 37385 X-Gnu-PR-Package: emacs Reply-To: 37385@debbugs.gnu.org Date: Fri, 13 Sep 2019 07:50:03 +0000 Content-Type: multipart/mixed; boundary="----------=_1568361003-7418-1" This is a multi-part message in MIME format... ------------=_1568361003-7418-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #37385: 27.0.50; Crash on multibyte assertion violation which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 37385@debbugs.gnu.org. --=20 37385: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D37385 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1568361003-7418-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 37385-done) by debbugs.gnu.org; 13 Sep 2019 07:49:02 +0000 Received: from localhost ([127.0.0.1]:44291 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i8gKE-0001uR-AA for submit@debbugs.gnu.org; Fri, 13 Sep 2019 03:49:02 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58393) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i8gKD-0001ty-7h for 37385-done@debbugs.gnu.org; Fri, 13 Sep 2019 03:49:01 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:49022) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1i8gK7-0005uL-RX; Fri, 13 Sep 2019 03:48:55 -0400 Received: from [176.228.60.248] (port=3461 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1i8gK7-00034H-70; Fri, 13 Sep 2019 03:48:55 -0400 Date: Fri, 13 Sep 2019 10:49:09 +0300 Message-Id: <831rwk1vre.fsf@gnu.org> From: Eli Zaretskii To: Juri Linkov In-reply-to: <87v9txmbfw.fsf@mail.linkov.net> (message from Juri Linkov on Fri, 13 Sep 2019 00:30:11 +0300) Subject: Re: bug#37385: 27.0.50; Crash on multibyte assertion violation References: <87tv9ir38c.fsf@mail.linkov.net> <83ftl11xdn.fsf@gnu.org> <87v9txmbfw.fsf@mail.linkov.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 37385-done Cc: 37385-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Juri Linkov > Cc: 37385@debbugs.gnu.org > Date: Fri, 13 Sep 2019 00:30:11 +0300 > > Thanks for the proper fix. I tried and it works without problems. > Also I found third place (in addition to two places in your patch) > where STRING_MULTIBYTE could be used for reseat_to_string. Is the > following change needed as well? Yes, thanks. I installed all of them, and I'm closing this bug report. ------------=_1568361003-7418-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 11 Sep 2019 20:32:24 +0000 Received: from localhost ([127.0.0.1]:42801 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i89Hs-0001yP-47 for submit@debbugs.gnu.org; Wed, 11 Sep 2019 16:32:24 -0400 Received: from lists.gnu.org ([209.51.188.17]:60570) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i89Hq-0001yH-MK for submit@debbugs.gnu.org; Wed, 11 Sep 2019 16:32:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45651) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i89Ho-0003Vs-Qp for bug-gnu-emacs@gnu.org; Wed, 11 Sep 2019 16:32:22 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,RCVD_IN_DNSWL_NONE, URIBL_BLOCKED autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i89Hg-0003Z4-0f for bug-gnu-emacs@gnu.org; Wed, 11 Sep 2019 16:32:15 -0400 Received: from anteater.elm.relay.mailchannels.net ([23.83.212.3]:30115) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i89He-0003VJ-In for bug-gnu-emacs@gnu.org; Wed, 11 Sep 2019 16:32:11 -0400 X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id CC3C55E190D for ; Wed, 11 Sep 2019 20:32:02 +0000 (UTC) Received: from pdx1-sub0-mail-a53.g.dreamhost.com (100-96-91-237.trex.outbound.svc.cluster.local [100.96.91.237]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 4A86B5E1CA9 for ; Wed, 11 Sep 2019 20:32:02 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Received: from pdx1-sub0-mail-a53.g.dreamhost.com ([TEMPUNAVAIL]. [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.17.5); Wed, 11 Sep 2019 20:32:02 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jurta@jurta.org X-MailChannels-Auth-Id: dreamhost X-Troubled-Wide-Eyed: 38a9bdeb4e63ccf7_1568233922532_4207892381 X-MC-Loop-Signature: 1568233922532:2106337843 X-MC-Ingress-Time: 1568233922531 Received: from pdx1-sub0-mail-a53.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a53.g.dreamhost.com (Postfix) with ESMTP id EAC39837A6 for ; Wed, 11 Sep 2019 13:31:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=linkov.net; h=from:to :subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=linkov.net; bh=dhIJP/ycg0QfgHXADPf iADruANU=; b=V67PSIt9J5HUS237h5HNOw3N8WI3sOiROSuZyw7SuIXfXyj+TQ1 WviGGP8GOdvR2eB7uPKMtHjEPBd5PPtd3J16a3NKyf/DFPytWuxK1U9upZMX/fC1 uSVSRKhi1wzk2Vdx7+LBJQ2ODNVNriFhYsVjMV3FhB7q4OYKeRkRc0qA= Received: from mail.jurta.org (m91-129-108-240.cust.tele2.ee [91.129.108.240]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jurta@jurta.org) by pdx1-sub0-mail-a53.g.dreamhost.com (Postfix) with ESMTPSA id B9487837AB for ; Wed, 11 Sep 2019 13:31:57 -0700 (PDT) X-DH-BACKEND: pdx1-sub0-mail-a53 From: Juri Linkov To: bug-gnu-emacs@gnu.org Subject: 27.0.50; Crash on multibyte assertion violation Organization: LINKOV.NET Date: Wed, 11 Sep 2019 23:24:03 +0300 Message-ID: <87tv9ir38c.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: 0 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrtdefgdduvdegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgdpffftgfetoffjqffuvfenuceurghilhhouhhtmecufedttdenucenucfjughrpefhvffuohffkfgfgggtgfesthekredttderjeenucfhrhhomheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqeenucfkphepledurdduvdelrddutdekrddvgedtnecurfgrrhgrmhepmhhouggvpehsmhhtphdphhgvlhhopehmrghilhdrjhhurhhtrgdrohhrghdpihhnvghtpeeluddruddvledruddtkedrvdegtddprhgvthhurhhnqdhprghthheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqedpmhgrihhlfhhrohhmpehjuhhriheslhhinhhkohhvrdhnvghtpdhnrhgtphhtthhopegsuhhgqdhgnhhuqdgvmhgrtghssehgnhhurdhorhhgnecuvehluhhsthgvrhfuihiivgeptd Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 23.83.212.3 X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) Testing the tabs branch helped to expose a bug in master: In GNU Emacs 27.0.50 (build 6, x86_64-pc-linux-gnu) of 2019-09-11 built on localhost Repository revision: 4d90fadf27ccbb98e0e174304cb4e3008bf364fc Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.1190600= 0 System Description: Linux Mint 19.1 Configured using: 'configure --with-x-toolkit=3Dno --enable-checking=3Dyes,glyphs --enable-check-lisp-object-type 'CFLAGS=3D-O0 -g3'' These steps reproduce the crash in master: 0. emacs -Q 1. Eval: (define-key global-map [menu-bar test] '("Test =E2=AE=BF" keymap= )) 2. Visit an image file, e.g. etc/images/attach.pbm #0 0x00005555557a61b8 in terminate_due_to_signal (sig=3D6, backtrace_lim= it=3D2147483647) at emacs.c:374 #1 0x00005555558c7555 in die (msg=3D0x555555ae73ee "SINGLE_BYTE_CHAR_P (= c)", file=3D0x555555ae4790 "xdisp.c", line=3D7250) at alloc.c:7256 #2 0x00005555555e9e56 in get_next_display_element (it=3D0x7fffffff89b0) = at xdisp.c:7250 #3 0x000055555562938c in display_string (string=3D0x0, lisp_string=3DXIL= (0x5555567a0204), face_string=3DXIL(0), face_string_pos=3D0, start=3D0, i= t=3D0x7fffffff89b0, field_width=3D7, precision=3D0, max_x=3D674, multibyt= e=3D-1) at xdisp.c:25489 #4 0x00005555556239db in display_menu_bar (w=3D0x5555565cae40) at xdisp.= c:23533 #5 0x000055555560d61e in redisplay_window (window=3DXIL(0x5555565cae45),= just_this_one_p=3Dfalse) at xdisp.c:17821 #6 0x0000555555603b79 in redisplay_window_0 (window=3DXIL(0x5555565cae45= )) at xdisp.c:15116 #7 0x0000555555921b23 in internal_condition_case_1 (bfun=3D0x555555603b3= 7 , arg=3DXIL(0x5555565cae45), handlers=3DXIL(0x7fffe= 995aad3), hfun=3D0x555555603aff ) at eval.c:1379 #8 0x0000555555603ad1 in redisplay_windows (window=3DXIL(0x5555565cae45)= ) at xdisp.c:15096 #9 0x00005555556024c2 in redisplay_internal () at xdisp.c:14579 #10 0x00005555555ffea3 in redisplay () at xdisp.c:13806 #11 0x00005555557b7948 in read_char (commandflag=3D1, map=3DXIL(0x555556a= 2aba3), prev_event=3DXIL(0), used_mouse_menu=3D0x7fffffffdd25, end_time=3D= 0x0) at keyboard.c:2472 #12 0x00005555557c930f in read_key_sequence (keybuf=3D0x7fffffffdf10, pro= mpt=3DXIL(0), dont_downcase_last=3Dfalse, can_return_switch_frame=3Dtrue,= fix_current_buffer=3Dtrue, prevent_redisplay=3Dfalse) at keyboard.c:9125 #13 0x00005555557b3d8b in command_loop_1 () at keyboard.c:1345 #14 0x0000555555921a48 in internal_condition_case (bfun=3D0x5555557b390d = , handlers=3DXIL(0x90), hfun=3D0x5555557b2ed7 = ) at eval.c:1355 #15 0x00005555557b34f4 in command_loop_2 (ignore=3DXIL(0)) at keyboard.c:= 1091 #16 0x0000555555920ea2 in internal_catch (tag=3DXIL(0xcdb0), func=3D0x555= 5557b34c7 , arg=3DXIL(0)) at eval.c:1116 #17 0x00005555557b3492 in command_loop () at keyboard.c:1070 #18 0x00005555557b29be in recursive_edit_1 () at keyboard.c:714 #19 0x00005555557b2bb6 in Frecursive_edit () at keyboard.c:786 #20 0x00005555557a8acc in main (argc=3D3, argv=3D0x7fffffffe368) at emacs= .c:2086 An assertion violation is in get_next_display_element: if (! it->multibyte_p && ! ASCII_CHAR_P (c)) { eassert (SINGLE_BYTE_CHAR_P (c)); The menu item uses a multibyte char: c =3D 11199 (#o25677, #x2bbf, ?=E2=AE=BF) But init_iterator sets multibyte_p in the menu-bar window to the value of enable-multibyte-characters in the current buffer where enable-multibyte-characters is nil when an image file is visited in image-mode: /* Are multibyte characters enabled in current_buffer? */ it->multibyte_p =3D !NILP (BVAR (current_buffer, enable_multibyte_chara= cters)); I tried the following fix and it prevents the crash: diff --git a/src/xdisp.c b/src/xdisp.c index 94f969f37c..5730145268 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -2984,7 +2984,9 @@ init_iterator (struct it *it, struct window *w, it->dp =3D window_display_table (w); =20 /* Are multibyte characters enabled in current_buffer? */ - it->multibyte_p =3D !NILP (BVAR (current_buffer, enable_multibyte_char= acters)); + it->multibyte_p =3D WINDOW_MENU_BAR_P (w) + || WINDOW_TOOL_BAR_P (w) + || !NILP (BVAR (current_buffer, enable_multibyte_characters)); =20 /* Get the position at which the redisplay_end_trigger hook should be run, if it is to be run at all. */ @@ -6864,7 +6866,9 @@ reseat_1 (struct it *it, struct text_pos pos, bool = set_stop_p) it->method =3D GET_FROM_BUFFER; it->object =3D it->w->contents; it->area =3D TEXT_AREA; - it->multibyte_p =3D !NILP (BVAR (current_buffer, enable_multibyte_char= acters)); + it->multibyte_p =3D WINDOW_MENU_BAR_P (it->w) + || WINDOW_TOOL_BAR_P (it->w) + || !NILP (BVAR (current_buffer, enable_multibyte_characters)); it->sp =3D 0; it->string_from_display_prop_p =3D false; it->string_from_prefix_prop_p =3D false; ------------=_1568361003-7418-1--