From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#70122: 29.3.50; transpose-regions can crash Emacs Date: Thu, 04 Apr 2024 07:48:46 +0300 Message-ID: <86frw191ht.fsf@gnu.org> References: <2318820.ElGaqSPkdT@gabor> <86wmph9u1i.fsf@gnu.org> <86ttkl9q9b.fsf@gnu.org> <3216728.5fSG56mABF@gabor> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26580"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 70122@debbugs.gnu.org To: Braun =?UTF-8?Q?G=C3=A1bor?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Apr 04 06:50:08 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rsF39-0006eO-Q7 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 04 Apr 2024 06:50:08 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rsF32-0001cl-Mc; Thu, 04 Apr 2024 00:50:00 -0400 Original-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 ) id 1rsF2z-0001cW-OL for bug-gnu-emacs@gnu.org; Thu, 04 Apr 2024 00:49:57 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rsF2z-0001eR-Fg for bug-gnu-emacs@gnu.org; Thu, 04 Apr 2024 00:49:57 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rsF34-0001SC-5r for bug-gnu-emacs@gnu.org; Thu, 04 Apr 2024 00:50:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 04 Apr 2024 04:50:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70122 X-GNU-PR-Package: emacs Original-Received: via spool by 70122-submit@debbugs.gnu.org id=B70122.17122061485335 (code B ref 70122); Thu, 04 Apr 2024 04:50:02 +0000 Original-Received: (at 70122) by debbugs.gnu.org; 4 Apr 2024 04:49:08 +0000 Original-Received: from localhost ([127.0.0.1]:60138 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rsF2B-0001Nv-RI for submit@debbugs.gnu.org; Thu, 04 Apr 2024 00:49:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51064) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rsF29-0001Mp-DG for 70122@debbugs.gnu.org; Thu, 04 Apr 2024 00:49:06 -0400 Original-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 ) id 1rsF1w-0001IW-Ip; Thu, 04 Apr 2024 00:48:53 -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=VWHZqM2AomXn8HU+AiRR9OP4JLjrf5G43pACF64wURY=; b=KoR/FUplntYBw6/519V8 NP1egiI1XlzvoXjd/nROECjbRjoP99lMBhqimviRLw9s1YbGnXAZ1b4qkCs9pdoQXveuYjiuE4YgZ /xGOybkcZsTIKzP8C6jadRH9FnL0u8+bEguROBJV6FKUqxIjoT8WIdE+AqhQC07tCXQp0vCVtZmUR VLgTUyv8JTU8EOeMbqcgkJqfiQYFpw4/u0gJ4E5Ka5vhlRsAJwVnyYfkkKggMSGTTGYQA8yY3Ondl i3H0Piv8GLQzBwN/El8X9MpuKA1CYMwzqk+WkJXusO2SLIRQROtZZOQz72MVd147Jrj3HpI/2dlRp 6WZEcjt55RS+EQ==; In-Reply-To: <3216728.5fSG56mABF@gabor> (message from Braun =?UTF-8?Q?G=C3=A1bor?= on Wed, 03 Apr 2024 20:52:47 +0200) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:282615 Archived-At: > From: Braun Gábor > Cc: 70122@debbugs.gnu.org > Date: Wed, 03 Apr 2024 20:52:47 +0200 > > I've attached a new self-contained patch based on yours, > thank you for coming up with it. > > In my opinion, one of the problems is really as you said > that len_mid (length in bytes) > is uses where length of characters is expected. > The patch contains an additional such case, > and replaces (start1 + len1) in your patch with the equivalent > but shorter end1. > > The other problem is that the branch len1_byte == len2_byte > assumes len1 == len2 in several places: > undo records, positions after the transposition, > and the least obvious one is that even intervals between the > region seem to need adjustment of positions. Can we lift that restriction by augmenting the len1_byte == len2_byte branch so that the len1 == len2 condition is not needed? > (I don't know enough of intervals to understand it, but had failed > tests with text properties at wrong places.) Intervals work with character positions, that's all. Any call to functions that examine or modify intervals should use character positions, not byte positions, and accordingly length in terms of characters, not bytes. Is this sufficient for you to come up with changes to remove the len1 == len2 restriction from that branch? > Anyway, I've just added len1 == len2 as a condition to that branch > with comments where I think the assumption is used. If we cannot easily lift that restriction, that is the right fallback, yes. > I've also added a new test for this case. Thanks. > > The patch > > below passes both your test and the already-existing tests in > > test/src/editfns-tests.el. > > For me after applying your patch, the tests crashed. > The crash message was hidden in the end of the output: > > passed 21/24 transpose-nonascii-regions-test-1 (0.000067 sec) > passed 22/24 transpose-nonascii-regions-test-2 (0.000068 sec) > passed 23/24 transpose-regions-text-properties (0.000074 sec) > Undo > Undo > make[1]: *** [Makefile:181: src/editfns-tests.log] segmentation > fault > make[1]: Leaving directory "/home/gabor/src/build/emacs-29.3/test" > make: *** [Makefile:247: src/editfns-tests] Error 2 This says the test that crashed was the one of the two new ones you added, and it is different from the one you presented at the beginning of this bug report. So it is a small wonder I didn't see any crash in my testing. > With the tests I intended to test all the branches in the code > where the regions don't touch each other, catching mistakes > where the wrong length is used. Can we also have a test where the byte lengths are equal, but the character lengths aren't? > I hoped that byte length is not system dependent, It isn't, not if you consider the internal representation of characters in Emacs buffers and strings. > So what differences exist or byte length? I don't think there are differences, but if you show an example where you see such a difference, we can discuss the example and see what happens there. Last, but not least: with the added tests your patch becomes larger than what we can accept without your assigning the copyright to the FSF. Would you like to start the legal paperwork of copyright assignment at this time, so that we could accept all of your contributions without limitations, including any future contributions? If yes, I will send you the form to fill and instructions to email the filled form, to start the process. Thanks.