GNU bug report logs - #77233
31.0.50; crash if message starts with a space and then without it

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Daniel Clemente <n142857@HIDDEN>; Done: Gerd Möllmann <gerd.moellmann@HIDDEN>; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
bug marked as fixed in version 31.1, send any further explanations to 77233 <at> debbugs.gnu.org and Daniel Clemente <n142857@HIDDEN> Request was from Gerd Möllmann <gerd.moellmann@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 77233 <at> debbugs.gnu.org:


Received: (at 77233) by debbugs.gnu.org; 27 Mar 2025 17:16:39 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 27 13:16:39 2025
Received: from localhost ([127.0.0.1]:51161 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1txqqM-0007lH-Go
	for submit <at> debbugs.gnu.org; Thu, 27 Mar 2025 13:16:39 -0400
Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:46463)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <gerd.moellmann@HIDDEN>)
 id 1txqqI-0007ka-PG
 for 77233 <at> debbugs.gnu.org; Thu, 27 Mar 2025 13:16:35 -0400
Received: by mail-wm1-x329.google.com with SMTP id
 5b1f17b1804b1-43bb6b0b898so13440045e9.1
 for <77233 <at> debbugs.gnu.org>; Thu, 27 Mar 2025 10:16:34 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1743095788; x=1743700588; darn=debbugs.gnu.org;
 h=mime-version:user-agent:message-id:date:references:in-reply-to
 :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to;
 bh=RbqSX+SZ4Te1WgskSi606v5k5FTdakphKlu7Mi9ofYw=;
 b=ClsDWK6ZiHdi74hQKDfjyWRz+2CbNqsc1NINyt1iy5oaSJ6xSrjPfRHLWJR/NKc00k
 55oYeRLr8xHyRDgNYKrOV2SH+Wnv/qh+uYqkdfSlbqv6MkU6cG8XQaRcCSn+5buJ8jqb
 o9xBNkCuHI9HAmJIhzNxE5qxwmVW2NT6815tc/eW/EBD+xQfVKlvBz3/G0/Um+Lpv/j/
 WMXwAiH8AKcOvlZuXd9NIYHK1jFZzUFIniYEWcCSvARRKgPLjdNxwW9gyvaOec2S9stn
 WIJxUj8VitbdOs0c1Jvtb4ZFR4WUYUj/xcou00s2trvPCVXbLfLHO62t3R3VwHEr8RwB
 KzBg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1743095788; x=1743700588;
 h=mime-version:user-agent:message-id:date:references:in-reply-to
 :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date
 :message-id:reply-to;
 bh=RbqSX+SZ4Te1WgskSi606v5k5FTdakphKlu7Mi9ofYw=;
 b=qvc84Vc4/f6L+jVcahlOk5jQtn8hRmTG6APQj96eV3xAYW7SQwpJ3LmGw4+2rX6l2M
 vhvEhi6nfecmCkqnecjClxRvWbKzHfnwLmCS5mS6zIPmWKk+byVYAdENHFkQTrMJ5+XX
 ZNEJAK98SX2j+pNfpfctSYojYlMhtFYNvH/nXTo1DID04vfn5H2YwJX87G/c0IbIXZC3
 3IWOlubh4crEJaKaveu23+ZHKKVAUfs39l23dfJ9O4oe2vmOmA2eBOm28E1qOkMAW+pG
 iI4Eh+X8E8fxO5ys6NklIqlmvH4UGgavXU8GdvHdSv716CHWoggsmZtv0iHKt0wTRit3
 htoA==
X-Forwarded-Encrypted: i=1;
 AJvYcCXMAwBZPRIMuazkA+jGF/MCnASUddBnoKYIKUyc8x7Kju631vutzRVeMbIuwIz5QJWdJpI6uw==@debbugs.gnu.org
X-Gm-Message-State: AOJu0Yz1a1eRbhxOPH+TcA1xvQ+SEbc7CowjDPSi9gCxSnfanF/wYN+o
 tSLm5pd6NI5LW/2LhV3YW+fTXiluXGlO8qor3gzy1/KyNJj/FniHQ2BzxA==
X-Gm-Gg: ASbGncsJUpdnPUYshd5X6/RZzBHtP+P9OW0wj57kONhc8YguCyW2it2UTITyr1pL1UH
 gsr7rPBc9itX3YqkFjKvcLR8Xg8un1bgbFdAhpl6tE/KhDLaeJBZpjQB0gdyaVrmXO1yQk73jJN
 1HHrHxBpx2AJYsHx54w3UIlyy2AL6JT8T5+WQbz/Hih7MJa1mQBwfe2Zwadx1xsbDMtg2iMl1Yv
 kQlgtLmR1SIvCJNEp6+DzITBbmKt0WoKkd8ZaD9dp7DWULBmU7P/n6q8Jv+qhhMpPaYwI52JAmJ
 VhVFvuoWWukI8QpyqylPjI0n4RO84Ah4hrlinaG2zSS+OkhOCXjJC+JBnweXbEDCGZ/lh+EdfLa
 UgaYwWcDykYiXoAJfNsz89l0WNl9dEeN0DuAjzRrT3w5rp8MbqJyNyg==
X-Google-Smtp-Source: AGHT+IHraerektpqlc/Ber4Z9OB+5IE06vaU/tmNCS10ebvahuHGCP3l727RiSuLWfjSfLtgOxx8fA==
X-Received: by 2002:a05:600c:444c:b0:43c:ed61:2c26 with SMTP id
 5b1f17b1804b1-43d84fb27a7mr41958935e9.17.1743095787934; 
 Thu, 27 Mar 2025 10:16:27 -0700 (PDT)
Received: from pro2 (p200300e0b7076c003c477b84fae44a32.dip0.t-ipconnect.de.
 [2003:e0:b707:6c00:3c47:7b84:fae4:4a32])
 by smtp.gmail.com with ESMTPSA id
 5b1f17b1804b1-43d8ff042c8sm882665e9.27.2025.03.27.10.16.26
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 27 Mar 2025 10:16:26 -0700 (PDT)
From: =?utf-8?Q?Gerd_M=C3=B6llmann?= <gerd.moellmann@HIDDEN>
To: Daniel Clemente <n142857@HIDDEN>
Subject: Re: bug#77233: 31.0.50; crash if message starts with a space and
 then without it
In-Reply-To: <CAJKAhPAORTS5WqdT8N-HQQ1p+BiEcsoBSnDnXD0XNdSUR+mH3Q@HIDDEN>
References: <CAJKAhPCBJUoxuK-9HSBfyvstsJE3n4YJUSY-EMav_75DUYcFGQ@HIDDEN>
 <867c4efuyx.fsf@HIDDEN> <87jz8eectq.fsf@HIDDEN>
 <86zfhae1e5.fsf@HIDDEN> <m2pli65jkq.fsf@HIDDEN>
 <8734f2dyh3.fsf@HIDDEN>
 <CAJKAhPBYdLFc6zajj4GjF1QYBRGcPoF=v-68eJbEDe4Lp4k_hg@HIDDEN>
 <m24izf12ds.fsf@HIDDEN>
 <CAJKAhPAORTS5WqdT8N-HQQ1p+BiEcsoBSnDnXD0XNdSUR+mH3Q@HIDDEN>
Date: Thu, 27 Mar 2025 18:16:25 +0100
Message-ID: <m2v7rumm1i.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77233
Cc: 77233 <at> debbugs.gnu.org, Pip Cet <pipcet@HIDDEN>,
 Eli Zaretskii <eliz@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Daniel Clemente <n142857@HIDDEN> writes:

>> Anyway. Since nobody complained about my patch while I was away, I've
>> pushed something like that now. Could you please give it a try, Daniel?
>
> It's fixed now, and I can't reproduce the crash in any of the terminal
> emulators mentioned. I tried:
> - with zone-pgm-stress (or others)
> - running zone, while resizing the terminal emulator
> - with very small window sizes
> - with other messages (e.g. garbage-collection-messages) are appearing
> while zone-pgm-stress runs
>
> Editing and everything else works normally.
>
> So thanks!, and I think the bug can be closed.

Thanks for testing. And closing.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#77233; Package emacs. Full text available.

Message received at 77233 <at> debbugs.gnu.org:


Received: (at 77233) by debbugs.gnu.org; 27 Mar 2025 17:10:10 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 27 13:10:10 2025
Received: from localhost ([127.0.0.1]:51130 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1txqk6-00072e-3h
	for submit <at> debbugs.gnu.org; Thu, 27 Mar 2025 13:10:10 -0400
Received: from mail-vk1-xa2e.google.com ([2607:f8b0:4864:20::a2e]:57351)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <n142857@HIDDEN>) id 1txqk2-00071W-Tk
 for 77233 <at> debbugs.gnu.org; Thu, 27 Mar 2025 13:10:07 -0400
Received: by mail-vk1-xa2e.google.com with SMTP id
 71dfb90a1353d-524125f6cadso1200718e0c.2
 for <77233 <at> debbugs.gnu.org>; Thu, 27 Mar 2025 10:10:06 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1743095401; x=1743700201; darn=debbugs.gnu.org;
 h=cc:to:subject:message-id:date:from:in-reply-to:references
 :mime-version:from:to:cc:subject:date:message-id:reply-to;
 bh=KfCL6xrzdRS5gBLDdeWe6Vgl+VGNidLagWz9gMQpTwg=;
 b=aOfcNmuyQ0YBigMMbpluWZEXq8x/O7D1RMKILPQH4dXQyEnHNIHsxau8MBDPIeAvMA
 s25JcAXX66Wd+dHBvdX73kgZECkEJabfXz2+qPJWWJCYhiI6J+/SFfmGUhkSyF3i2NJ5
 s+kU0pwoQsrs0AO9eIlCdqA7doDNvf05bh1ZCe2ftz+SqOtMPldwxrmNMF0Amem0hXSN
 b0uLGSLtyq18hswNwkrXaXyiqo4qc1n++mdMnn/g5jOlyZA0/qy67FBiDFmyIrRiq0eY
 PnkQtn27NV7Qkct/Y7Jul2nBL5AhDV7y/xzNRbEOy8+dsa91bs82nVkHRdiwhQe1aTfh
 v6+Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1743095401; x=1743700201;
 h=cc:to:subject:message-id:date:from:in-reply-to:references
 :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id
 :reply-to;
 bh=KfCL6xrzdRS5gBLDdeWe6Vgl+VGNidLagWz9gMQpTwg=;
 b=oeqSPeo9ErMkvpkyhCqfedAxKSZNpRDqYaUECGkU/Zel/yacb0HKGOG6tVRrcR9yS4
 vWmvJXiry4N/OQi87+89HO3HcalIUM7sjAP1qN8ViCpIRw+Z8MwIcY6MdyPoEebAqdvd
 2KhyXAyb+1hntpmBvHo/4M3R+hyeHnCq/kY/1fWnENGDx7Yi5MaadI5PKL60e6ZsgfkP
 ZMbKPnUVyffcwD3Zzcj0DY6z6iqkd57/IOTGO4lSunk045XhyBdrp/B2uw3xhf84VRU4
 VO9NiZtPgWxC4CXvvbm5WdsLIFw4uRb2doB8NjI9Ih2Tw27hYRMHvkS1i2vXS/ZPmcXb
 TYSw==
X-Forwarded-Encrypted: i=1;
 AJvYcCVXHEAi8CNaVGF8qYfHVWV/O+xgIR0R/VOrGrAsxBZJSGoGa/rnhbNit4asQ+xs3Gm94u+jcw==@debbugs.gnu.org
X-Gm-Message-State: AOJu0YyLvI/NX7yHrK90UGDJe9awtZU0hUtn2dVlKYQfkSYrfYnispLV
 sv8fxd/bki5HdhkQi159PI9qNXaWHqOjheylW7g47CpSLuqgfbzsahBvFlY8C2tBf6CYAetncYa
 15nkpQZFIlzMRVyTxvwULTTC2s7c=
X-Gm-Gg: ASbGncs0tz3d7Ugdgo5KkIsYNx+r1C4w+y+v+YITCNUMAvaiUgNNXJDQMyP0zj0aNED
 YUPwx+WkHfGsPCoj64rYBtQocvJ9Z9gMaLUoubRZr2COtuzLEBj7tj1N4UdOhujHg/Q9Gzy9bH0
 C6Ltjkq657rKFl8L4QL+Lj/EeaFg==
X-Google-Smtp-Source: AGHT+IEXPiaMoJ8btIZEpkkm2JKTeIpbK0eUjSZDxJFJhUCVeOpcsV48Rgdw8Jt7tdLovbXdr75Jfeqc0eVnaw5NKzE=
X-Received: by 2002:a05:6122:6144:b0:520:5a87:66f0 with SMTP id
 71dfb90a1353d-526006ed183mr4019837e0c.0.1743095400857; Thu, 27 Mar 2025
 10:10:00 -0700 (PDT)
MIME-Version: 1.0
References: <CAJKAhPCBJUoxuK-9HSBfyvstsJE3n4YJUSY-EMav_75DUYcFGQ@HIDDEN>
 <867c4efuyx.fsf@HIDDEN> <87jz8eectq.fsf@HIDDEN>
 <86zfhae1e5.fsf@HIDDEN>
 <m2pli65jkq.fsf@HIDDEN> <8734f2dyh3.fsf@HIDDEN>
 <CAJKAhPBYdLFc6zajj4GjF1QYBRGcPoF=v-68eJbEDe4Lp4k_hg@HIDDEN>
 <m24izf12ds.fsf@HIDDEN>
In-Reply-To: <m24izf12ds.fsf@HIDDEN>
From: Daniel Clemente <n142857@HIDDEN>
Date: Thu, 27 Mar 2025 17:09:31 +0000
X-Gm-Features: AQ5f1JoMIw_HG2DGC1G6FcU4uhEJFHReKOOrFvkHXBDJbFF0FHlslVJ4dp24d-4
Message-ID: <CAJKAhPAORTS5WqdT8N-HQQ1p+BiEcsoBSnDnXD0XNdSUR+mH3Q@HIDDEN>
Subject: Re: bug#77233: 31.0.50; crash if message starts with a space and then
 without it
To: =?UTF-8?Q?Gerd_M=C3=B6llmann?= <gerd.moellmann@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
X-Spam-Score: 0.3 (/)
X-Debbugs-Envelope-To: 77233
Cc: 77233 <at> debbugs.gnu.org, Pip Cet <pipcet@HIDDEN>,
 Eli Zaretskii <eliz@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

> Anyway. Since nobody complained about my patch while I was away, I've
> pushed something like that now. Could you please give it a try, Daniel?

It's fixed now, and I can't reproduce the crash in any of the terminal
emulators mentioned. I tried:
- with zone-pgm-stress (or others)
- running zone, while resizing the terminal emulator
- with very small window sizes
- with other messages (e.g. garbage-collection-messages) are appearing
while zone-pgm-stress runs

Editing and everything else works normally.

So thanks!, and I think the bug can be closed.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#77233; Package emacs. Full text available.

Message received at 77233 <at> debbugs.gnu.org:


Received: (at 77233) by debbugs.gnu.org; 27 Mar 2025 05:14:38 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 27 01:14:38 2025
Received: from localhost ([127.0.0.1]:46493 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1txfZd-0001Kj-0t
	for submit <at> debbugs.gnu.org; Thu, 27 Mar 2025 01:14:38 -0400
Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]:53634)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <gerd.moellmann@HIDDEN>)
 id 1txfZX-0001J4-W9
 for 77233 <at> debbugs.gnu.org; Thu, 27 Mar 2025 01:14:33 -0400
Received: by mail-wm1-x336.google.com with SMTP id
 5b1f17b1804b1-43cfba466b2so5049695e9.3
 for <77233 <at> debbugs.gnu.org>; Wed, 26 Mar 2025 22:14:31 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1743052465; x=1743657265; darn=debbugs.gnu.org;
 h=content-transfer-encoding:mime-version:user-agent:message-id:date
 :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=b0j09neCJoWDqzEIcUvNiBI7FejhMi45T2WhtQ3/BbI=;
 b=YfDoazEyz3ol8d49JL07zfrocek+xXUT8MyWBWR3dcFGdlIcxoStMnQQADFSVjbn+O
 C19vNTR1ajiPx3vCnmi9nlNd9xnNeEXh0d2fPc1C4mrppmlUT8mFMA3P6xjzEERX++Q1
 dE+V6A9Djxs8Q7Rw9scE2iGraUxs0M9K5FTJ5mNjaRc0TeZa2YlU0EL9xpt+lsA/5wXR
 LJdRBLfPJHXbuOHQ/0rhNkF4FuywUUo5oCujSF0yePkmB7zHtM0ZyQW1THwIPQkOZTgN
 2gXOys3EV3kAHg/bHAWcsVck5PejNBAjcWqDLKHJ+TALFb2gMMWGrAvaop6GtjAyzamh
 f/LQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1743052465; x=1743657265;
 h=content-transfer-encoding:mime-version:user-agent:message-id:date
 :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from
 :to:cc:subject:date:message-id:reply-to;
 bh=b0j09neCJoWDqzEIcUvNiBI7FejhMi45T2WhtQ3/BbI=;
 b=vxgtqGgrNAlI/Z2TjApeKgApSLRchROfyPAwWcQPFLq+Xw6iBLESV+355XvH+I81Zq
 LSIy0c7naTY9/R4sssDRhq8dxRY/wT4Pj/olDetWtHyq25h8C5gmy8uvFiNwl4AsEZGC
 d8WLwvSC4sjWsqq6WncCwSL4VxfsYxeBVbhR9C2APC2nZuVx0BMBO/i9LjfIXLUhzUoz
 QIifmXChlVFIo7p/DEU7/+flo0ZSHoLo0W734FS8KSoAgCLbmQn3sMcjNgyKGM7+6oDG
 CLmGC/KVN+GwgqoCrKb1wDVcON9ml2PNIzX0wnUChh9JODAH8OX5168q0xrCsgG2rbt1
 /0pw==
X-Forwarded-Encrypted: i=1;
 AJvYcCVy+/hdwrZ4mWKr4rTBE0Z/D/nBZn167fBiaXVBtZ+RZgl0kcmQ3YXA3tlTRmRZBhEL9C4A1Q==@debbugs.gnu.org
X-Gm-Message-State: AOJu0YyzAvuAClSCda/GXRYWJgWGjSX9PeqKWhf3z/IFS+JvVuUmBLCB
 dLrDv+vJqr/MMdFlrGXkcZGNQhRkxMjl+TBt+z7SzaCeas3QgUY3CMLP2Q==
X-Gm-Gg: ASbGnctwFkBejh7Xm9sn8QwVsmO8HgJ105dv31aTq0k0d88KRabkIVNoHx5YPdXjAes
 Nz0BvJQdf1B3U7qkFl2zc0BIdh6YZthBEW62bREWBL1ikB7VdOONgBbAwKRqpBSHvn4Kr0CWPbI
 Nz/RIi17ZS/Ch7a2YxkFs9D8nbgGBfsrHegjQvgGeYod7WLh/kZoUbLEPM8p5CRwG88BFIuiTvn
 O2tt30ooqMwc9aZcmY1r/lGW4PVfyECLv0NPpLBBuGR6bHTUFqew8Qv1Tgb+7qkarCL84yCHgjn
 I0U1oiCAacrAiVd0a9Wz3Nc6uySSTprmclaiCm0Kr5THPk5zvLX2B4w9MK/X4A+8xwN2KzxmTV+
 9xRNvopBT6p6oXCFqEim+ZVj9rBnWW5GJStMdr/s0/xKBXQW2
X-Google-Smtp-Source: AGHT+IEU9b39zCCYDSGZ1dbWax/OiHrJFJADvcM4EohBmkFJteZUtCE/DezxF+GMqGCatyrID8g5zA==
X-Received: by 2002:a05:600c:1e1d:b0:43c:fffc:7855 with SMTP id
 5b1f17b1804b1-43d84fb6384mr17116935e9.15.1743052465319; 
 Wed, 26 Mar 2025 22:14:25 -0700 (PDT)
Received: from pro2 (p200300e0b7076c009105bebb99c19f6c.dip0.t-ipconnect.de.
 [2003:e0:b707:6c00:9105:bebb:99c1:9f6c])
 by smtp.gmail.com with ESMTPSA id
 ffacd0b85a97d-3997f9a31a7sm18436306f8f.23.2025.03.26.22.14.24
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Wed, 26 Mar 2025 22:14:24 -0700 (PDT)
From: =?utf-8?Q?Gerd_M=C3=B6llmann?= <gerd.moellmann@HIDDEN>
To: Daniel Clemente <n142857@HIDDEN>
Subject: Re: bug#77233: 31.0.50; crash if message starts with a space and
 then without it
In-Reply-To: <CAJKAhPBYdLFc6zajj4GjF1QYBRGcPoF=v-68eJbEDe4Lp4k_hg@HIDDEN>
References: <CAJKAhPCBJUoxuK-9HSBfyvstsJE3n4YJUSY-EMav_75DUYcFGQ@HIDDEN>
 <867c4efuyx.fsf@HIDDEN> <87jz8eectq.fsf@HIDDEN>
 <86zfhae1e5.fsf@HIDDEN> <m2pli65jkq.fsf@HIDDEN>
 <8734f2dyh3.fsf@HIDDEN>
 <CAJKAhPBYdLFc6zajj4GjF1QYBRGcPoF=v-68eJbEDe4Lp4k_hg@HIDDEN>
Date: Thu, 27 Mar 2025 06:14:23 +0100
Message-ID: <m24izf12ds.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77233
Cc: 77233 <at> debbugs.gnu.org, Pip Cet <pipcet@HIDDEN>,
 Eli Zaretskii <eliz@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Daniel Clemente <n142857@HIDDEN> writes:

> On first thought it seems safer to avoid printing at (cols-1, rows-1)
> when we know that AutoWrap is enabled=E2=80=A6

I agree. That auto-wrap code is there since the very beginning, added to
Emacs 1985, derived from public domain code which is even older of
course (VT100 is from the mid 70s). Of course it would be nice if the
code could be "modernized", but who's gone do that, realistically?

Anyway. Since nobody complained about my patch while I was away, I've
pushed something like that now. Could you please give it a try, Daniel?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#77233; Package emacs. Full text available.

Message received at 77233 <at> debbugs.gnu.org:


Received: (at 77233) by debbugs.gnu.org; 26 Mar 2025 14:24:58 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 26 10:24:58 2025
Received: from localhost ([127.0.0.1]:43787 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1txRgf-00076B-5G
	for submit <at> debbugs.gnu.org; Wed, 26 Mar 2025 10:24:57 -0400
Received: from mail-vk1-xa31.google.com ([2607:f8b0:4864:20::a31]:55677)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <n142857@HIDDEN>) id 1txRgM-000749-IG
 for 77233 <at> debbugs.gnu.org; Wed, 26 Mar 2025 10:24:39 -0400
Received: by mail-vk1-xa31.google.com with SMTP id
 71dfb90a1353d-51eb1823a8eso3230423e0c.3
 for <77233 <at> debbugs.gnu.org>; Wed, 26 Mar 2025 07:24:38 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1742999072; x=1743603872; darn=debbugs.gnu.org;
 h=cc:to:subject:message-id:date:from:in-reply-to:references
 :mime-version:from:to:cc:subject:date:message-id:reply-to;
 bh=Td1143aFK2cFV3owSJ4OCNQm03rETL8pouBc+GDeogg=;
 b=d0PwLTPzivN4Nf6K+DonLO6p/I5vwgBthHhHHBw1AjMVpJPgwVT4j7zWVg5dwMsOMq
 3HxbQ+MIKVkKaYTXXCnGnLwpnxxGdZQkiYWwV1eT7FsG75RILL4DxdvaJWZ0WQAj4cAA
 FhRzsGgWeOPc0eSNVbxY7WtkWO05Exba3QUF4ird1Pgbm/gamR2YhnrI1Wcokqw4obLH
 MbxcvI2Fwly+sQf47Mq75YLt4YwEzI2mgCmaFcYXjb5hj4rcuzvdm1csvNdufaqqhfRq
 ABUZwSa/lNj03hXgqEVcD6Dpl+dzxaT37GT7FmotlF31ZXGbCpMEd1DoTIg3t3Xqyqo3
 D0HA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1742999072; x=1743603872;
 h=cc:to:subject:message-id:date:from:in-reply-to:references
 :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id
 :reply-to;
 bh=Td1143aFK2cFV3owSJ4OCNQm03rETL8pouBc+GDeogg=;
 b=OxiC76j52EoRPUTygiGo9xcVIXoOhs53W+kI34fxVVeUAklmtBJ9YJZ2+MKO0ZXGjR
 7O1ncWMOFNnhDoiQKy7BnK/h7Lx47HmbtjTZnu3kyVPbAbi1kxXjkqVBxXBX27fvOtHM
 +RLMGgJcA199xwLXDH1Sfkoztnv1VFiwj3q588jFaLoxKr++PJjgSeSRnY8O0Cktl795
 FLgH/Xr1IpSkmYHO6EvmScQOKIH0orhvT57rAlbGlnIkp5znzqJH4g3SgfCBGcc8ZcG8
 47K1neQm3+EZaWQySCnkzT/XyXZH++u5JGbYjlghl/YXZV5EEZttqF7KSWFPUGcsKlFA
 ILXg==
X-Forwarded-Encrypted: i=1;
 AJvYcCWNO/A8HM9nNgDQNcQtACWaYEbCV3sdFEE+BAueGrH+cvAPk4j8Edho/zoQ7vgmaT20vayPlg==@debbugs.gnu.org
X-Gm-Message-State: AOJu0YzIwNUNOKb7UyvtVzfmFRdc1fjD0Zy5P3Dvuhq0dZe7cgRIWeHh
 EW19dv1XU27P5BvKnfmacf+yR3rlk10IPejFSofhO81H2dmo0DY+E2isxkoupMlwL5GlwFASU60
 RZMT5iUZx0A6BpRYciF0VB9RIDsA=
X-Gm-Gg: ASbGncsJgeX63Noh7bj+RjBnUJSBXIkWy6/zZtXVv1Z/FILXHUXiQrOCIWs92YhcSrG
 KfI8XELDjBzNbfHQsvK4RM+3YTHdojN7lJpHwljndM+PBWwkNSUnMcp6F3a40LDryfvEXnh2weR
 PqhjfButPMFA4jUJDpxsN0sJUxWVZt4Km3cL8=
X-Google-Smtp-Source: AGHT+IHDV1YhOrMmIfkNwsU9/CzB6Y7Xv/9ViAyTWaZZ8Mb7yqVfNQeLNBqgq9Ec/zcR3cW1/D44F8g20ngXNcOj0/U=
X-Received: by 2002:a05:6122:3306:b0:50a:c70b:9453 with SMTP id
 71dfb90a1353d-525a854124cmr14430648e0c.10.1742999071747; Wed, 26 Mar 2025
 07:24:31 -0700 (PDT)
MIME-Version: 1.0
References: <CAJKAhPCBJUoxuK-9HSBfyvstsJE3n4YJUSY-EMav_75DUYcFGQ@HIDDEN>
 <867c4efuyx.fsf@HIDDEN> <87jz8eectq.fsf@HIDDEN>
 <86zfhae1e5.fsf@HIDDEN>
 <m2pli65jkq.fsf@HIDDEN> <8734f2dyh3.fsf@HIDDEN>
In-Reply-To: <8734f2dyh3.fsf@HIDDEN>
From: Daniel Clemente <n142857@HIDDEN>
Date: Wed, 26 Mar 2025 14:24:04 +0000
X-Gm-Features: AQ5f1Jo_uo0NcbSNJ3mlV9hpaxXtuf_8cNTdPKpCc1JUuz6NGe9RlT0ZCupSGWk
Message-ID: <CAJKAhPBYdLFc6zajj4GjF1QYBRGcPoF=v-68eJbEDe4Lp4k_hg@HIDDEN>
Subject: Re: bug#77233: 31.0.50; crash if message starts with a space and then
 without it
To: Pip Cet <pipcet@HIDDEN>
Content-Type: multipart/mixed; boundary="00000000000084220006313f985d"
X-Spam-Score: 0.3 (/)
X-Debbugs-Envelope-To: 77233
Cc: =?UTF-8?Q?Gerd_M=C3=B6llmann?= <gerd.moellmann@HIDDEN>,
 77233 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

--00000000000084220006313f985d
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

> > If it's urgent, maybe try to comment out the emacs_abort in cmcheckmagi=
c
> > and see if that suffices.
>
> That avoids the crash here, and things work fine in an xterm, but it
> means we printed a character with the cursor at (cols-1,rows-1), which
> allegedly would have caused some (old, I assume?) terminals to scroll by
> a line, destroying the entire Emacs layout...
>
> However, xterm and M-x term both handle this situation sensibly, not
> scrolling the frame.  Is anyone aware of a terminal emulator that
> scrolls in this situation?

If I comment the emacs_abort, I see everything scroll 1 line upwards,
in many terminals: xterm, urxvt, mlterm, Eterm, lxterm,
cool-retro-term.
Every C-x C-e scrolls it 1 line. C-l fixes it.
I have several customizations in .Xresources that may affect what I'm
seeing in some terminal, but not in all the ones I tested.  I don't
know why doesn't your Emacs-in-xterm scroll. Did you run the part that
sets the background color?


On first thought it seems safer to avoid printing at (cols-1, rows-1)
when we know that AutoWrap is enabled=E2=80=A6

I know this is a different language and scenario, but I just checked
ncurses in Python, and it rejects writing at the bottom right corner:
  File "/n/cursor1.py", line 41, in main
    stdscr.addstr(y, x, letter, curses.color_pair(1))
_curses.error: addwstr() returned ERR

However, with C and using terminal sequences, I saw it's possible to
print at the bottom right without scrolling, in all of the terminal
emulators mentioned above.
I attach a test program that prints a letter in all four corners and
in the center, and doesn't scroll.
I don't know why Emacs scrolls but this test program doesn't (even
with autoscroll on). I don't know enough about terminals, so please
forgive my small mistakes.

--00000000000084220006313f985d
Content-Type: text/x-csrc; charset="US-ASCII"; name="cursor2.c"
Content-Disposition: attachment; filename="cursor2.c"
Content-Transfer-Encoding: base64
Content-ID: <f_m8q0f8sx0>
X-Attachment-Id: f_m8q0f8sx0

I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPHN0cmluZy5o
PgojaW5jbHVkZSA8dW5pc3RkLmg+CiNpbmNsdWRlIDx0ZXJtaW9zLmg+CiNpbmNsdWRlIDxzeXMv
aW9jdGwuaD4KCi8vIEFOU0kgZXNjYXBlIHNlcXVlbmNlcwojZGVmaW5lIENMRUFSX1NDUkVFTiAi
XDAzM1tIXDAzM1tKIgojZGVmaW5lIENVUlNPUl9IT01FICJcMDMzW0giCiNkZWZpbmUgU0VUX1JF
RF9CRyAiXDAzM1s0MW0iCiNkZWZpbmUgUkVTRVRfQVRUUiAiXDAzM1swbSIKI2RlZmluZSBNT1ZF
X0NVUlNPUiAiXDAzM1slZDslZEgiCgp2b2lkIGdldF9zY3JlZW5fc2l6ZShpbnQgKmhlaWdodCwg
aW50ICp3aWR0aCkgewogICAgc3RydWN0IHdpbnNpemUgdzsKICAgIGlvY3RsKFNURE9VVF9GSUxF
Tk8sIFRJT0NHV0lOU1osICZ3KTsKICAgICpoZWlnaHQgPSB3LndzX3JvdzsKICAgICp3aWR0aCA9
IHcud3NfY29sOwp9Cgp2b2lkIG1vdmVfY3Vyc29yKGludCB5LCBpbnQgeCkgewogICAgcHJpbnRm
KE1PVkVfQ1VSU09SLCB5ICsgMSwgeCArIDEpOwogICAgZmZsdXNoKHN0ZG91dCk7Cn0KCmludCBt
YWluKCkgewogICAgaW50IGhlaWdodCwgd2lkdGg7CiAgICBjaGFyIGJ1ZmZlclsyNTZdOwogICAg
CiAgICAvLyBHZXQgc2NyZWVuIGRpbWVuc2lvbnMKICAgIGdldF9zY3JlZW5fc2l6ZSgmaGVpZ2h0
LCAmd2lkdGgpOwogICAgCiAgICAvLyBDbGVhciBzY3JlZW4gYW5kIG1vdmUgY3Vyc29yIGhvbWUK
ICAgIHByaW50ZigiJXMiLCBDTEVBUl9TQ1JFRU4pOwogICAgZmZsdXNoKHN0ZG91dCk7CiAgICAK
ICAgIC8vIENhbGN1bGF0ZSBjZW50ZXIgcG9zaXRpb24KICAgIGludCBjZW50ZXJfeSA9IGhlaWdo
dCAvIDI7CiAgICBpbnQgY2VudGVyX3ggPSB3aWR0aCAvIDI7CiAgICAKICAgIC8vIENvcm5lciBw
b3NpdGlvbnMKICAgIGludCBwb3NpdGlvbnNbXVsyXSA9IHsKICAgICAgICB7MCwgMH0sICAgICAg
ICAgICAvLyBUb3AtbGVmdAogICAgICAgIHswLCB3aWR0aCAtIDF9LCAgIC8vIFRvcC1yaWdodAog
ICAgICAgIHtoZWlnaHQgLSAxLCAwfSwgIC8vIEJvdHRvbS1sZWZ0CiAgICAgICAge2hlaWdodCAt
IDEsIHdpZHRoIC0gMX0sIC8vIEJvdHRvbS1yaWdodAogICAgICAgIHtjZW50ZXJfeSwgY2VudGVy
X3h9ICAgICAvLyBDZW50ZXIKICAgIH07CiAgICAKICAgIGNoYXIgbGV0dGVyc1tdID0geydBJywg
J0InLCAnQycsICdEJywgJ0UnfTsKICAgIAogICAgLy8gRGlzcGxheSBsZXR0ZXJzIHdpdGggZGVs
YXlzCiAgICBmb3IoaW50IGkgPSAwOyBpIDwgNTsgaSsrKSB7CiAgICAgICAgbW92ZV9jdXJzb3Io
cG9zaXRpb25zW2ldWzBdLCBwb3NpdGlvbnNbaV1bMV0pOwogICAgICAgIAogICAgICAgIGlmKGkg
PCA0KSB7IC8vIENvcm5lcnMgZ2V0IHJlZCBiYWNrZ3JvdW5kCiAgICAgICAgICAgIHByaW50Zigi
JXMlYyVzIiwgU0VUX1JFRF9CRywgbGV0dGVyc1tpXSwgUkVTRVRfQVRUUik7CiAgICAgICAgfSBl
bHNlIHsgLy8gQ2VudGVyIGxldHRlciBnZXRzIG5vcm1hbCBiYWNrZ3JvdW5kCiAgICAgICAgICAg
IHByaW50ZigiJWMiLCBsZXR0ZXJzW2ldKTsKICAgICAgICB9CiAgICAgICAgCiAgICAgICAgZmZs
dXNoKHN0ZG91dCk7CiAgICAgICAgdXNsZWVwKDUwMDAwMCk7IC8vIDAuNSBzZWNvbmRzCiAgICB9
CiAgICAKICAgIC8vIFdhaXQgMiBzZWNvbmRzIGJlZm9yZSBleGl0aW5nCiAgICBzbGVlcCgyKTsK
ICAgIAogICAgcmV0dXJuIDA7Cn0K
--00000000000084220006313f985d--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#77233; Package emacs. Full text available.

Message received at 77233 <at> debbugs.gnu.org:


Received: (at 77233) by debbugs.gnu.org; 26 Mar 2025 14:24:28 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 26 10:24:28 2025
Received: from localhost ([127.0.0.1]:43784 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1txRgC-00073z-Af
	for submit <at> debbugs.gnu.org; Wed, 26 Mar 2025 10:24:28 -0400
Received: from mail-vk1-xa29.google.com ([2607:f8b0:4864:20::a29]:61564)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <n142857@HIDDEN>) id 1txRg8-00073c-DN
 for 77233 <at> debbugs.gnu.org; Wed, 26 Mar 2025 10:24:25 -0400
Received: by mail-vk1-xa29.google.com with SMTP id
 71dfb90a1353d-523f19d39d3so3358146e0c.2
 for <77233 <at> debbugs.gnu.org>; Wed, 26 Mar 2025 07:24:24 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1742999058; x=1743603858; darn=debbugs.gnu.org;
 h=cc:to:subject:message-id:date:from:in-reply-to:references
 :mime-version:from:to:cc:subject:date:message-id:reply-to;
 bh=Nzwhbzpa/yetGKlWNveo5YFHOqsz26ta9jJbr3CcWEU=;
 b=ITzUGP/a+MMXfwP0oe+MJCGlxTAJtPLO6xpvGyGnuzh6kfZ0cqcAHPJ5o/2QDKfaHd
 akmvA3oDwW9rKtsRq0JuUk7UGckOEvBl6jnplhDU+VAt0i+GcKS+6XoA2LA0pYEJJd2R
 zuWRmj99tl/nmt3AAHLOMpCbARf9E8tNdUegUCqbSnZXvZMgJVkCGGiR9lgYOiBbZJPg
 sZyfDh4jABk2GpkirzH9jMoTLWjfj1Xm5yo/whPVWlxmBB3nYS055HQTtcB7PqT0suhs
 gOFm+2gET7iCf1GBdaO3tCwwtCNuXt3kiGlz4lCrnWfZ4snUAC+leMrjnVTOMKcAv8yI
 n5Sg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1742999058; x=1743603858;
 h=cc:to:subject:message-id:date:from:in-reply-to:references
 :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id
 :reply-to;
 bh=Nzwhbzpa/yetGKlWNveo5YFHOqsz26ta9jJbr3CcWEU=;
 b=suEvAcb10j1tqmBkRCefCCAYJQsBgMnFO63NyA2t5vw7chdUOnLAySmGMdRRNEwIOq
 WGBGwUNnnth7taSA2x1qSJ33xmZEbSvt1XGV0G8LQK7SHZFuPQrfz3CS1SlSchDV62Fz
 8DslNENCn1fRuy29RG8vpKjWa1s7NrqDrKFmwvY0LmfEWOclol9ahCcTn/pPKzC6d2Kn
 +Cq0VKvrxbJfnSL0bpKRAIjfoOSfpcJBM5gnUoWbNF73uqiaT17zuKaRzzk7IisViKOK
 gP9ItCGLKfcpLxXNw5HTDG185AZlbxjbIB+hQ/NfONuV45rYTOcPex/+J33kfeGgMK8h
 EOHw==
X-Gm-Message-State: AOJu0YyfA5iveuUns3mVDSiwXGVTVvDGdx8EBuH6QJ3D/ta5knaDcLi7
 lURMFosAvLBccqi1Jlobc4YMFSlJU/GtP2QjyzmKRcPjDMO41gN0oPe40+Tlg1UQ44fL9Tx5Ryu
 qm0qofWbLUSNJZ8IyjWfQpJ5rY6U=
X-Gm-Gg: ASbGncuvUA7uCLeN1KWdzMpIpuz2cmhAY5RLNFl2W+ABvt0+IbyOOecnfPb2wzcWUMt
 a1t7zl+8xJewrLNSc/erIPrOTNnLwX4Bfo6zv4JHuyjkNsyvRwN4UDgQIeNgb0nXfeashzQf7BE
 jUKR0Wo9o3T7OTQ68xU9JjIpTA
X-Google-Smtp-Source: AGHT+IEAtB3IZtIMKbLg2E+93/j3Xdumxn+JhAZth1Wkb5PiZUCMqUxpswdQKygoU5oH/LbMeBa8zvalMU6qAat0IvM=
X-Received: by 2002:a05:6122:88d:b0:520:5185:1c31 with SMTP id
 71dfb90a1353d-525a850df05mr15141812e0c.9.1742999058286; Wed, 26 Mar 2025
 07:24:18 -0700 (PDT)
MIME-Version: 1.0
References: <CAJKAhPCBJUoxuK-9HSBfyvstsJE3n4YJUSY-EMav_75DUYcFGQ@HIDDEN>
 <867c4efuyx.fsf@HIDDEN> <861pumfrgo.fsf@HIDDEN>
In-Reply-To: <861pumfrgo.fsf@HIDDEN>
From: Daniel Clemente <n142857@HIDDEN>
Date: Wed, 26 Mar 2025 14:23:50 +0000
X-Gm-Features: AQ5f1JqHE9ydDdM6N-MXq1Kto7fN9BQsbPrg9LgltWICoylc5EH37ndFQo0bRA8
Message-ID: <CAJKAhPApG-2_Pb2uUhELb2okne7BXtKNxZjygktK6MmC4v9JAA@HIDDEN>
Subject: Re: bug#77233: 31.0.50; crash if message starts with a space and then
 without it
To: Eli Zaretskii <eliz@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
X-Spam-Score: 0.3 (/)
X-Debbugs-Envelope-To: 77233
Cc: 77233 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

> Does the crash depend on the terminal emulator you use?

I was using urxvt, which also implements autowrap. As mentioned in the
thread, it also happens in xterm.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#77233; Package emacs. Full text available.

Message received at 77233 <at> debbugs.gnu.org:


Received: (at 77233) by debbugs.gnu.org; 25 Mar 2025 05:06:40 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 25 01:06:40 2025
Received: from localhost ([127.0.0.1]:35548 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1twwUp-0002pX-SR
	for submit <at> debbugs.gnu.org; Tue, 25 Mar 2025 01:06:40 -0400
Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:51700)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <gerd.moellmann@HIDDEN>)
 id 1twwUn-0002p4-3J
 for 77233 <at> debbugs.gnu.org; Tue, 25 Mar 2025 01:06:37 -0400
Received: by mail-wr1-x42a.google.com with SMTP id
 ffacd0b85a97d-3995ff6b066so2884792f8f.3
 for <77233 <at> debbugs.gnu.org>; Mon, 24 Mar 2025 22:06:37 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1742879190; x=1743483990; darn=debbugs.gnu.org;
 h=mime-version:user-agent:message-id:date:references:in-reply-to
 :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to;
 bh=QHGAYGWVFmNZHlclFa5sE7VkhEcnmk5udUlLQa8qttY=;
 b=X6dh3Wvuksdsf8s9+CcyJneVEIo02+G0GS+LSFBymvLiTJ7ARKxP+5KH/aeHuYc4Uc
 FczUiWx5iYczRpEyORdCfyBC4KgLcayjlhqVIsSTbTshG5HlzL4hM+43Mf9UiuWiKXzr
 95zAy+HuyilpPag5P6tLEXKuRex2PCRqRcv01UKkRgL20ZEHlpNRl464qx7sbPkm9dln
 aL33mDem5136b1vxveanGIvv9bD1i06ejzUjz3s+gyAAzXPZi3JF43WUcqamjTv5R8jn
 V+up0PhMoux+6BqRi23xlCoCIExohVuSK7Si3e0BqabZ1O1xamQEbr36LI8W0fP2fm7d
 XWgQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1742879190; x=1743483990;
 h=mime-version:user-agent:message-id:date:references:in-reply-to
 :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date
 :message-id:reply-to;
 bh=QHGAYGWVFmNZHlclFa5sE7VkhEcnmk5udUlLQa8qttY=;
 b=BaXXbLV+1E3fEllZcROf1+5WZ9bO/03rL5I/kTUr5Ftkn2CZIJBYClPF5vAmo02kC5
 Z8GMv6t3VszJC8lL8M7YRbDvhcRRCqRLzL1qNy9lEnj7i+yDhVLISJoOQDVJoi1foLAd
 Wr88KHPyYDEy3g48rn5ujpOWI42VoVc//46k4aiKQVCIz1I8D6tj/L6056scPvgjzsLQ
 X0I777ePE/bfv+VQZ5XH3Xy9ONFWngsNTlNBF+vg2zWcvBUb8KT2Gc//E5DG5yRmeVng
 GZsAeXKn0m/JY3D9rSdUd3tDOQ1fWkYBAahq8LFPkIdgPhGRTj3/17B1fEuE+Uwaz9Zu
 IZfQ==
X-Forwarded-Encrypted: i=1;
 AJvYcCXtJqkL/ZhZUDykUT/4LBfLc91eGGcqF0UjRRFAvNfDCIkdnOWARz+60/8CrL8TCd4q6l6BaA==@debbugs.gnu.org
X-Gm-Message-State: AOJu0Yw2ZRuzugSwa2WE5IHlk+XaXMJ0pj1/lHOdrYuuwtJdE3a4LPAn
 vesFg4a78dbPT6oQZvo3rwqq2yyuZTEfpz0xqW9jHyt9NPzKBeYah6PFmA==
X-Gm-Gg: ASbGncsbwVxsclwwuuzoLjOXuIQO+Ev5N7KhipVWU6g1qF3HUYDAvDBTYqFPODhTI/v
 4MzNO511Pc8rkjtxX4NMkYWu4raWpHJ8s1oCE3djb2WaPIJsKnmQUjFDKQmPygzt3aYZyvYBCM7
 D0KnEwALBNVfY2P00uKw5/32lOiHPxwjbkUyRN/X6dP1qXrmN7hW/gTVVKGi2obHdee48y5gsky
 Gq7XKhYpxUTEsmYEIhjNkL+mboJb6w0jVTxKCOef8dSDvt6/tEmdGx58wr8eic/MajEtIjncyzT
 Czo/PcmhvrCJ8N90zRHZZORYrYkH2LJ+zPOZ/Ai90rzbt9f9q66RZ94EL13vSfsnp5aAkqaCWQF
 jM2/Ja3vEn/TND2u+hQyqlsq5l8tW+8UY5jctNK4pIaKVbg==
X-Google-Smtp-Source: AGHT+IFQPfKgx3E0FlPsG7J+9iEXmMcIT2A1ORzBcOj2YpMEcaYDhZt+cZgv9u79oAQRZrOp2+eO4A==
X-Received: by 2002:a05:6000:1aca:b0:391:47a7:299c with SMTP id
 ffacd0b85a97d-3997f94de39mr14460012f8f.40.1742879190429; 
 Mon, 24 Mar 2025 22:06:30 -0700 (PDT)
Received: from pro2 (p200300e0b7030900e45d830002abc6c6.dip0.t-ipconnect.de.
 [2003:e0:b703:900:e45d:8300:2ab:c6c6])
 by smtp.gmail.com with ESMTPSA id
 ffacd0b85a97d-3997f9ef155sm12475725f8f.89.2025.03.24.22.06.29
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 24 Mar 2025 22:06:29 -0700 (PDT)
From: =?utf-8?Q?Gerd_M=C3=B6llmann?= <gerd.moellmann@HIDDEN>
To: Pip Cet <pipcet@HIDDEN>
Subject: Re: bug#77233: 31.0.50; crash if message starts with a space and
 then without it
In-Reply-To: <m2cye567hk.fsf@HIDDEN>
References: <CAJKAhPCBJUoxuK-9HSBfyvstsJE3n4YJUSY-EMav_75DUYcFGQ@HIDDEN>
 <867c4efuyx.fsf@HIDDEN> <87jz8eectq.fsf@HIDDEN>
 <86zfhae1e5.fsf@HIDDEN> <878qoudyy6.fsf@HIDDEN>
 <m2h63i5gt8.fsf@HIDDEN> <m2cye567hk.fsf@HIDDEN>
Date: Tue, 25 Mar 2025 06:06:29 +0100
Message-ID: <m28qot66ne.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77233
Cc: n142857@HIDDEN, Eli Zaretskii <eliz@HIDDEN>, 77233 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Gerd M=C3=B6llmann <gerd.moellmann@HIDDEN> writes:

>> Something like that, yes.
>
> Or maybe simply use the glyph at string - 1 when cur_x =3D=3D last column.
> STRING is always part of a row, and we don't have rows that are
> only partially filled, or are so narrow that string - 1 isn't valid.

Like this:


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment; filename=wrap.diff

diff --git a/src/term.c b/src/term.c
index a66cec252d5..46b3db7abeb 100644
--- a/src/term.c
+++ b/src/term.c
@@ -972,10 +972,18 @@ tty_write_glyphs (struct frame *f, struct glyph *string, int len)
   if (AutoWrap (tty)
       && curY (tty) + 1 == FRAME_TOTAL_LINES (f)
       && curX (tty) + len == FRAME_COLS (f)
-      && curX (tty) < FRAME_COLS (f) - 1
       && len > 0)
     {
-      /* Write glyphs except the first. */
+      /* If only outputting 1 glyph in the last column, make that two so
+	 that we have something to shift into the last column.  */
+      if (curX (tty) == FRAME_COLS (f) - 1)
+	{
+	  cmgoto (tty, curY (tty), curX (tty) - 1);
+	  --string;
+	  ++len;
+	}
+
+      /* Write glyphs except the first.  */
       int old_x = curX (tty), old_y = curY (tty);
       tty_write_glyphs_1 (f, string + 1, len - 1);
 

--=-=-=
Content-Type: text/plain


Sorry for being terse, have to get the train now :-).

--=-=-=--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#77233; Package emacs. Full text available.

Message received at 77233 <at> debbugs.gnu.org:


Received: (at 77233) by debbugs.gnu.org; 25 Mar 2025 04:48:35 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 25 00:48:35 2025
Received: from localhost ([127.0.0.1]:35382 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1twwDK-0001SB-PS
	for submit <at> debbugs.gnu.org; Tue, 25 Mar 2025 00:48:35 -0400
Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:44086)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <gerd.moellmann@HIDDEN>)
 id 1twwDI-0001Rt-0y
 for 77233 <at> debbugs.gnu.org; Tue, 25 Mar 2025 00:48:33 -0400
Received: by mail-wr1-x42d.google.com with SMTP id
 ffacd0b85a97d-39127512371so3371601f8f.0
 for <77233 <at> debbugs.gnu.org>; Mon, 24 Mar 2025 21:48:31 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1742878105; x=1743482905; darn=debbugs.gnu.org;
 h=content-transfer-encoding:mime-version:user-agent:message-id:date
 :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=/KbCGF8wVGkAvR9AEgjeX3XvCmZ86DeXnUXyxNi3NFc=;
 b=Fg5xT4TI3WUk312ProRDaYTwvS0RyNPW2Dmx+qYmSQJ8Cz9byNwylpJCd5spkOidtK
 VuDf5FvD0B2oisuaTfvqwBUFtcFPb13ItU6Qd3aqFLdqBmxpnPy784hID1Zxqji5iiaJ
 e5wUp2O2eDqvFh1RceyHewFVzxHjGMrYUj8x4foiaVvnUzoT+Y9e3uxtdMUvGogtFHvo
 MZsUFTZ5wDTK9+GpbtHz26xMAKZpDfPN18bwaJqp+jIJHHa1WLdM5RHsyCqtxqFkfdEr
 b+mML4iu0r29NlCrVNaxgJQPzWwoywyzjSR5f8Er8yqdmqEfk3R6V8fiFIWM1Dv3KKZ1
 oMTQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1742878105; x=1743482905;
 h=content-transfer-encoding:mime-version:user-agent:message-id:date
 :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from
 :to:cc:subject:date:message-id:reply-to;
 bh=/KbCGF8wVGkAvR9AEgjeX3XvCmZ86DeXnUXyxNi3NFc=;
 b=I7Q+lFtXiMnepwQ6DU1ADTpUUUFhpnPqkiKrQ/SgCOrrmq54x+QITt2YMIss1Oq0v4
 QXIezKUHihB+NntlyIPO753h2DVMvOtJ/pNjKYTGM0YdGLu99FPv2WDm2GX58jOOziR5
 myvoCR6+J9hELzqLX/MvRniHswW9iZhGhPa7CSavFIVnTYc5a0FyCVmk4Gx328jZP0fS
 L/7CIPxOsRtp2S/1AGoIQ9Lvi8ewacKTby6Sa5iGXBGOwti/gkKMf601fPxlzAcdQ2HV
 viTiupoZN/ObyntcyFctpxLRKgAp1KzNRp3K5wUx5h3hYza93kk4o+EM6R6oA+n8/THc
 u1aQ==
X-Forwarded-Encrypted: i=1;
 AJvYcCW6i4ggOvuhV7d5pf3L+m7KVKQHAsV76vyw3ie6b2J0r0Ei7tNhcdaGPL3S8KTOuUJZ0XVgLQ==@debbugs.gnu.org
X-Gm-Message-State: AOJu0Yytow8nW8BWAV/GDN+eEA3vepckvwv90Re9M0PkX6T1FfSoWaeb
 Iul4wBLV93eAXdhwxtTT0DUPI5MVCbW3hNsPl6mzqZRn/K/b+wd+rEheXg==
X-Gm-Gg: ASbGncvZY9beq9Z+0NyW6999x2gFg3G835o3IrCa//VpZTPTEiF/Wknz5/3mOli0Kt1
 AUbOWLAA/3eeYqEE/RHq0qtVIky/0spOn3TgCIo6Kfio7gwlXrHkhRrJ4gobj5phL9HS1F0+ujp
 Ofz8tVwxr+H4/mM/CE2t3FIu9u8cQnOG5mpKfFA9TgaUgkPUKvxmzq/F5GxzD4lnU03OzI3vrqf
 JjdFuA/8IdE/3+SwBB4gNlwjJlgcH2O2L1lj67TJFHRtMg2u+yEyTyDQ7Fivtt7rMn3BxOQaZFa
 eG8bORI/GuwuviM+f/iaZaYGZSTOFDLmjxp7qu9hbXM7eU0ImhLlHB7O4HI5GLUh6b+jBrv4hJc
 D8jr1pmiPsmwTObAfseN8A1l9KDVJpqTe5g+K3zng4/WvKg==
X-Google-Smtp-Source: AGHT+IEQSArMzhtJSxXiTN/QY6IcER3PbKZ2GylWBh6/qUYQQX1z/D3PXSSE0n+aIW/O+ORn/83DTA==
X-Received: by 2002:a05:6000:4188:b0:391:c78:8895 with SMTP id
 ffacd0b85a97d-3997f93d4d0mr9410544f8f.50.1742878104921; 
 Mon, 24 Mar 2025 21:48:24 -0700 (PDT)
Received: from pro2 (p200300e0b7030900e45d830002abc6c6.dip0.t-ipconnect.de.
 [2003:e0:b703:900:e45d:8300:2ab:c6c6])
 by smtp.gmail.com with ESMTPSA id
 ffacd0b85a97d-3997f9a3f81sm12892965f8f.35.2025.03.24.21.48.23
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 24 Mar 2025 21:48:24 -0700 (PDT)
From: =?utf-8?Q?Gerd_M=C3=B6llmann?= <gerd.moellmann@HIDDEN>
To: Pip Cet <pipcet@HIDDEN>
Subject: Re: bug#77233: 31.0.50; crash if message starts with a space and
 then without it
In-Reply-To: <m2h63i5gt8.fsf@HIDDEN>
References: <CAJKAhPCBJUoxuK-9HSBfyvstsJE3n4YJUSY-EMav_75DUYcFGQ@HIDDEN>
 <867c4efuyx.fsf@HIDDEN> <87jz8eectq.fsf@HIDDEN>
 <86zfhae1e5.fsf@HIDDEN> <878qoudyy6.fsf@HIDDEN>
 <m2h63i5gt8.fsf@HIDDEN>
Date: Tue, 25 Mar 2025 05:48:23 +0100
Message-ID: <m2cye567hk.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77233
Cc: n142857@HIDDEN, Eli Zaretskii <eliz@HIDDEN>, 77233 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Gerd M=C3=B6llmann <gerd.moellmann@HIDDEN> writes:

> Pip Cet <pipcet@HIDDEN> writes:
>
>> "Eli Zaretskii" <eliz@HIDDEN> writes:
>>
>>>> Date: Mon, 24 Mar 2025 14:14:11 +0000
>>>> From: Pip Cet <pipcet@HIDDEN>
>>>> Cc: Daniel Clemente <n142857@HIDDEN>, 77233 <at> debbugs.gnu.org
>>>>
>>>> "Eli Zaretskii" <eliz@HIDDEN> writes:
>>>>
>>>> >> #2  0x00005555556730a9 in cmcheckmagic (tty=3D0x555555a983a0) at cm=
.c:122
>>>> >> 122        emacs_abort ();
>>>> >> (gdb) list
>>>> >> 117      if (frame_size_change_delayed (XFRAME (tty->top_frame)))
>>>> >> 118        return;
>>>> >> 119      if (curX (tty) =3D=3D FrameCols (tty))
>>>> >> 120        {
>>>> >> 121          if (!MagicWrap (tty) || curY (tty) >=3D FrameRows (tty=
) - 1)
>>>> >> 122        emacs_abort ();
>>>> >> 123          if (tty->termscript)
>>>> >> 124        putc ('\r', tty->termscript);
>>>> >> 125          putc ('\r', tty->output);
>>>> >> 126          if (tty->termscript)
>>>> >> (gdb) p curY(tty)
>>>> >> $1 =3D 60
>>>> >> (gdb) p FrameRows(tty)-1
>>>> >> $2 =3D 60
>>>> >> (gdb) p FrameCols(tty)
>>>> >> $3 =3D 100
>>>> >> (gdb)
>>>> >
>>>> > What is the value of curX(tty) ?  And if (as I'd expect) it is 100,
>>>> > then do you have any idea how come it became 100 for a 2-character
>>>> > message?
>>>>
>>>> It is equal to FrameCols (tty), as established in line 119 (this
>>>> requires a breakpoint in emacs_abort rather than terminate_due_to_sign=
al).
>>>>
>>>> > Can anyone else reproduce this?
>>>>
>>>> I can, on GNU/Linux with no special options and in an xterm.
>>>
>>> And you can explain how come curX(tty) got such a large value?
>>
>> We tried to print a character at (cols-1,rows-1), which left the
>> remembered cursor position at (cols,rows-1).  According to the comments
>> in term.c, "some terminals" would have scrolled the entire terminal when
>> we wrote that character, which is the situation detected by
>> cmcheckmagic.
>>
>> The code Gerd pushed looks like this:
>>
>> static void
>> tty_write_glyphs (struct frame *f, struct glyph *string, int len)
>> {
>>   struct tty_display_info *tty =3D FRAME_TTY (f);
>>   /* Don't dare write in last column of bottom line, if Auto-Wrap,
>>      since that would scroll the whole frame on some terminals.  */
>>   if (AutoWrap (tty)
>>       && curY (tty) + 1 =3D=3D FRAME_TOTAL_LINES (f)
>>       && curX (tty) + len =3D=3D FRAME_COLS (f)
>>       && curX (tty) < FRAME_COLS (f) - 1
>>       && len > 0)
>>     {
>>       /* Write glyphs except the first. */
>>       int old_x =3D curX (tty), old_y =3D curY (tty);
>>       tty_write_glyphs_1 (f, string + 1, len - 1);
>>
>>       /* Insert the first glyph, shifting the rest right.  */
>>       cmgoto (tty, old_y, old_x);
>>       tty_insert_glyphs (f, string, 1);
>>     }
>>   else
>>     tty_write_glyphs_1 (f, string, len);
>> }
>>
>> in our case (len =3D=3D 1), we end up in the "else" branch because curX =
=3D=3D
>> cols - 1, attempting to print a single character in the bottom-right
>> corner of the terminal.
>>
>> The "else" branch simply prints the character and leaves the cursor
>> position "invalid".
>>
>> Note that xterm (the application) doesn't appear to scroll the terminal
>> in this case, so it's a bit of a historical exercise to fix things on
>> those terminals that would have, but IIUC, the right way is to retrieve
>> the character at (cols-2,rows-1), goto (cols-2,rows-1), print the
>> character that's supposed to end up at (cols-1,rows-1), goto
>> (cols-2,rows-1) again, then print the retrieved character.
>>
>> This is complicated because we'd need to retrieve the character at
>> (cols-2, rows-1) from the frame matrix if tty_write_glyphs is called
>> with len =3D=3D 1 and the cursor is at (cols-1,rows-1).
>>
>> Anyway, here's a patch that does this, but it seems too complicated to
>> be worth it to me:
>>
>> diff --git a/src/term.c b/src/term.c
>> index e15b7a0887e..ccee6c650e3 100644
>> --- a/src/term.c
>> +++ b/src/term.c
>> @@ -971,16 +971,36 @@ tty_write_glyphs (struct frame *f, struct glyph *s=
tring, int len)
>>    if (AutoWrap (tty)
>>        && curY (tty) + 1 =3D=3D FRAME_TOTAL_LINES (f)
>>        && curX (tty) + len =3D=3D FRAME_COLS (f)
>> -      && curX (tty) < FRAME_COLS (f) - 1
>
> Ah, I see. It got into the else branch for len =3D 1. I think I
> misinterpreted what is happening. It didn't even try to insert. Sorry
> for that.
>
>>        && len > 0)
>>      {
>> -      /* Write glyphs except the first. */
>> -      int old_x =3D curX (tty), old_y =3D curY (tty);
>> -      tty_write_glyphs_1 (f, string + 1, len - 1);
>> +      if (len > 1)
>> +	{
>> +	  /* Write glyphs except the first. */
>> +	  int old_x =3D curX (tty), old_y =3D curY (tty);
>> +	  tty_write_glyphs_1 (f, string + 1, len - 1);
>>
>> -      /* Insert the first glyph, shifting the rest right.  */
>> -      cmgoto (tty, old_y, old_x);
>> -      tty_insert_glyphs (f, string, 1);
>> +	  /* Insert the first glyph, shifting the rest right.  */
>> +	  cmgoto (tty, old_y, old_x);
>> +	  tty_insert_glyphs (f, string, 1);
>> +	}
>> +      else
>> +	{
>> +	  struct glyph glyphs[2];
>> +	  glyphs[1] =3D string[0];
>> +	  if (!f->current_matrix || f->current_matrix->matrix_h < curY (tty))
>> +	    return;
>> +	  struct glyph_row *row =3D &f->current_matrix->rows[curY (tty)];
>> +	  int area =3D 0;
>> +	  int x =3D curX (tty) - 1;
>> +	  while (x > row->used[area])
>> +	    {
>> +	      x -=3D row->used[area];
>> +	      if (area++ =3D=3D LAST_AREA)
>> +		return;
>> +	    }
>> +	  glyphs[0] =3D row->glyphs[area][x];
>> +	  tty_write_glyphs (f, glyphs, 2);
>> +	}
>
> Something like that, yes.

Or maybe simply use the glyph at string - 1 when cur_x =3D=3D last column.
STRING is always part of a row, and we don't have rows that are
only partially filled, or are so narrow that string - 1 isn't valid.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#77233; Package emacs. Full text available.

Message received at 77233 <at> debbugs.gnu.org:


Received: (at 77233) by debbugs.gnu.org; 24 Mar 2025 20:12:31 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 24 16:12:31 2025
Received: from localhost ([127.0.0.1]:59093 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1two9u-0003gB-JX
	for submit <at> debbugs.gnu.org; Mon, 24 Mar 2025 16:12:31 -0400
Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:50267)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <gerd.moellmann@HIDDEN>)
 id 1two9r-0003fA-Nv
 for 77233 <at> debbugs.gnu.org; Mon, 24 Mar 2025 16:12:28 -0400
Received: by mail-wr1-x42c.google.com with SMTP id
 ffacd0b85a97d-38a25d4b9d4so2582535f8f.0
 for <77233 <at> debbugs.gnu.org>; Mon, 24 Mar 2025 13:12:27 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1742847141; x=1743451941; darn=debbugs.gnu.org;
 h=mime-version:user-agent:message-id:date:references:in-reply-to
 :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to;
 bh=BriUF1TKU/ft0no3UG9CP0h9bqv1gS6Loyt2uIjTOVM=;
 b=f8ymzejTY3t1i21rJNzkT3Kfzkipp8O00q4WLAADaxosRGfAOblIy/27moRiT4TmAq
 /JcMGJb1Kv0hjXUZTa8dOu8EsPI3xMH8fpqBnV+Gb1f+odKQkhoIIQIQPTrk+i7fiZsz
 OsVWRwfj719NTCTOOygZtIY/JkOutdtD9kQWN9j2hmH65Z6bWDW45dlfkH6V8AEQx4gd
 uptxviSiv4GLNJuqV6V6lgrEhii1/yyay/+vbLpfjJo+w63RQYz9QqLnIYhxjz9uQxuO
 9wBrQLZk9O0ctViWkvNqCgH1Uu3C/N6YfOe8Ay3+DygeTwq2ofy7I9hybIhCdCc6vYey
 xnxw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1742847141; x=1743451941;
 h=mime-version:user-agent:message-id:date:references:in-reply-to
 :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date
 :message-id:reply-to;
 bh=BriUF1TKU/ft0no3UG9CP0h9bqv1gS6Loyt2uIjTOVM=;
 b=IrkuPWIwwN6+LWxTO9kifOhibMu327+Zu7PBSEo6ouPd3eJo45HcP7t+uY0UnmFay9
 K1b2r0QBUEEfXTtHHlMGWSRAFFCy63aDvT9IOej3SyYBo92kRbj3SmN+aTfuYln9pMwu
 gr0dfusAkFdS3+Zef8rb6CQe11dk0M1CHTa22wOy4B9lubt0x3kQQrHBek7RCPQ4wRXs
 xKTNxuOtxEJtNouX/HwXhqxiwBZ+POwfzplLg+eW4K4GS7syR9tK1kg2O5cN0HqESkiJ
 CTUYsQ43MGEYEh2tp5bcjQsb9Il1kDNhXLzti5U8b+l3zsDbr4mLdx8aJmQop86bxwbW
 jpWA==
X-Forwarded-Encrypted: i=1;
 AJvYcCXs3PG3e0GjHm6BVNCYOmW6LnrR3g87Aq5skswY2tmnEpzu44i7SFmYByCGR+cjN+p+GJTMyg==@debbugs.gnu.org
X-Gm-Message-State: AOJu0Yzosug754qqyTr4gv3ygiJYyaOmHXYA/EmYQ09PWDRJ6YVmdA43
 +ZUsJMQLoydAnlzwpWUTDmk8gUL7md0Pi/T9pElJkf+slXWL18WxsfUedQ==
X-Gm-Gg: ASbGncsfIz8AKGIg9kFkqxhbvUoSTUY9eTdZ/7DmwX9BZXyyPJ5kI7O1f73U/wJX7Cv
 zn1y7BrSntzMyW6eTjpeGIqR0JY5taNpC870wA7HUgWZExaoCEMTRawXUQhnmgz1j6Fs/V0xJLp
 dBiyu/J9jARDTjGNh1e9S/eppGBXa3m8qbUqAQ36Xy3lTQiP63iOKZWSkx0X+4qjMtz3Gk78a5Z
 5dxYn0jUscQ1ygJvaUnmJDlOsugiD3YCrcjD9GBhMo8BpXvgiIk85bOwprwA5tNrTcrNaAI8xhG
 Pq+TmqfrZanEiAjDA3KPnRd+m5RM+a3WgFZu1MOn0HRdYCLVB51e3rSIbfdw1j1Ggpzc7bDFpIe
 Lf4CuPwlh4+IJkCqpTg7qhJfIMDG8ixmRKFX4Y+ShA2CU/RlunQkTCeTIw0E=
X-Google-Smtp-Source: AGHT+IGbTR2qmZytuNyy8v0CGA875e0/y6PNSW9TePqz96Qgm2MByaxrPLfbedJurTmT8KnrL43hSg==
X-Received: by 2002:a5d:5846:0:b0:391:4559:8761 with SMTP id
 ffacd0b85a97d-3997f94da30mr11269336f8f.36.1742847140551; 
 Mon, 24 Mar 2025 13:12:20 -0700 (PDT)
Received: from pro2 (p200300e0b70b5b00b91c76a7d1cbd6d5.dip0.t-ipconnect.de.
 [2003:e0:b70b:5b00:b91c:76a7:d1cb:d6d5])
 by smtp.gmail.com with ESMTPSA id
 ffacd0b85a97d-3997f9efe61sm12023970f8f.97.2025.03.24.13.12.19
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 24 Mar 2025 13:12:20 -0700 (PDT)
From: =?utf-8?Q?Gerd_M=C3=B6llmann?= <gerd.moellmann@HIDDEN>
To: Pip Cet <pipcet@HIDDEN>
Subject: Re: bug#77233: 31.0.50; crash if message starts with a space and
 then without it
In-Reply-To: <878qoudyy6.fsf@HIDDEN>
References: <CAJKAhPCBJUoxuK-9HSBfyvstsJE3n4YJUSY-EMav_75DUYcFGQ@HIDDEN>
 <867c4efuyx.fsf@HIDDEN> <87jz8eectq.fsf@HIDDEN>
 <86zfhae1e5.fsf@HIDDEN> <878qoudyy6.fsf@HIDDEN>
Date: Mon, 24 Mar 2025 21:12:19 +0100
Message-ID: <m2h63i5gt8.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77233
Cc: n142857@HIDDEN, Eli Zaretskii <eliz@HIDDEN>, 77233 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Pip Cet <pipcet@HIDDEN> writes:

> "Eli Zaretskii" <eliz@HIDDEN> writes:
>
>>> Date: Mon, 24 Mar 2025 14:14:11 +0000
>>> From: Pip Cet <pipcet@HIDDEN>
>>> Cc: Daniel Clemente <n142857@HIDDEN>, 77233 <at> debbugs.gnu.org
>>>
>>> "Eli Zaretskii" <eliz@HIDDEN> writes:
>>>
>>> >> #2  0x00005555556730a9 in cmcheckmagic (tty=0x555555a983a0) at cm.c:122
>>> >> 122        emacs_abort ();
>>> >> (gdb) list
>>> >> 117      if (frame_size_change_delayed (XFRAME (tty->top_frame)))
>>> >> 118        return;
>>> >> 119      if (curX (tty) == FrameCols (tty))
>>> >> 120        {
>>> >> 121          if (!MagicWrap (tty) || curY (tty) >= FrameRows (tty) - 1)
>>> >> 122        emacs_abort ();
>>> >> 123          if (tty->termscript)
>>> >> 124        putc ('\r', tty->termscript);
>>> >> 125          putc ('\r', tty->output);
>>> >> 126          if (tty->termscript)
>>> >> (gdb) p curY(tty)
>>> >> $1 = 60
>>> >> (gdb) p FrameRows(tty)-1
>>> >> $2 = 60
>>> >> (gdb) p FrameCols(tty)
>>> >> $3 = 100
>>> >> (gdb)
>>> >
>>> > What is the value of curX(tty) ?  And if (as I'd expect) it is 100,
>>> > then do you have any idea how come it became 100 for a 2-character
>>> > message?
>>>
>>> It is equal to FrameCols (tty), as established in line 119 (this
>>> requires a breakpoint in emacs_abort rather than terminate_due_to_signal).
>>>
>>> > Can anyone else reproduce this?
>>>
>>> I can, on GNU/Linux with no special options and in an xterm.
>>
>> And you can explain how come curX(tty) got such a large value?
>
> We tried to print a character at (cols-1,rows-1), which left the
> remembered cursor position at (cols,rows-1).  According to the comments
> in term.c, "some terminals" would have scrolled the entire terminal when
> we wrote that character, which is the situation detected by
> cmcheckmagic.
>
> The code Gerd pushed looks like this:
>
> static void
> tty_write_glyphs (struct frame *f, struct glyph *string, int len)
> {
>   struct tty_display_info *tty = FRAME_TTY (f);
>   /* Don't dare write in last column of bottom line, if Auto-Wrap,
>      since that would scroll the whole frame on some terminals.  */
>   if (AutoWrap (tty)
>       && curY (tty) + 1 == FRAME_TOTAL_LINES (f)
>       && curX (tty) + len == FRAME_COLS (f)
>       && curX (tty) < FRAME_COLS (f) - 1
>       && len > 0)
>     {
>       /* Write glyphs except the first. */
>       int old_x = curX (tty), old_y = curY (tty);
>       tty_write_glyphs_1 (f, string + 1, len - 1);
>
>       /* Insert the first glyph, shifting the rest right.  */
>       cmgoto (tty, old_y, old_x);
>       tty_insert_glyphs (f, string, 1);
>     }
>   else
>     tty_write_glyphs_1 (f, string, len);
> }
>
> in our case (len == 1), we end up in the "else" branch because curX ==
> cols - 1, attempting to print a single character in the bottom-right
> corner of the terminal.
>
> The "else" branch simply prints the character and leaves the cursor
> position "invalid".
>
> Note that xterm (the application) doesn't appear to scroll the terminal
> in this case, so it's a bit of a historical exercise to fix things on
> those terminals that would have, but IIUC, the right way is to retrieve
> the character at (cols-2,rows-1), goto (cols-2,rows-1), print the
> character that's supposed to end up at (cols-1,rows-1), goto
> (cols-2,rows-1) again, then print the retrieved character.
>
> This is complicated because we'd need to retrieve the character at
> (cols-2, rows-1) from the frame matrix if tty_write_glyphs is called
> with len == 1 and the cursor is at (cols-1,rows-1).
>
> Anyway, here's a patch that does this, but it seems too complicated to
> be worth it to me:
>
> diff --git a/src/term.c b/src/term.c
> index e15b7a0887e..ccee6c650e3 100644
> --- a/src/term.c
> +++ b/src/term.c
> @@ -971,16 +971,36 @@ tty_write_glyphs (struct frame *f, struct glyph *string, int len)
>    if (AutoWrap (tty)
>        && curY (tty) + 1 == FRAME_TOTAL_LINES (f)
>        && curX (tty) + len == FRAME_COLS (f)
> -      && curX (tty) < FRAME_COLS (f) - 1

Ah, I see. It got into the else branch for len = 1. I think I
misinterpreted what is happening. It didn't even try to insert. Sorry
for that.

>        && len > 0)
>      {
> -      /* Write glyphs except the first. */
> -      int old_x = curX (tty), old_y = curY (tty);
> -      tty_write_glyphs_1 (f, string + 1, len - 1);
> +      if (len > 1)
> +	{
> +	  /* Write glyphs except the first. */
> +	  int old_x = curX (tty), old_y = curY (tty);
> +	  tty_write_glyphs_1 (f, string + 1, len - 1);
>  
> -      /* Insert the first glyph, shifting the rest right.  */
> -      cmgoto (tty, old_y, old_x);
> -      tty_insert_glyphs (f, string, 1);
> +	  /* Insert the first glyph, shifting the rest right.  */
> +	  cmgoto (tty, old_y, old_x);
> +	  tty_insert_glyphs (f, string, 1);
> +	}
> +      else
> +	{
> +	  struct glyph glyphs[2];
> +	  glyphs[1] = string[0];
> +	  if (!f->current_matrix || f->current_matrix->matrix_h < curY (tty))
> +	    return;
> +	  struct glyph_row *row = &f->current_matrix->rows[curY (tty)];
> +	  int area = 0;
> +	  int x = curX (tty) - 1;
> +	  while (x > row->used[area])
> +	    {
> +	      x -= row->used[area];
> +	      if (area++ == LAST_AREA)
> +		return;
> +	    }
> +	  glyphs[0] = row->glyphs[area][x];
> +	  tty_write_glyphs (f, glyphs, 2);
> +	}

Something like that, yes.

>      }
>    else
>      tty_write_glyphs_1 (f, string, len);




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#77233; Package emacs. Full text available.

Message received at 77233 <at> debbugs.gnu.org:


Received: (at 77233) by debbugs.gnu.org; 24 Mar 2025 20:00:34 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 24 16:00:33 2025
Received: from localhost ([127.0.0.1]:59003 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1twnyL-00027l-4F
	for submit <at> debbugs.gnu.org; Mon, 24 Mar 2025 16:00:33 -0400
Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:49420)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <gerd.moellmann@HIDDEN>)
 id 1twnyI-00026s-66
 for 77233 <at> debbugs.gnu.org; Mon, 24 Mar 2025 16:00:31 -0400
Received: by mail-wr1-x42e.google.com with SMTP id
 ffacd0b85a97d-39727fe912cso1737717f8f.3
 for <77233 <at> debbugs.gnu.org>; Mon, 24 Mar 2025 13:00:30 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1742846424; x=1743451224; darn=debbugs.gnu.org;
 h=content-transfer-encoding:mime-version:user-agent:message-id:date
 :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=Fk66mCGwwEAscXItnLwzLSb2mQCkyIZK5xfZeLbDlDE=;
 b=Agte72N1BYUxGYlmO8HzGKo6Px6du/hVFZIlWB95r4pj/4B0rMbej5sEcgLZVk1GtN
 rpUOPD/EYPaq/UaMC6WaRNAdBMkke+lAukoKJxbnkUiS0Kp0dzflaWFBw9eRxMDUxihB
 CAT+bPPsDuNkJsrhVOYJCfX3I5pR6ucqZtMAfF9RNG/dW9Mdyns8VrpD/Q3OJkDwpYP3
 t2tlqFzNMWA3QS8Lzt0+G8sXyyGhS2GgLapcN3b2EDqYviuiaCGQ4i6aOq3kcOyXqAMc
 Exjxyjgxdh5LUoCR0hCAhSNzyd9tTNrgnVIWk3xMnFpo6tTbdir+RBSi1+I83fUC1xr1
 8ujg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1742846424; x=1743451224;
 h=content-transfer-encoding:mime-version:user-agent:message-id:date
 :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from
 :to:cc:subject:date:message-id:reply-to;
 bh=Fk66mCGwwEAscXItnLwzLSb2mQCkyIZK5xfZeLbDlDE=;
 b=fG3MLMPoi501scQGCbx3uAxRWf2MhEh+zgJ6q+kUVGBd0zXUCb43iVKFs8Gw/JhT0b
 rbs0PIR3Gtd4nmIGx09znlxtmSvl8Zletv4/f5MAIjMsUQYCSLRUVauPhzkTxA5pBhep
 hK/GyCJKC9dYI7ceOoLzY9NkrWOvF5Jjcz8k6itnb9Jlykkq3ykHqId5QylQmqHaXc0x
 avYzALhAYPB+wTexvewmIGBqYaRZ81ewt41XcuYG/yDRIf39T/2sPLf2hqnD+bgp4A+Y
 Y0g2e1D8d2iQRGcAruaTWMM6DJwhomLK1EhbN391Hk6d82oiIxfhTTLXyXo+L9YbeIsO
 F4PQ==
X-Forwarded-Encrypted: i=1;
 AJvYcCUDyFqWByhuQBP+tChG2rNOOoHIrr+1OL4qx1ktQE0Xc2khBmWeFT8B36dt1ptzpEhKlyYaLw==@debbugs.gnu.org
X-Gm-Message-State: AOJu0YybwmLd/j9G1Vsgf/LYDHuC3wRnkvBjytM5Rnbzwmn8zsA8cs4P
 K1Jfv8KOiC3B6J82SEPeq4f88cEN11NfdBAow65t7XNJim+52gs0hzy50A==
X-Gm-Gg: ASbGncvGXBPBpto/Y6wy3Pq/dZ5D6NakkNppadIee7t/0aBJ7uPMwJ9oq0qRsyJweNQ
 fySNmqkZo4PLsKz7CFHEG3Whg/0q/4gbvLNjIYCf1Vh+sHlJr0PKnGHFgCp3nYEiZ0vXNM59iHv
 +TKCtk+WocWnU1uTXXSwacV1On31zPZlaEIoVlabNndfICRy9DOcDIr/tZEeG+F1fRGCOkKap7r
 JXf9yKOHILrwKhWUfZz1gugZ6yL9TABzrS9KSb7iS0/z6zAYi+173rQjWVqE0o5wmrNNrUDitww
 cNlu1U873Vt1gnyi181nXoeq7DVOuQgRgCaU59YkcijErsHcKp3KbpbUXNkxPyFiBIAfEU1lKM3
 0OjpG5zY8sOiO2biip2Ob8zxTBgvKu8vBrOfkM0d0nvuMiuNnjy4N0OjZL9Q=
X-Google-Smtp-Source: AGHT+IEubGTEO/GeqNVfz54zG/W1eKqh35L5py9lZusa1wtd/JaDKm0PtW7K6LCJspgt9zcKuFwFeg==
X-Received: by 2002:a5d:6d88:0:b0:391:3bba:7f18 with SMTP id
 ffacd0b85a97d-3997f8f9e77mr12323158f8f.12.1742846423525; 
 Mon, 24 Mar 2025 13:00:23 -0700 (PDT)
Received: from pro2 (p200300e0b70b5b00b91c76a7d1cbd6d5.dip0.t-ipconnect.de.
 [2003:e0:b70b:5b00:b91c:76a7:d1cb:d6d5])
 by smtp.gmail.com with ESMTPSA id
 ffacd0b85a97d-39abe4971b0sm6734897f8f.26.2025.03.24.13.00.22
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 24 Mar 2025 13:00:23 -0700 (PDT)
From: =?utf-8?Q?Gerd_M=C3=B6llmann?= <gerd.moellmann@HIDDEN>
To: Pip Cet <pipcet@HIDDEN>
Subject: Re: bug#77233: 31.0.50; crash if message starts with a space and
 then without it
In-Reply-To: <8734f2dyh3.fsf@HIDDEN>
References: <CAJKAhPCBJUoxuK-9HSBfyvstsJE3n4YJUSY-EMav_75DUYcFGQ@HIDDEN>
 <867c4efuyx.fsf@HIDDEN> <87jz8eectq.fsf@HIDDEN>
 <86zfhae1e5.fsf@HIDDEN> <m2pli65jkq.fsf@HIDDEN>
 <8734f2dyh3.fsf@HIDDEN>
Date: Mon, 24 Mar 2025 21:00:22 +0100
Message-ID: <m2ldsu5hd5.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77233
Cc: n142857@HIDDEN, Eli Zaretskii <eliz@HIDDEN>, 77233 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Pip Cet <pipcet@HIDDEN> writes:

> Gerd M=C3=B6llmann <gerd.moellmann@HIDDEN> writes:
>
>> Eli Zaretskii <eliz@HIDDEN> writes:
>>
>>>> > Can anyone else reproduce this?
>>>>
>>>> I can, on GNU/Linux with no special options and in an xterm.
>>>
>>> And you can explain how come curX(tty) got such a large value?
>>>
>>>> Reverting 6fb68f4310d808827b83da053fbc112b316b7757 avoids the crash.
>>>
>>> Adding Gerd.
>>
>> I think I can reproduce this, but I can't take a closer look
>> for a couple of days or so.
>>
>> If it's urgent, maybe try to comment out the emacs_abort in cmcheckmagic
>> and see if that suffices.
>
> That avoids the crash here, and things work fine in an xterm, but it
> means we printed a character with the cursor at (cols-1,rows-1), which
> allegedly would have caused some (old, I assume?) terminals to scroll by
> a line, destroying the entire Emacs layout...

Well, it's complicated as usual.

xterm implements AutoWrap. AutoWrap means that when outputting a
character the cursor automatically moves forwawrd. In the last column of
a row, the cursor automatically moves to column 0 of the next line.
Doing this in the last line of a display scrolls the display.

And then there is insert and overwrite mode. AFAIU what you wrote in
another mail len =3D=3D 1 which means we wrote nothing in overwrite mode,
and then 1 glyph in insert mode. tty_insert_glyphs probably (I don't
know), just turns on insert mode, calls tty_write_glyphs, and switches
insert mode off again. The cursor doesn't move. The terminal shifts
glyphs right that came after the cursor.

So the questing is what does inserting a glyph in the last column of the
last row do in various terminals. Does this scroll in some case even
when there are no glyphs to shift right?

> However, xterm and M-x term both handle this situation sensibly, not
> scrolling the frame.  Is anyone aware of a terminal emulator that
> scrolls in this situation?

I simply don't know. I can't remember having seen that defined anywhere.
But don't forget, this is insert mode, I'm pretty sure it scrolls if not
in insert mode.






Information forwarded to bug-gnu-emacs@HIDDEN:
bug#77233; Package emacs. Full text available.

Message received at 77233 <at> debbugs.gnu.org:


Received: (at 77233) by debbugs.gnu.org; 24 Mar 2025 19:41:12 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 24 15:41:12 2025
Received: from localhost ([127.0.0.1]:58839 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1twnfb-0007nl-Uv
	for submit <at> debbugs.gnu.org; Mon, 24 Mar 2025 15:41:12 -0400
Received: from mail-24418.protonmail.ch ([109.224.244.18]:19717)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <pipcet@HIDDEN>)
 id 1twnfY-0007mK-NX
 for 77233 <at> debbugs.gnu.org; Mon, 24 Mar 2025 15:41:09 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;
 s=protonmail3; t=1742845261; x=1743104461;
 bh=/4cem/5X8wk5rfvetHtopkHrbPPl6QP6RGiOHIWNMsc=;
 h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References:
 Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:
 Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post;
 b=yUBszS7Qi5SUeXaoqPITA/bpjVkWTQuYrp/dSDbZfaqoF3MG1BWqID3sW0x6DwMRA
 CiXk47sHyXRjUQJoOz6MY9+miqKfI5x7sTgBkq9aMZDz9KZV/Nn/N3cZ1D58WPp97N
 lgB3XZeTGsB20y7kN+FeBUXCtpyBTu+ieIgVH7I5rK9Gmi6UYgWlgvppWvywo9VUXk
 5n/6/K11vyYtY2KkKSwCcWFxCTDnne4kYAyigu8gxBxSSJYBiKWsr0irBq42QLF9gt
 gfuRpM3h9bMporcrrBo58ymQhYCBgjF3LNa8rYFWcfZjl/EycB23FElA0RnD8cvfGE
 2Mc4v8Ds86opw==
Date: Mon, 24 Mar 2025 19:40:58 +0000
To: Eli Zaretskii <eliz@HIDDEN>
From: Pip Cet <pipcet@HIDDEN>
Subject: Re: bug#77233: 31.0.50;
 crash if message starts with a space and then without it
Message-ID: <87tt7icj4m.fsf@HIDDEN>
In-Reply-To: <86v7rydyhx.fsf@HIDDEN>
References: <CAJKAhPCBJUoxuK-9HSBfyvstsJE3n4YJUSY-EMav_75DUYcFGQ@HIDDEN>
 <867c4efuyx.fsf@HIDDEN> <87jz8eectq.fsf@HIDDEN>
 <86zfhae1e5.fsf@HIDDEN> <878qoudyy6.fsf@HIDDEN>
 <86v7rydyhx.fsf@HIDDEN>
Feedback-ID: 112775352:user:proton
X-Pm-Message-ID: 5c6fa3d562fdc37c49fdb42d4f751a26b5663865
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 77233
Cc: gerd.moellmann@HIDDEN, n142857@HIDDEN, 77233 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

"Eli Zaretskii" <eliz@HIDDEN> writes:

>> Date: Mon, 24 Mar 2025 19:13:55 +0000
>> From: Pip Cet <pipcet@HIDDEN>
>> Cc: Gerd M=C3=B6llmann <gerd.moellmann@HIDDEN>, n142857@HIDDEN, 77=
233 <at> debbugs.gnu.org
>>
>> "Eli Zaretskii" <eliz@HIDDEN> writes:
>>
>> > And you can explain how come curX(tty) got such a large value?
>>
>> We tried to print a character at (cols-1,rows-1)
>
> Why did we do that, when the messages were 2 and 3 characters long?

write_row decided to delete (using delete_glyphs) the initial space in
the final terminal line, which means the bottom-right corner no longer
has the right background color, so it needs to be redrawn (this is in a
158x44 "terminal"):

(gdb) b dispnew.c:6109 if nsp !=3D osp
6109=09  if (osp > nsp)
(gdb) bt full 1

#0  write_row (f=3D0x555555af45d0, vpos=3D44, updating_menu_p=3Dfalse) at d=
ispnew.c:6109
        obody =3D 0x7ffff49740d0
        nbody =3D 0x7ffff49120d0
        op1 =3D 0x7ffff4976360
        op2 =3D 0x7ffff4976360
        np1 =3D 0x7ffff4914360
        nend =3D 0x7ffff4914360
        tem =3D 1
        osp =3D 1
        nsp =3D 0
        begmatch =3D 157
        endmatch =3D 0
        olen =3D 158
        nlen =3D 158
        current_matrix =3D 0x555555af5b40
        desired_matrix =3D 0x555555af5ad0
        current_row =3D 0x555555b00ca0
        desired_row =3D 0x555555afdf90
        must_write_whole_line_p =3D false
        write_spaces_p =3D true
        colored_spaces_p =3D true
(More stack frames follow...)
[...]

6112=09      delete_glyphs (f, osp - nsp);
(gdb) p osp - nsp
$2 =3D 1
[...]
6147=09=09      cursor_to (f, vpos, nsp + begmatch);

(gdb) p nsp + begmatch

$3 =3D 157
(gdb) p vpos

$4 =3D 44
[...]
6148=09=09      write_glyphs (f, nbody + nsp + begmatch, nlen - tem);

(gdb) p nsp + begmatch

$5 =3D 157
(gdb) p nlen - tem

$6 =3D 1

Then the abort.

(I agree with your comments about the patch, of course!  Thanks for
those.  I do think that this is an extremely rare situation and wanted
to make sure not to segfault even if the other display code is
changed...)

Pip





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#77233; Package emacs. Full text available.

Message received at 77233 <at> debbugs.gnu.org:


Received: (at 77233) by debbugs.gnu.org; 24 Mar 2025 19:32:45 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 24 15:32:45 2025
Received: from localhost ([127.0.0.1]:58770 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1twnXP-0006Wu-4m
	for submit <at> debbugs.gnu.org; Mon, 24 Mar 2025 15:32:44 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:39684)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1twnXL-0006VP-Ph
 for 77233 <at> debbugs.gnu.org; Mon, 24 Mar 2025 15:32:40 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1twnXG-0005yx-8w; Mon, 24 Mar 2025 15:32:34 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From:
 Date; bh=1HlOVDCUP6ZauxZgS3LtTsrFADPHZWrT5e8LclQVD9E=; b=kwgJDHwxI7t4kO3iOLq9
 7Q9Ny8VMPD83Emu9C+GaFIURSKuDRUHFnSCwmlHegmgxalpmapZeeHsGAmopbsPMujncGZxez7BfV
 dQE1ZMTyUtyY0V0WIgMUsFLOpLffCPB+uONEGif0Ho+AVvvDTKMRbl+qhP5LkG5Y0AH9E2AtfI5sc
 EBfBUX4UfG6suiNVFNMk0MRdjkFQQ3pdOT8+NCuKdd9+eNi6ohN904tmQCejN8HNkJLaYRIsQQiTY
 b8OF3E3cSyJdLSBd1aPlRFrkOfCwL9N5LcVUqrAor55K5gZ2jB40Cn9IcsGr5Vhp5aGx0uXAQzP2/
 sjaasFN3LFdQHA==;
Date: Mon, 24 Mar 2025 21:32:29 +0200
Message-Id: <86tt7idy2a.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Pip Cet <pipcet@HIDDEN>
In-Reply-To: <878qoudyy6.fsf@HIDDEN> (message from Pip Cet on Mon, 24
 Mar 2025 19:13:55 +0000)
Subject: Re: bug#77233: 31.0.50;
 crash if message starts with a space and then without it
References: <CAJKAhPCBJUoxuK-9HSBfyvstsJE3n4YJUSY-EMav_75DUYcFGQ@HIDDEN>
 <867c4efuyx.fsf@HIDDEN> <87jz8eectq.fsf@HIDDEN>
 <86zfhae1e5.fsf@HIDDEN> <878qoudyy6.fsf@HIDDEN>
MIME-version: 1.0
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 77233
Cc: gerd.moellmann@HIDDEN, n142857@HIDDEN, 77233 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Date: Mon, 24 Mar 2025 19:13:55 +0000
> From: Pip Cet <pipcet@HIDDEN>
> Cc: Gerd Möllmann <gerd.moellmann@HIDDEN>, n142857@HIDDEN, 77233 <at> debbugs.gnu.org
> 
> Anyway, here's a patch that does this, but it seems too complicated to
> be worth it to me:

A few minor/cosmetic comments about the patch:

> +	  if (!f->current_matrix || f->current_matrix->matrix_h < curY (tty))

How can a frame not have a current_matrix?  That could only mean one
thing: the frame was not completely made, in which case its
after_make_frame flag should be reset.  Such frames should never be
considered by this function, i.e. they should be detected at entry and
the function should then return without doing anything.

> +	  struct glyph_row *row = &f->current_matrix->rows[curY (tty)];
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Please use the MATRIX_ROW macro here.

> +	  int area = 0;
> +	  int x = curX (tty) - 1;
> +	  while (x > row->used[area])
> +	    {
> +	      x -= row->used[area];
> +	      if (area++ == LAST_AREA)
> +		return;
> +	    }
> +	  glyphs[0] = row->glyphs[area][x];
> +	  tty_write_glyphs (f, glyphs, 2);
> +	}

I think this is unnecessarily complicated, since frame glyph matrices
never have marginal areas, they only have the single TEXT_AREA.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#77233; Package emacs. Full text available.

Message received at 77233 <at> debbugs.gnu.org:


Received: (at 77233) by debbugs.gnu.org; 24 Mar 2025 19:24:23 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 24 15:24:23 2025
Received: from localhost ([127.0.0.1]:58689 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1twnPL-0005Hm-8J
	for submit <at> debbugs.gnu.org; Mon, 24 Mar 2025 15:24:23 -0400
Received: from mail-10630.protonmail.ch ([79.135.106.30]:15507)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <pipcet@HIDDEN>)
 id 1twnPH-0005GE-WE
 for 77233 <at> debbugs.gnu.org; Mon, 24 Mar 2025 15:24:21 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;
 s=protonmail3; t=1742844252; x=1743103452;
 bh=FJJYjvJHiN1mwLkOiuRAHmFiB3x0xq0cxo70abbPnbw=;
 h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References:
 Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:
 Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post;
 b=KYOKOLKmwn9tdPRbDBZTmoRacpQvFiqBekqmFg7NTU69XxdqNL2hykAwYzR3ytwVO
 3k7H6quJdhp5xaKGgTzhwC3+3fanF9vpUdLbEoOUey5Z6TBuUt1J67dqTu+I3xEJSg
 N526CaW8rUs3xnfHfhKAz5JuvFBVm/ijJX+qrZCWlpqR2Nb7IAOWwbOgwevMiilqrO
 xrMu957G5wCJPHt1p0xCQwLhF/aHuRmWyK7fLZwxzvJWl7SpCOaszcod/2YDcMjW5q
 t5jdX9LiKN7p/mq1EHHwPEXAKjY3NRK11e+cPRtzfkQV1HyunqBQdCP18IuGCHCSeR
 sgwPdmY8bFWUg==
Date: Mon, 24 Mar 2025 19:24:08 +0000
To: =?utf-8?Q?Gerd_M=C3=B6llmann?= <gerd.moellmann@HIDDEN>
From: Pip Cet <pipcet@HIDDEN>
Subject: Re: bug#77233: 31.0.50;
 crash if message starts with a space and then without it
Message-ID: <8734f2dyh3.fsf@HIDDEN>
In-Reply-To: <m2pli65jkq.fsf@HIDDEN>
References: <CAJKAhPCBJUoxuK-9HSBfyvstsJE3n4YJUSY-EMav_75DUYcFGQ@HIDDEN>
 <867c4efuyx.fsf@HIDDEN> <87jz8eectq.fsf@HIDDEN>
 <86zfhae1e5.fsf@HIDDEN> <m2pli65jkq.fsf@HIDDEN>
Feedback-ID: 112775352:user:proton
X-Pm-Message-ID: af116d53f7f879130c6f9375bfe9173d19f593e6
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77233
Cc: n142857@HIDDEN, Eli Zaretskii <eliz@HIDDEN>, 77233 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Gerd M=C3=B6llmann <gerd.moellmann@HIDDEN> writes:

> Eli Zaretskii <eliz@HIDDEN> writes:
>
>>> > Can anyone else reproduce this?
>>>
>>> I can, on GNU/Linux with no special options and in an xterm.
>>
>> And you can explain how come curX(tty) got such a large value?
>>
>>> Reverting 6fb68f4310d808827b83da053fbc112b316b7757 avoids the crash.
>>
>> Adding Gerd.
>
> I think I can reproduce this, but I can't take a closer look
> for a couple of days or so.
>
> If it's urgent, maybe try to comment out the emacs_abort in cmcheckmagic
> and see if that suffices.

That avoids the crash here, and things work fine in an xterm, but it
means we printed a character with the cursor at (cols-1,rows-1), which
allegedly would have caused some (old, I assume?) terminals to scroll by
a line, destroying the entire Emacs layout...

However, xterm and M-x term both handle this situation sensibly, not
scrolling the frame.  Is anyone aware of a terminal emulator that
scrolls in this situation?

Pip





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#77233; Package emacs. Full text available.

Message received at 77233 <at> debbugs.gnu.org:


Received: (at 77233) by debbugs.gnu.org; 24 Mar 2025 19:23:25 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 24 15:23:25 2025
Received: from localhost ([127.0.0.1]:58684 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1twnON-0005AS-6E
	for submit <at> debbugs.gnu.org; Mon, 24 Mar 2025 15:23:25 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:48628)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1twnOH-000590-9t
 for 77233 <at> debbugs.gnu.org; Mon, 24 Mar 2025 15:23:20 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1twnOB-0004c3-Cn; Mon, 24 Mar 2025 15:23:11 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From:
 Date; bh=lQKaYrL4BfrcIUBQldeYldBX482MEbcb6J7hIKKRzmU=; b=E8NQpk/2xZICLscZ8BoF
 ANSQLuwagGHjJ9QvV4jvHIDhr1aHJSuf6t/fu0sToVs+qK2/pJOOwF0jpCFrHPClq1Y43cNaqL8mp
 mdtDE1oRFBfj/heuEvFXmR4DivdgjRXvRmgueK9YSAENBGGU8iD9+LZkfO76Z6x8bUsxLp9bLp13P
 y4dvp25Mlix/OxgwcrZsAGM3nqTmI2yZamc5cxulcgQIc6erTJAMEpgWkP8RuXQ9ms5/Bj//sL1AE
 Ia/dy4cvZyHyURMgXyQW2/Ken2XI6wonM/HnSz25MDXRUeLNmSrizy1ZyS7+L111pbD4HHce5xPZK
 hO38qWWxigtBJg==;
Date: Mon, 24 Mar 2025 21:23:06 +0200
Message-Id: <86v7rydyhx.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Pip Cet <pipcet@HIDDEN>
In-Reply-To: <878qoudyy6.fsf@HIDDEN> (message from Pip Cet on Mon, 24
 Mar 2025 19:13:55 +0000)
Subject: Re: bug#77233: 31.0.50;
 crash if message starts with a space and then without it
References: <CAJKAhPCBJUoxuK-9HSBfyvstsJE3n4YJUSY-EMav_75DUYcFGQ@HIDDEN>
 <867c4efuyx.fsf@HIDDEN> <87jz8eectq.fsf@HIDDEN>
 <86zfhae1e5.fsf@HIDDEN> <878qoudyy6.fsf@HIDDEN>
MIME-version: 1.0
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 77233
Cc: gerd.moellmann@HIDDEN, n142857@HIDDEN, 77233 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Date: Mon, 24 Mar 2025 19:13:55 +0000
> From: Pip Cet <pipcet@HIDDEN>
> Cc: Gerd Möllmann <gerd.moellmann@HIDDEN>, n142857@HIDDEN, 77233 <at> debbugs.gnu.org
> 
> "Eli Zaretskii" <eliz@HIDDEN> writes:
> 
> > And you can explain how come curX(tty) got such a large value?
> 
> We tried to print a character at (cols-1,rows-1)

Why did we do that, when the messages were 2 and 3 characters long?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#77233; Package emacs. Full text available.

Message received at 77233 <at> debbugs.gnu.org:


Received: (at 77233) by debbugs.gnu.org; 24 Mar 2025 19:14:12 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 24 15:14:11 2025
Received: from localhost ([127.0.0.1]:58608 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1twnFQ-0003qc-Vw
	for submit <at> debbugs.gnu.org; Mon, 24 Mar 2025 15:14:11 -0400
Received: from mail-4322.protonmail.ch ([185.70.43.22]:28545)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <pipcet@HIDDEN>)
 id 1twnFN-0003oV-OH
 for 77233 <at> debbugs.gnu.org; Mon, 24 Mar 2025 15:14:07 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;
 s=protonmail3; t=1742843639; x=1743102839;
 bh=41bgqlNXDwEJohPH1eq9U4CV3QU2RgYLg+OD/cM9yJM=;
 h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References:
 Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:
 Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post;
 b=LzTfFQt6L53fEB7fyMPe5UNQ0+dSZBjGwd4z4nhoT+45p9jWUjQcihuvNX+f0XwYK
 txxhNpOfxS93z2LTYUM9ue9dY5AOPXb48cloEwTrG8wmzakgo9VKtgRTD4/8Z2tUW3
 TYS9F7827eBZ3wrcKREnII2/5U4A2+eoPZyToLrU78jylobX7jeVIbKKa1/VHPOOiF
 g1gJolTotfxCHRPOgrCMaySafTJwLF8U4e7tSX+Qgc2Tv6CziDxnzZummEHoe404kQ
 I8/xtDeM2jzmEKCzukImA9GNMlmR46qyDScM7za6KeRxholCgPdM9oD1vsCYHqEYUl
 8h6mTIfq3ioOA==
Date: Mon, 24 Mar 2025 19:13:55 +0000
To: Eli Zaretskii <eliz@HIDDEN>
From: Pip Cet <pipcet@HIDDEN>
Subject: Re: bug#77233: 31.0.50;
 crash if message starts with a space and then without it
Message-ID: <878qoudyy6.fsf@HIDDEN>
In-Reply-To: <86zfhae1e5.fsf@HIDDEN>
References: <CAJKAhPCBJUoxuK-9HSBfyvstsJE3n4YJUSY-EMav_75DUYcFGQ@HIDDEN>
 <867c4efuyx.fsf@HIDDEN> <87jz8eectq.fsf@HIDDEN>
 <86zfhae1e5.fsf@HIDDEN>
Feedback-ID: 112775352:user:proton
X-Pm-Message-ID: 6d6f3a49282899993dffd06921ddd968c35b08be
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77233
Cc: =?utf-8?Q?Gerd_M=C3=B6llmann?= <gerd.moellmann@HIDDEN>,
 n142857@HIDDEN, 77233 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

"Eli Zaretskii" <eliz@HIDDEN> writes:

>> Date: Mon, 24 Mar 2025 14:14:11 +0000
>> From: Pip Cet <pipcet@HIDDEN>
>> Cc: Daniel Clemente <n142857@HIDDEN>, 77233 <at> debbugs.gnu.org
>>
>> "Eli Zaretskii" <eliz@HIDDEN> writes:
>>
>> >> #2  0x00005555556730a9 in cmcheckmagic (tty=3D0x555555a983a0) at cm.c=
:122
>> >> 122        emacs_abort ();
>> >> (gdb) list
>> >> 117      if (frame_size_change_delayed (XFRAME (tty->top_frame)))
>> >> 118        return;
>> >> 119      if (curX (tty) =3D=3D FrameCols (tty))
>> >> 120        {
>> >> 121          if (!MagicWrap (tty) || curY (tty) >=3D FrameRows (tty) =
- 1)
>> >> 122        emacs_abort ();
>> >> 123          if (tty->termscript)
>> >> 124        putc ('\r', tty->termscript);
>> >> 125          putc ('\r', tty->output);
>> >> 126          if (tty->termscript)
>> >> (gdb) p curY(tty)
>> >> $1 =3D 60
>> >> (gdb) p FrameRows(tty)-1
>> >> $2 =3D 60
>> >> (gdb) p FrameCols(tty)
>> >> $3 =3D 100
>> >> (gdb)
>> >
>> > What is the value of curX(tty) ?  And if (as I'd expect) it is 100,
>> > then do you have any idea how come it became 100 for a 2-character
>> > message?
>>
>> It is equal to FrameCols (tty), as established in line 119 (this
>> requires a breakpoint in emacs_abort rather than terminate_due_to_signal=
).
>>
>> > Can anyone else reproduce this?
>>
>> I can, on GNU/Linux with no special options and in an xterm.
>
> And you can explain how come curX(tty) got such a large value?

We tried to print a character at (cols-1,rows-1), which left the
remembered cursor position at (cols,rows-1).  According to the comments
in term.c, "some terminals" would have scrolled the entire terminal when
we wrote that character, which is the situation detected by
cmcheckmagic.

The code Gerd pushed looks like this:

static void
tty_write_glyphs (struct frame *f, struct glyph *string, int len)
{
  struct tty_display_info *tty =3D FRAME_TTY (f);
  /* Don't dare write in last column of bottom line, if Auto-Wrap,
     since that would scroll the whole frame on some terminals.  */
  if (AutoWrap (tty)
      && curY (tty) + 1 =3D=3D FRAME_TOTAL_LINES (f)
      && curX (tty) + len =3D=3D FRAME_COLS (f)
      && curX (tty) < FRAME_COLS (f) - 1
      && len > 0)
    {
      /* Write glyphs except the first. */
      int old_x =3D curX (tty), old_y =3D curY (tty);
      tty_write_glyphs_1 (f, string + 1, len - 1);

      /* Insert the first glyph, shifting the rest right.  */
      cmgoto (tty, old_y, old_x);
      tty_insert_glyphs (f, string, 1);
    }
  else
    tty_write_glyphs_1 (f, string, len);
}

in our case (len =3D=3D 1), we end up in the "else" branch because curX =3D=
=3D
cols - 1, attempting to print a single character in the bottom-right
corner of the terminal.

The "else" branch simply prints the character and leaves the cursor
position "invalid".

Note that xterm (the application) doesn't appear to scroll the terminal
in this case, so it's a bit of a historical exercise to fix things on
those terminals that would have, but IIUC, the right way is to retrieve
the character at (cols-2,rows-1), goto (cols-2,rows-1), print the
character that's supposed to end up at (cols-1,rows-1), goto
(cols-2,rows-1) again, then print the retrieved character.

This is complicated because we'd need to retrieve the character at
(cols-2, rows-1) from the frame matrix if tty_write_glyphs is called
with len =3D=3D 1 and the cursor is at (cols-1,rows-1).

Anyway, here's a patch that does this, but it seems too complicated to
be worth it to me:

diff --git a/src/term.c b/src/term.c
index e15b7a0887e..ccee6c650e3 100644
--- a/src/term.c
+++ b/src/term.c
@@ -971,16 +971,36 @@ tty_write_glyphs (struct frame *f, struct glyph *stri=
ng, int len)
   if (AutoWrap (tty)
       && curY (tty) + 1 =3D=3D FRAME_TOTAL_LINES (f)
       && curX (tty) + len =3D=3D FRAME_COLS (f)
-      && curX (tty) < FRAME_COLS (f) - 1
       && len > 0)
     {
-      /* Write glyphs except the first. */
-      int old_x =3D curX (tty), old_y =3D curY (tty);
-      tty_write_glyphs_1 (f, string + 1, len - 1);
+      if (len > 1)
+=09{
+=09  /* Write glyphs except the first. */
+=09  int old_x =3D curX (tty), old_y =3D curY (tty);
+=09  tty_write_glyphs_1 (f, string + 1, len - 1);
=20
-      /* Insert the first glyph, shifting the rest right.  */
-      cmgoto (tty, old_y, old_x);
-      tty_insert_glyphs (f, string, 1);
+=09  /* Insert the first glyph, shifting the rest right.  */
+=09  cmgoto (tty, old_y, old_x);
+=09  tty_insert_glyphs (f, string, 1);
+=09}
+      else
+=09{
+=09  struct glyph glyphs[2];
+=09  glyphs[1] =3D string[0];
+=09  if (!f->current_matrix || f->current_matrix->matrix_h < curY (tty))
+=09    return;
+=09  struct glyph_row *row =3D &f->current_matrix->rows[curY (tty)];
+=09  int area =3D 0;
+=09  int x =3D curX (tty) - 1;
+=09  while (x > row->used[area])
+=09    {
+=09      x -=3D row->used[area];
+=09      if (area++ =3D=3D LAST_AREA)
+=09=09return;
+=09    }
+=09  glyphs[0] =3D row->glyphs[area][x];
+=09  tty_write_glyphs (f, glyphs, 2);
+=09}
     }
   else
     tty_write_glyphs_1 (f, string, len);





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#77233; Package emacs. Full text available.

Message received at 77233 <at> debbugs.gnu.org:


Received: (at 77233) by debbugs.gnu.org; 24 Mar 2025 19:12:50 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 24 15:12:50 2025
Received: from localhost ([127.0.0.1]:58593 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1twnEA-0003fW-EL
	for submit <at> debbugs.gnu.org; Mon, 24 Mar 2025 15:12:50 -0400
Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]:45122)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <gerd.moellmann@HIDDEN>)
 id 1twnE6-0003eQ-Dj
 for 77233 <at> debbugs.gnu.org; Mon, 24 Mar 2025 15:12:48 -0400
Received: by mail-wm1-x32b.google.com with SMTP id
 5b1f17b1804b1-43cfebc343dso36278435e9.2
 for <77233 <at> debbugs.gnu.org>; Mon, 24 Mar 2025 12:12:46 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1742843559; x=1743448359; darn=debbugs.gnu.org;
 h=mime-version:user-agent:message-id:date:references:in-reply-to
 :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to;
 bh=FspvHKTpaMZU0Rmrw2WHCES/0DlVO0IylcU1a+zXTnM=;
 b=kT0+zoKuqRBozGxSGcBvJ52A/UmTBK9VBgtta818OxJLwcYxL3n/adbk/KYqdzuE4w
 FfHRjGgMM7aGQhLebUmOfB34Dq3SCl/qff+zUgnsQGUtsK5PQQHO3vv/NKVKr+DJNkuf
 Weym11zqZvMrEdXxLCAWv6E6kahNyN/P0FgNKH7iHZBPf2l58nXxXF8Sz9sVCZiMDVI7
 /TVQ4Z/n2sLupoTinFtaPMfDFJgwnwD8k7W/hG8nqqDYFkOGhevtg+iBgVq4uOCONmqb
 PAtCCPxgMkcmdHiz/x8ASrmeqTCZOtqM18sJGS5LP3/s+w3I/utdGymPjgBss3MTH1Oa
 AZtA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1742843559; x=1743448359;
 h=mime-version:user-agent:message-id:date:references:in-reply-to
 :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date
 :message-id:reply-to;
 bh=FspvHKTpaMZU0Rmrw2WHCES/0DlVO0IylcU1a+zXTnM=;
 b=lG18tdJ7b3pGPV3BKY217ZaPh17OK98zpG16ru2vgOKMmgX89IMKGwECpm/nINH6au
 wOasYH2kD0CqjnCnNOcMpglU81PLGoTZbf8JQKq8r7oZL74FBEi9eM9k1V9k40di3mjK
 lbXPvGvMmiEb36oaGXg+Us8fwFqTPF7fxASRUqamofL0za7fZGmAsMju4+BVqfGE/ZYk
 Fizn2C09LJD27HDboCP486OrodzdJgWZ7sW8NUKxYZ6dqCBCkO6F5AxUZu0fw6jW0atd
 IUKkQWgEg5NjPzA6A/EyrvjZRM7dunj+NY+arB+Ydeh5LIqFgMSPNKctvs8wVOh1NB4M
 PZ7A==
X-Forwarded-Encrypted: i=1;
 AJvYcCXxfXUfLp9MtH/yh91U2CmJJN/yZS2/4E9FLSC50odq0/GlDOoWccUld+SvuiscyQP19FyEzA==@debbugs.gnu.org
X-Gm-Message-State: AOJu0Yyxvi8drAhA/dZI4xd7ThzQ/0Yz00/bDIvATB2h5rylvCF+UWrk
 nKMcYdJNsXRZVsyRYigYMwiCkTUplPWCX/3i9+jOqnc4eLKsv/ga6+OeMA==
X-Gm-Gg: ASbGncv0YdjLEkCzsNG8MlNyY61Kb/Vb++8S8M8lmgW9vZrdn6uk+MmSQ6+r5S0PTY0
 pDthwPvUybfDUPzT1plt3Eaqe+R3zEixcJeoJp+XhiMP33kcIQAQ2V05scA8xgSIXFHUtgzhFFi
 xQTXUBxYAE7Mfl8BOy7gHdFQHhl2MGFiAtLB4kx1byQSNUzrJEoADqeqBNg3uO2QjqPtDLZnAbw
 IUT8znCC0+put9oM3YV4RwDGV/+QGIw1lRlX4jvfU7/hZLcYZaMgpNmjkoZIWaRzHwtgbmTRsdQ
 n8qn+qRYQA+dLefYTE+/mLN42WdLKTaHZ7a1d+DdJpeMIcewAKACUFa3PoKGSpTTN2og4wKb6D7
 atrqPAJMFYVu6frAehlBnCifRE4rcKYLeaDioMIVpaJ/QF+F1
X-Google-Smtp-Source: AGHT+IH0an0IMuq6PJ2Bhtpc1rTKvRuyq1N0Jjaj0Aov3Cf28Q1dYZqlExT67RFIiBPSELH8AN0hqQ==
X-Received: by 2002:a05:6000:21c6:b0:391:3157:7717 with SMTP id
 ffacd0b85a97d-3997f932f71mr8116640f8f.34.1742843559211; 
 Mon, 24 Mar 2025 12:12:39 -0700 (PDT)
Received: from pro2 (p200300e0b70b5b00b91c76a7d1cbd6d5.dip0.t-ipconnect.de.
 [2003:e0:b70b:5b00:b91c:76a7:d1cb:d6d5])
 by smtp.gmail.com with ESMTPSA id
 ffacd0b85a97d-39ab907da9asm9137121f8f.90.2025.03.24.12.12.38
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 24 Mar 2025 12:12:38 -0700 (PDT)
From: =?utf-8?Q?Gerd_M=C3=B6llmann?= <gerd.moellmann@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#77233: 31.0.50; crash if message starts with a space and
 then without it
In-Reply-To: <86zfhae1e5.fsf@HIDDEN>
References: <CAJKAhPCBJUoxuK-9HSBfyvstsJE3n4YJUSY-EMav_75DUYcFGQ@HIDDEN>
 <867c4efuyx.fsf@HIDDEN> <87jz8eectq.fsf@HIDDEN>
 <86zfhae1e5.fsf@HIDDEN>
Date: Mon, 24 Mar 2025 20:12:37 +0100
Message-ID: <m2pli65jkq.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77233
Cc: n142857@HIDDEN, Pip Cet <pipcet@HIDDEN>, 77233 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eli Zaretskii <eliz@HIDDEN> writes:

>> > Can anyone else reproduce this?
>> 
>> I can, on GNU/Linux with no special options and in an xterm.
>
> And you can explain how come curX(tty) got such a large value?
>
>> Reverting 6fb68f4310d808827b83da053fbc112b316b7757 avoids the crash.
>
> Adding Gerd.

I think I can reproduce this, but I can't take a closer look
for a couple of days or so.

If it's urgent, maybe try to comment out the emacs_abort in cmcheckmagic
and see if that suffices.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#77233; Package emacs. Full text available.

Message received at 77233 <at> debbugs.gnu.org:


Received: (at 77233) by debbugs.gnu.org; 24 Mar 2025 18:20:47 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 24 14:20:47 2025
Received: from localhost ([127.0.0.1]:58149 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1twmPn-0004nk-69
	for submit <at> debbugs.gnu.org; Mon, 24 Mar 2025 14:20:47 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:59806)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1twmPk-0004m9-Fh
 for 77233 <at> debbugs.gnu.org; Mon, 24 Mar 2025 14:20:45 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1twmPe-0005KK-S3; Mon, 24 Mar 2025 14:20:38 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From:
 Date; bh=Cq0dCBR4kWTBOluoR+eKStlilHKTTYIunrYo4OltuWo=; b=p41Q1VctbpK6aXkMB6sq
 er+91TxBALguuT9awkwfpQFDXgwJi5YW3SxMWhYQWafLk4m6xO140c9LXXeKUjkBVIUOWvlAtPU8F
 OU4BdBG3lOZ/GbJUPI5luVLQ8J24LIWENntAr8s+AVyXDrNZ4QTnWWG4VaLZUSqnF1sWv8HXZCjFC
 39oN2ZOHLV7//kd9gOed9zlXImJsGgo3thJlxa9Yx1D9pCWelDNSm2UZCDixVAThrXOGufBYVYTom
 WOiW+Xd+qyAz+0FXSIK1yGN2hkDNtKvYQMq80to9rk685XlcuVbxyIdFoNXoFy1FPQ73f7SnA4B5k
 gu7UvqT7JcJ4OA==;
Date: Mon, 24 Mar 2025 20:20:34 +0200
Message-Id: <86zfhae1e5.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Pip Cet <pipcet@HIDDEN>,
 =?utf-8?Q?Gerd_M=C3=B6llmann?= <gerd.moellmann@HIDDEN>
In-Reply-To: <87jz8eectq.fsf@HIDDEN> (message from Pip Cet on Mon, 24
 Mar 2025 14:14:11 +0000)
Subject: Re: bug#77233: 31.0.50;
 crash if message starts with a space and then without it
References: <CAJKAhPCBJUoxuK-9HSBfyvstsJE3n4YJUSY-EMav_75DUYcFGQ@HIDDEN>
 <867c4efuyx.fsf@HIDDEN> <87jz8eectq.fsf@HIDDEN>
MIME-version: 1.0
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 77233
Cc: n142857@HIDDEN, 77233 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Date: Mon, 24 Mar 2025 14:14:11 +0000
> From: Pip Cet <pipcet@HIDDEN>
> Cc: Daniel Clemente <n142857@HIDDEN>, 77233 <at> debbugs.gnu.org
> 
> "Eli Zaretskii" <eliz@HIDDEN> writes:
> 
> >> #2  0x00005555556730a9 in cmcheckmagic (tty=0x555555a983a0) at cm.c:122
> >> 122        emacs_abort ();
> >> (gdb) list
> >> 117      if (frame_size_change_delayed (XFRAME (tty->top_frame)))
> >> 118        return;
> >> 119      if (curX (tty) == FrameCols (tty))
> >> 120        {
> >> 121          if (!MagicWrap (tty) || curY (tty) >= FrameRows (tty) - 1)
> >> 122        emacs_abort ();
> >> 123          if (tty->termscript)
> >> 124        putc ('\r', tty->termscript);
> >> 125          putc ('\r', tty->output);
> >> 126          if (tty->termscript)
> >> (gdb) p curY(tty)
> >> $1 = 60
> >> (gdb) p FrameRows(tty)-1
> >> $2 = 60
> >> (gdb) p FrameCols(tty)
> >> $3 = 100
> >> (gdb)
> >
> > What is the value of curX(tty) ?  And if (as I'd expect) it is 100,
> > then do you have any idea how come it became 100 for a 2-character
> > message?
> 
> It is equal to FrameCols (tty), as established in line 119 (this
> requires a breakpoint in emacs_abort rather than terminate_due_to_signal).
> 
> > Can anyone else reproduce this?
> 
> I can, on GNU/Linux with no special options and in an xterm.

And you can explain how come curX(tty) got such a large value?

> Reverting 6fb68f4310d808827b83da053fbc112b316b7757 avoids the crash.

Adding Gerd.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#77233; Package emacs. Full text available.

Message received at 77233 <at> debbugs.gnu.org:


Received: (at 77233) by debbugs.gnu.org; 24 Mar 2025 14:14:26 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 24 10:14:25 2025
Received: from localhost ([127.0.0.1]:57265 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1twiZN-0004WX-Gq
	for submit <at> debbugs.gnu.org; Mon, 24 Mar 2025 10:14:25 -0400
Received: from mail-10631.protonmail.ch ([79.135.106.31]:54669)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <pipcet@HIDDEN>)
 id 1twiZJ-0004WC-R7
 for 77233 <at> debbugs.gnu.org; Mon, 24 Mar 2025 10:14:23 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;
 s=protonmail3; t=1742825654; x=1743084854;
 bh=HSzFyPpQOQ956qK0WT2AIbAsZ90DGmPFTOhALC5weUI=;
 h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References:
 Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:
 Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post;
 b=cyIl59N70rUvwtWlPN4FzR9LleedBI/fSfOhgi1o/q5cmWVlu2NGhiBogB7PKRi4U
 cxdC57aK//zQjE/DweDy1xvdmeXhQ3hy6VHidyvCustipn6gGEzUZC2naUp1pL6x2q
 Vy/xqjBRbFj+KLkPoUP/s7ivR250j0ROrTlwow7XiUuGvCFFD1UXa0rbVWhdI7wF0Z
 bvyfFHXDuYHwa2QUTJBD2Q0jOhN2IPiR3Sn7oUK9FEau5O8wezHFV5h2d+FSO9sfbX
 oK72E88GSKsy9pgiMPJbXIce1pMPcmftm47zfnt37rWcTDhPXOp/Pi+Eo/N8mwe7T4
 ywFETwk+epWYw==
Date: Mon, 24 Mar 2025 14:14:11 +0000
To: Eli Zaretskii <eliz@HIDDEN>
From: Pip Cet <pipcet@HIDDEN>
Subject: Re: bug#77233: 31.0.50;
 crash if message starts with a space and then without it
Message-ID: <87jz8eectq.fsf@HIDDEN>
In-Reply-To: <867c4efuyx.fsf@HIDDEN>
References: <CAJKAhPCBJUoxuK-9HSBfyvstsJE3n4YJUSY-EMav_75DUYcFGQ@HIDDEN>
 <867c4efuyx.fsf@HIDDEN>
Feedback-ID: 112775352:user:proton
X-Pm-Message-ID: 37d03141ca450a58c6e45bb0a2aafad354d530dc
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77233
Cc: Daniel Clemente <n142857@HIDDEN>, 77233 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

"Eli Zaretskii" <eliz@HIDDEN> writes:

>> #2  0x00005555556730a9 in cmcheckmagic (tty=3D0x555555a983a0) at cm.c:12=
2
>> 122        emacs_abort ();
>> (gdb) list
>> 117      if (frame_size_change_delayed (XFRAME (tty->top_frame)))
>> 118        return;
>> 119      if (curX (tty) =3D=3D FrameCols (tty))
>> 120        {
>> 121          if (!MagicWrap (tty) || curY (tty) >=3D FrameRows (tty) - 1=
)
>> 122        emacs_abort ();
>> 123          if (tty->termscript)
>> 124        putc ('\r', tty->termscript);
>> 125          putc ('\r', tty->output);
>> 126          if (tty->termscript)
>> (gdb) p curY(tty)
>> $1 =3D 60
>> (gdb) p FrameRows(tty)-1
>> $2 =3D 60
>> (gdb) p FrameCols(tty)
>> $3 =3D 100
>> (gdb)
>
> What is the value of curX(tty) ?  And if (as I'd expect) it is 100,
> then do you have any idea how come it became 100 for a 2-character
> message?

It is equal to FrameCols (tty), as established in line 119 (this
requires a breakpoint in emacs_abort rather than terminate_due_to_signal).

> Can anyone else reproduce this?

I can, on GNU/Linux with no special options and in an xterm.  Reverting
6fb68f4310d808827b83da053fbc112b316b7757 avoids the crash.

Pip





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#77233; Package emacs. Full text available.

Message received at 77233 <at> debbugs.gnu.org:


Received: (at 77233) by debbugs.gnu.org; 24 Mar 2025 14:12:27 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 24 10:12:27 2025
Received: from localhost ([127.0.0.1]:57260 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1twiXT-0004Sq-Dz
	for submit <at> debbugs.gnu.org; Mon, 24 Mar 2025 10:12:27 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:49494)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1twiXP-0004SV-3y
 for 77233 <at> debbugs.gnu.org; Mon, 24 Mar 2025 10:12:25 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1twiXJ-00061D-BK; Mon, 24 Mar 2025 10:12:17 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=dxrAwlxNrX2dnoKb72kFYcbfA7wQCauJnclLu/Yh7dA=; b=YexPSYJZR4/w
 xJ69gxXIZUSkNRvOmDLqE654aRqYcTMtMmT9D6NZIyckUykE2eS5fGQUk5MM7c2rvgTvsWYHxMfUm
 qDZF+P/eiB9b4yLNwIe3wGS2v+bCmIPU1Fm5NLc0GYaDldboXX31Gtacz+Mg45PFy+urbJcYBLEuc
 iyocT6/oN7FS27o1CS4eAoop/q4qs5/Nha8cI2/UiHeN1gXTKABWxMwsetM0TQ6tKt4/gA6tvqyJs
 E6Ybl9zfqZeejp9vtI/3fOLCOIZH4V5EdXCh1MqfSotlhcemnDLonqcentT6hyKT1hcke0jBKBv8Q
 1Jb02uzudCzrxI/PwqQn6w==;
Date: Mon, 24 Mar 2025 16:12:07 +0200
Message-Id: <861pumfrgo.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: n142857@HIDDEN
In-Reply-To: <867c4efuyx.fsf@HIDDEN> (message from Eli Zaretskii on Mon, 24
 Mar 2025 14:56:22 +0200)
Subject: Re: bug#77233: 31.0.50;
 crash if message starts with a space and then without it
References: <CAJKAhPCBJUoxuK-9HSBfyvstsJE3n4YJUSY-EMav_75DUYcFGQ@HIDDEN>
 <867c4efuyx.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 77233
Cc: 77233 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Cc: 77233 <at> debbugs.gnu.org
> Date: Mon, 24 Mar 2025 14:56:22 +0200
> From: Eli Zaretskii <eliz@HIDDEN>
> 
> What is the value of curX(tty) ?  And if (as I'd expect) it is 100,
> then do you have any idea how come it became 100 for a 2-character
> message?
> 
> Can anyone else reproduce this?

Does the crash depend on the terminal emulator you use?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#77233; Package emacs. Full text available.

Message received at 77233 <at> debbugs.gnu.org:


Received: (at 77233) by debbugs.gnu.org; 24 Mar 2025 12:56:40 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 24 08:56:40 2025
Received: from localhost ([127.0.0.1]:54692 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1twhM8-0008WH-AM
	for submit <at> debbugs.gnu.org; Mon, 24 Mar 2025 08:56:40 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:37208)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1twhM2-0008Vu-Jy
 for 77233 <at> debbugs.gnu.org; Mon, 24 Mar 2025 08:56:35 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1twhLw-0003cs-TN; Mon, 24 Mar 2025 08:56:28 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=7FMBAjsIaASDa3lxKOVDr1uZDyQK0xKQYk51sH77oVY=; b=ezG1AIRw6/hp
 aJBBO6HRd6Uusp0e0sRuHNgi0Zl71EpaX+wmV+yYcctYpD6yN1EcXX5Akjt0HVFZJjY0Dwt9TTzk1
 c7tamnC5at41MhnRYB5IEV5Dih3PJvk5Y8KLx+aXGLKDYUeojOZ9mcfKH+Zpr5V1aNOw1PlwoiIWz
 UA81Rlx3tahPXAfA0peYGia6TVuBrLB8l0VzqztiN7RW8aaONxB1lrOuLwKbQKZmnovsS17DICnF1
 Jxk2ZeGrogdraygx+tE6buEvvi3u9aepBiwbwnVO9NRuiY6bAEmm8d6s9/XLZL7i7/GNyUwRT5jpN
 6n8/726WX+ky6gGn/7cl8Q==;
Date: Mon, 24 Mar 2025 14:56:22 +0200
Message-Id: <867c4efuyx.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Daniel Clemente <n142857@HIDDEN>
In-Reply-To: <CAJKAhPCBJUoxuK-9HSBfyvstsJE3n4YJUSY-EMav_75DUYcFGQ@HIDDEN>
 (message from Daniel Clemente on Mon, 24 Mar 2025 09:42:52 +0000)
Subject: Re: bug#77233: 31.0.50;
 crash if message starts with a space and then without it
References: <CAJKAhPCBJUoxuK-9HSBfyvstsJE3n4YJUSY-EMav_75DUYcFGQ@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 77233
Cc: 77233 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Daniel Clemente <n142857@HIDDEN>
> Date: Mon, 24 Mar 2025 09:42:52 +0000
> 
> Believe it or not, this crashes each time. Open emacs -Q (with or
> without daemon) in a TTY, and evaluate the first part and then the progn:
> 
> (modify-frame-parameters (selected-frame) '(
>       ;; background-color needs to be defined, to crash. The precise
> color doesn't matter
>       (background-color . "#111")
>       ;; Doesn't affect the crash:
>       ;; (foreground-color . "#c0c0c0")
>      ))
> (progn
>   (message " AB")
>   (message "AB")
> )

Thanks.

I cannot reproduce the crash.  My build is a bit different (for
example, not --without-x), but otherwise I have no clue.

> #2  0x00005555556730a9 in cmcheckmagic (tty=0x555555a983a0) at cm.c:122
> 122        emacs_abort ();
> (gdb) list
> 117      if (frame_size_change_delayed (XFRAME (tty->top_frame)))
> 118        return;
> 119      if (curX (tty) == FrameCols (tty))
> 120        {
> 121          if (!MagicWrap (tty) || curY (tty) >= FrameRows (tty) - 1)
> 122        emacs_abort ();
> 123          if (tty->termscript)
> 124        putc ('\r', tty->termscript);
> 125          putc ('\r', tty->output);
> 126          if (tty->termscript)
> (gdb) p curY(tty)
> $1 = 60
> (gdb) p FrameRows(tty)-1
> $2 = 60
> (gdb) p FrameCols(tty)
> $3 = 100
> (gdb)

What is the value of curX(tty) ?  And if (as I'd expect) it is 100,
then do you have any idea how come it became 100 for a 2-character
message?

Can anyone else reproduce this?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#77233; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 24 Mar 2025 09:43:34 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 24 05:43:34 2025
Received: from localhost ([127.0.0.1]:54250 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tweLF-0003ps-FC
	for submit <at> debbugs.gnu.org; Mon, 24 Mar 2025 05:43:34 -0400
Received: from lists.gnu.org ([2001:470:142::17]:39204)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <n142857@HIDDEN>) id 1tweLA-0003pY-NG
 for submit <at> debbugs.gnu.org; Mon, 24 Mar 2025 05:43:31 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <n142857@HIDDEN>) id 1tweL5-0008Np-4p
 for bug-gnu-emacs@HIDDEN; Mon, 24 Mar 2025 05:43:23 -0400
Received: from mail-ua1-x936.google.com ([2607:f8b0:4864:20::936])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <n142857@HIDDEN>) id 1tweL3-00029L-8T
 for bug-gnu-emacs@HIDDEN; Mon, 24 Mar 2025 05:43:22 -0400
Received: by mail-ua1-x936.google.com with SMTP id
 a1e0cc1a2514c-86dde90e7a3so1752177241.1
 for <bug-gnu-emacs@HIDDEN>; Mon, 24 Mar 2025 02:43:20 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1742809399; x=1743414199; darn=gnu.org;
 h=content-transfer-encoding:to:subject:message-id:date:from
 :mime-version:from:to:cc:subject:date:message-id:reply-to;
 bh=Q4OmIGcjpiCNg8qcUyyaMiGhaOlfthveqhaLsYpg1Vg=;
 b=ZUxuXYS9mdK2DgcAJKLFGQC5BRUajqNw2MoRow2yaEqyF4yy3Z2Q/NYybRXqUsRHLr
 Vg7fN2n/TbBofRT5s2bqijWqNPbgMAAMlD8GfnKWLpw5Nk59jLuTElGIZyZ4XQZLrxih
 uVYNZ6W40vrEDU1vnxq9Ta9K+0bHa6RW1TZ5SF4UGhaiNGULIpIS+uV/mhEQFsIAcAfL
 cgvuSQ5lh+Mr60c9BD9ceeyVXqwOWThNBN4espQqpbLu1y+VpMhol6eKVQaHvijI1vOB
 i8aA+IKz+fBKPx513abAdGqdPTxVDq9jQpKdseBt+Yw0965vF/ZMN58ndEakSf5TXvVh
 qddg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1742809399; x=1743414199;
 h=content-transfer-encoding:to:subject:message-id:date:from
 :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id
 :reply-to;
 bh=Q4OmIGcjpiCNg8qcUyyaMiGhaOlfthveqhaLsYpg1Vg=;
 b=B03eQXlYbpWQecUULhcYik1qFeOceqQQYTMm8vD8ORhRXGRRHbLRyigsZQQ5p6U0qc
 g6+vT+QrmVIKvTfqzaQl6bZOcYq+zp6L7YE2dcnxv0L5LzrfGKjp0D3JG8zDLQo5Ki5/
 Fnua8QTjkOaPP/8/Rt0wDmwszIX5qbh0CwJp07rJjHrzYtWDRx5FSIMoJvg4C+dK+PDx
 OeqklZ0cnL+x4W43olRKWTYUnauURgg2wegc3Com8wAISsa405smDQsaPWu1oVyEV/g+
 39oDLJr8jMaCqrJMPUHDDew36PpEJ8AOU2cFN7AtaXQ/ic/V6Z3HmfijlolN0LEfss/l
 GHUQ==
X-Gm-Message-State: AOJu0YwzxPX0AF9a69yA77mGYIXPb2E+yf+gakwGTphImZqWsQqHY7JK
 oMlMEqO2ALLuUY2wyKzyRDYf9yNHO4gLs2niV+JeWI21ZY7jgKBjHYgv/eA/H6LZlEsUicuJcz7
 YZXnj6KghbA2eZxQosua6SENCZYdCjg==
X-Gm-Gg: ASbGncvdhwajYe8+QzLixESmxGg91p9ghxZmEyEva7MxP+c8Sl2E2PvjzrriLbtKTAf
 VJUGDZdX/HaXZPsSz/r2Em0mEbGZ/c57KFmNi/AHXdTmlVu0ZtnzMHywEKrQuHBLGW0YAwwhpLM
 M1GNZ4yhJB3rqZtG2gaScJCtM+9Wrb3U2wKuGK
X-Google-Smtp-Source: AGHT+IEqF1BwostoU2Z0miwetpghJ1ldfGC2zY24HNQEETkSm/8/vr6EejAWAMck+gd1m8lkmv4DxSO5LdsS9uX4i48=
X-Received: by 2002:a05:6102:3f0d:b0:4c4:df56:6a2b with SMTP id
 ada2fe7eead31-4c50d491ca0mr8118999137.4.1742809398856; Mon, 24 Mar 2025
 02:43:18 -0700 (PDT)
MIME-Version: 1.0
From: Daniel Clemente <n142857@HIDDEN>
Date: Mon, 24 Mar 2025 09:42:52 +0000
X-Gm-Features: AQ5f1JoKKSPfUWrAkOV9lyik6CRSh8pHukGwKH9uHEQYUF3EVj7QMILNcn8BvsQ
Message-ID: <CAJKAhPCBJUoxuK-9HSBfyvstsJE3n4YJUSY-EMav_75DUYcFGQ@HIDDEN>
Subject: 31.0.50; crash if message starts with a space and then without it
To: bug-gnu-emacs@HIDDEN
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Received-SPF: pass client-ip=2607:f8b0:4864:20::936;
 envelope-from=n142857@HIDDEN; helo=mail-ua1-x936.google.com
X-Spam_score_int: -17
X-Spam_score: -1.8
X-Spam_bar: -
X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 1.2 (+)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview:  Believe it or not,
 this crashes each time. Open emacs -Q (with
 or without daemon) in a TTY, and evaluate the first part and then the progn:
 (modify-frame-parameters (selected-frame) '( ;; background-color needs to
 be defined, to crash. The precise color doesn't matter (background-color
 . "#111") ;; Doesn't affect the crash: ;; (foreground [...] 
 Content analysis details:   (1.2 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 0.0 FREEMAIL_FROM          Sender email is commonly abused enduser mail
 provider (n142857[at]gmail.com)
 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends
 in digit (n142857[at]gmail.com)
 -0.0 SPF_HELO_PASS          SPF: HELO matches SPF record
 1.0 SPF_SOFTFAIL           SPF: sender does not match SPF record (softfail)
 -0.0 RCVD_IN_DNSWL_NONE     RBL: Sender listed at https://www.dnswl.org/,
 no trust [2001:470:142:0:0:0:0:17 listed in] [list.dnswl.org]
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.2 (/)

Believe it or not, this crashes each time. Open emacs -Q (with or
without daemon) in a TTY, and evaluate the first part and then the progn:

(modify-frame-parameters (selected-frame) '(
      ;; background-color needs to be defined, to crash. The precise
color doesn't matter
      (background-color . "#111")
      ;; Doesn't affect the crash:
      ;; (foreground-color . "#c0c0c0")
     ))
(progn
  (message " AB")
  (message "AB")
)

Conditions for this crash:
- the same message must have appeared with an initial space and
without an initial space. Use " ABC" and "AB" and it won't crash,
because ABC !=3D AB. But use " ABC" and "ABC" and it crashes
- it must be in this order: first with space, then without
- both messages must be contained in a progn or in a let/while/defun=E2=80=
=A6
If you evaluate each message separately, it works
- the background-color needs to be set
- there must only be 1 space in the beginning. With 2 spaces or 1 tab
or 1 dot it works. Space in the end also works

This is with latest Emacs compiled right now. It seems due to recent
changes since I didn't see it in my previous version (~2 weeks old),
but I'm not sure and I didn't have time to do bisecting. Line numbers
in my
backtrace might be off by 1 since I added some lines with comments
(but it also crashes without my edits).

Discovered by running zone-pgm-stress, which triggers the condition.

Crash:

Breakpoint 1, terminate_due_to_signal (sig=3D6, backtrace_limit=3D40) at em=
acs.c:425
425      signal (sig, SIG_DFL);
(gdb) bt
#0  terminate_due_to_signal (sig=3D6, backtrace_limit=3D40) at emacs.c:425
#1  0x00005555556cb0b7 in emacs_abort () at sysdep.c:2378
#2  0x00005555556730a9 in cmcheckmagic (tty=3D0x555555a983a0) at cm.c:122
#3  0x0000555555677abd in tty_write_glyphs_1 (f=3D0x555555aa46e0,
string=3D0x7ffff6ea3670, len=3D1)
    at term.c:816
#4  0x0000555555678430 in tty_write_glyphs (f=3D0x555555aa46e0,
string=3D0x7ffff6ea3638, len=3D1)
    at term.c:992
#5  0x000055555568358b in write_glyphs (f=3D0x555555aa46e0,
string=3D0x7ffff6ea3638, len=3D1)
    at terminal.c:182
#6  0x0000555555593388 in write_row (f=3D0x555555aa46e0, vpos=3D60,
updating_menu_p=3Dfalse)
    at dispnew.c:6159
#7  0x00005555555912d1 in write_matrix (f=3D0x555555aa46e0,
inhibit_id_p=3Dtrue, updating_menu_p=3Dfalse)
    at dispnew.c:5746
#8  0x000055555558d69b in combine_updates_for_frame (f=3D0x555555aa46e0,
inhibit_scrolling=3Dtrue)
    at dispnew.c:4053
#9  0x00005555555cebfc in echo_area_display (update_frame_p=3Dtrue) at
xdisp.c:13562
#10 0x00005555555ca99e in message3_nolog (m=3DXIL(0x555555da1a04)) at
xdisp.c:12460
#11 0x00005555555ca64c in message3 (m=3DXIL(0x555555da1a04)) at xdisp.c:123=
90
#12 0x000055555576f5c1 in Fmessage (nargs=3D1, args=3D0x7fffffffbb00) at
editfns.c:3127
[=E2=80=A6]
(gdb) frame 2
#2  0x00005555556730a9 in cmcheckmagic (tty=3D0x555555a983a0) at cm.c:122
122        emacs_abort ();
(gdb) list
117      if (frame_size_change_delayed (XFRAME (tty->top_frame)))
118        return;
119      if (curX (tty) =3D=3D FrameCols (tty))
120        {
121          if (!MagicWrap (tty) || curY (tty) >=3D FrameRows (tty) - 1)
122        emacs_abort ();
123          if (tty->termscript)
124        putc ('\r', tty->termscript);
125          putc ('\r', tty->output);
126          if (tty->termscript)
(gdb) p curY(tty)
$1 =3D 60
(gdb) p FrameRows(tty)-1
$2 =3D 60
(gdb) p FrameCols(tty)
$3 =3D 100
(gdb)




In GNU Emacs 31.0.50 (build 28, x86_64-pc-linux-gnu) of 2025-03-24 built
 on sonn
Repository revision: 0cfe700e336da3cc5a2a766840d375921dcd5ee9
Repository branch: master
System Description: Devuan GNU/Linux 5 (daedalus)

Configured using:
 'configure --prefix=3D/opt/dc/emacs-dev/ --with-tiff=3Dno --without-tiff
 --without-libsystemd --without-dbus --with-mailutils --without-modules
 --with-native-compilation=3Dno --with-x-toolkit=3Dno --without-imagemagick
 --without-xft --without-harfbuzz --without-freetype --without-libotf
 --without-xwidgets --without-xpm --without-jpeg --without-gif
 --without-png --without-webp --without-rsvg --without-cairo --without-x
 --without-sound --enable-checking=3Dyes,glyphs --enable-profiling CC=3Dgcc
 'CFLAGS=3D-g3 -O0 ''

Configured features:
GMP GNUTLS LCMS2 LIBSELINUX LIBXML2 NOTIFY INOTIFY PDUMPER SECCOMP
SQLITE3 THREADS XIM ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=3DSCIM
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  server-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  minibuffer-regexp-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
/w/emacs-dev/lisp/pulse hides /w/emacs-dev/lisp/cedet/pulse

Features:
(shadow sort hashcash pcase cl-macs regexp-opt mail-extr emacsbug
message mailcap yank-media puny dired dnd dired-loaddefs rfc822 mml
mml-sec password-cache epa derived epg rfc6068 epg-config gnus-util
text-property-search time-date subr-x mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader cl-loaddefs cl-lib
sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
term/rxvt term/xterm xterm byte-opt gv bytecomp byte-compile server rmc
iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook
vc-hooks lisp-float-type elisp-mode tabulated-list replace newcomment
text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow
isearch easymenu timer select mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads inotify lcms2 multi-tty
make-network-process tty-child-frames emacs)

Memory information:
((conses 16 52990 10439) (symbols 48 6510 1) (strings 32 16235 1652)
 (string-bytes 1 429445) (vectors 16 8416) (vector-slots 8 76621 5913)
 (floats 8 33 11518) (intervals 56 248 14) (buffers 984 12))




Acknowledgement sent to Daniel Clemente <n142857@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#77233; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Thu, 27 Mar 2025 17:30:02 UTC

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