From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#5131: Subject: 23.1; interaction of transpose-regions with markers and multibyte chars Date: Tue, 19 Jul 2016 19:05:09 +0300 Message-ID: <8360s11umi.fsf@gnu.org> References: <20091206042206.10974kro2g12qlhq@webmail.tau.ac.il> <874m7oeus5.fsf@users.sourceforge.net> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1468944390 3031 80.91.229.3 (19 Jul 2016 16:06:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 19 Jul 2016 16:06:30 +0000 (UTC) Cc: ahyatt@gmail.com, schochet@post.tau.ac.il, 5131-done@debbugs.gnu.org To: npostavs@users.sourceforge.net Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jul 19 18:06:20 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bPXXF-0005f0-Hb for geb-bug-gnu-emacs@m.gmane.org; Tue, 19 Jul 2016 18:06:17 +0200 Original-Received: from localhost ([::1]:57036 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPXXE-0000vO-PQ for geb-bug-gnu-emacs@m.gmane.org; Tue, 19 Jul 2016 12:06:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:32890) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPXX6-0000sq-9p for bug-gnu-emacs@gnu.org; Tue, 19 Jul 2016 12:06:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bPXX0-0005ma-3d for bug-gnu-emacs@gnu.org; Tue, 19 Jul 2016 12:06:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:45150) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPXX0-0005mQ-0I for bug-gnu-emacs@gnu.org; Tue, 19 Jul 2016 12:06:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bPXWz-0002gf-Qk for bug-gnu-emacs@gnu.org; Tue, 19 Jul 2016 12:06:01 -0400 Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Tue, 19 Jul 2016 16:06:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 5131 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Mail-Followup-To: 5131@debbugs.gnu.org, eliz@gnu.org, schochet@post.tau.ac.il Original-Received: via spool by 5131-done@debbugs.gnu.org id=D5131.146894433610290 (code D ref 5131); Tue, 19 Jul 2016 16:06:01 +0000 Original-Received: (at 5131-done) by debbugs.gnu.org; 19 Jul 2016 16:05:36 +0000 Original-Received: from localhost ([127.0.0.1]:57486 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bPXWZ-0002ft-QK for submit@debbugs.gnu.org; Tue, 19 Jul 2016 12:05:36 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:41585) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bPXWX-0002fg-2n for 5131-done@debbugs.gnu.org; Tue, 19 Jul 2016 12:05:34 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bPXWO-0005Q9-DC for 5131-done@debbugs.gnu.org; Tue, 19 Jul 2016 12:05:27 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:46999) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPXWO-0005Pk-A8; Tue, 19 Jul 2016 12:05:24 -0400 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:3508 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1bPXWK-0001MP-EN; Tue, 19 Jul 2016 12:05:22 -0400 In-reply-to: <874m7oeus5.fsf@users.sourceforge.net> (npostavs@users.sourceforge.net) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:121267 Archived-At: > From: npostavs@users.sourceforge.net > Date: Sun, 17 Jul 2016 00:46:34 -0400 > Cc: schochet@post.tau.ac.il, 5131@debbugs.gnu.org > > Andrew Hyatt writes: > > > Sorry for the late reply. I can reproduce the problem of unexpected > > characters when transposing using markers in Emacs 25. > > > > schochet@post.tau.ac.il writes: > > > >> ;-*- mode: lisp-interaction; coding: utf-8-unix -*- > >> > >> ; case 1: abcd was: abcd > >> ; case 2: ÷bcd was: ÷bcd > >> ; case 3: ÷ab"äé was: ÷ab"äé > >> > >> (progn (defvar start nil) (defvar len nil)) ;do \C-j here > >> > >> ; Using markers to move multi-byte characters may cause problems > >> > >> (progn (setq begm (make-marker)) (setq endm (make-marker))) ;do \C-j here > >> > >> (defun reverse-all () > >> (set-marker begm start) > >> (set-marker endm (+ start (1- len))) > >> (while (> endm begm) > >> (progn (transpose-regions begm (1+ begm) endm (1+ endm) t) > >> (set-marker begm (1+ begm)) > >> (set-marker endm (1- endm))))) ;do \C-j here > >> > >> ;case1 > >> (progn (setq start 64) (setq len 4) (reverse-all)) ;do \C-j here > >> > >> ;case2 > >> (progn (setq start 94) (setq len 4) (reverse-all)) ;do \C-j here > >> > >> ;case3 > >> (progn (setq start 124) (setq len 6) (reverse-all)) ;do \C-j here > > With the latest emacs-25 branch after evaluating up to case3 here, I get > an abort, here is the backtrace: > > (gdb) bt > #0 0x00007ffff1218d59 in raise () from /usr/lib/libpthread.so.0 > #1 0x00000000005738c4 in terminate_due_to_signal (sig=6, backtrace_limit=2147483647) at emacs.c:381 > #2 0x0000000000600d84 in die (msg=0x6f4140 "IT_BYTEPOS (*it) == CHAR_TO_BYTE (IT_CHARPOS (*it))", file=0x6f1ff0 "xdisp.c", > line=7442) at alloc.c:7223 > #3 0x0000000000452c1c in set_iterator_to_next (it=0x7fffffff90f0, reseat_p=true) at xdisp.c:7442 That's because your build is with --enable-checking, while Andrew's probably isn't. This recipe causes some markers to have invalid bytepos values, so any code that calls CHAR_TO_BYTE is likely to crash or cause assertion violations. It feels strange to fix bugs that were introduced 18 years ago; I guess almost no one invokes transpose-regions with last argument non-nil. Fixed on the master branch. I'm closing the bug; feel free to reopen if there are some left-overs. Thanks.