From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ari Roponen Newsgroups: gmane.emacs.bugs Subject: bug#11464: 24.1.50; pos-visible-in-window-p returns a false positive with bidi text Date: Fri, 18 May 2012 13:47:26 +0300 Message-ID: <87obplepfl.fsf@gmail.com> References: <87y5owjcto.fsf@gmail.com> <83pqa8vsxw.fsf@gnu.org> <87fwb1dagj.fsf_-_@gmail.com> <83wr4do1qv.fsf@gnu.org> <87bolor98t.fsf@gmail.com> <83sjf0nolt.fsf@gnu.org> <87pqa3csuc.fsf@gmail.com> <83likqojxl.fsf@gnu.org> <83fwayo6mz.fsf@gnu.org> <83ehqindec.fsf@gnu.org> <87wr49ex07.fsf@gmail.com> <83vcjtswst.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1337338078 10398 80.91.229.3 (18 May 2012 10:47:58 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 18 May 2012 10:47:58 +0000 (UTC) Cc: 11464@debbugs.gnu.org, mwd@cert.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri May 18 12:47:56 2012 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 1SVKix-0003aj-80 for geb-bug-gnu-emacs@m.gmane.org; Fri, 18 May 2012 12:47:55 +0200 Original-Received: from localhost ([::1]:59672 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SVKiw-000127-7a for geb-bug-gnu-emacs@m.gmane.org; Fri, 18 May 2012 06:47:54 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:48488) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SVKip-00011j-Dz for bug-gnu-emacs@gnu.org; Fri, 18 May 2012 06:47:52 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SVKik-0000Em-FO for bug-gnu-emacs@gnu.org; Fri, 18 May 2012 06:47:46 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:50666) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SVKik-0000Eh-8y for bug-gnu-emacs@gnu.org; Fri, 18 May 2012 06:47:42 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1SVKj4-0005PA-5k for bug-gnu-emacs@gnu.org; Fri, 18 May 2012 06:48:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ari Roponen Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 18 May 2012 10:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 11464 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 11464-submit@debbugs.gnu.org id=B11464.133733807920767 (code B ref 11464); Fri, 18 May 2012 10:48:02 +0000 Original-Received: (at 11464) by debbugs.gnu.org; 18 May 2012 10:47:59 +0000 Original-Received: from localhost ([127.0.0.1]:60212 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SVKj0-0005Ot-H9 for submit@debbugs.gnu.org; Fri, 18 May 2012 06:47:59 -0400 Original-Received: from mail-lb0-f172.google.com ([209.85.217.172]:34704) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SVKix-0005Od-JP for 11464@debbugs.gnu.org; Fri, 18 May 2012 06:47:57 -0400 Original-Received: by lbbgo11 with SMTP id go11so1866978lbb.3 for <11464@debbugs.gnu.org>; Fri, 18 May 2012 03:47:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=Hwj9d89VVbLM9qm1khZBl6ppKa70XB6k//LQycCv4xY=; b=gxcaSqM0oIRuV2chPc2jTSz3o4CodpuB5uUzZ1YetRf7BbSjWcxOOmj8JY83GA8aEA wZr+ZEhnfk8OKRXXo12wSu4L87KJuDuS/oqm+tRdIdnd9k1qkf4rJQ4Kbbd2egNLI/Vy DjUHOTSbZ8qcHOiZ5j/MH+kYZD50TN8XTzJJlzRj19lUUSFNUBfUFjds7lfsa29QoXEj S84Tu3QH6blKT3B6q5PfUZioDkd/3Cki3Y9jB81suFas+8kPnjPt0MSqlavirBbgi+IV gi0MahLUrpSi/opK1KdohJx9JyAVwbfnLdXWHGRZxSGf/W9vIVki3eN8HVPOIfjEWP+A kfhQ== Original-Received: by 10.152.48.37 with SMTP id i5mr4198442lan.36.1337338048887; Fri, 18 May 2012 03:47:28 -0700 (PDT) Original-Received: from arirop (dsl-jklbrasgw1-fe82df00-79.dhcp.inet.fi. [80.223.130.79]) by mx.google.com with ESMTPS id mo3sm11912865lab.2.2012.05.18.03.47.27 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 18 May 2012 03:47:28 -0700 (PDT) In-Reply-To: <83vcjtswst.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 18 May 2012 11:44:34 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:60172 Archived-At: Eli Zaretskii writes: > And if that happens, the correction code below, viz.: > > if (bottom_y <= it.last_visible_y > && it.bidi_p && it.bidi_it.scan_dir == -1 > && IT_CHARPOS (it) < charpos) > > would evaluate to false, and visible_p would have stayed at its 1 > value, which is wrong. > > So could you please clarify this case? Yes, pos_visible_p indeed returns incorrect value (1), but it is called from Fpos_visible_in_window_p, which returns the correct value. For longer description, see below. > > Also, what was the value of top_y in your first case, i.e.: > >> bottom_y = 300 >> it.last_visible_y = 304 That case has the following values now (in emacs-24 rev. 108005): bottom_y = 302 it.last_visible_y = 304 top_y = 285 I'm not sure why bottom_y has changed its value. I guess that is because I installed some new fonts. > > Again, sorry for bothering you with the details. I just must > understand what is going on here and where did I err in my original > change. No worries. Here are some logs from my debugging sessions. I don't pretend to know the code, but this shows why the bug didn't happen in the last case ("emacs -fn fixed"). I tried emacs-24 revision 108005, compiled with "-O0 -ggdb". File bug.el contains this: (progn (pop-to-buffer (get-buffer-create "test")) (erase-buffer) (dotimes (i (* 2 (window-height))) (insert "\u05d0\n")) ; HEBREW LETTER ALEF (insert "Last line\n") (goto-char (point-min)) (insert "a") (message "Should be nil: %S" (pos-visible-in-window-p (point-max)))) The function pos_visible_p returns the incorrect value (1): [src]$ gdb --quiet --args ./emacs -Q -fn fixed -l bug.el Reading symbols from /usr/local/repos/bzr/emacs/emacs-24/src/emacs...done. warning: File "/usr/local/repos/bzr/emacs/emacs-24/src/.gdbinit" auto-loading has been declined by your `auto-load safe-path' set to "/usr/share/gdb/auto-load:/usr/lib/debug:/usr/bin/mono-gdb.py". (gdb) source .gdbinit SIGINT is used by the debugger. Are you sure you want to change it? (y or n) [answered Y; input not from terminal] DISPLAY = :0 TERM = xterm Breakpoint 1 at 0x5623fd: file emacs.c, line 394. Temporary breakpoint 2 at 0x588153: file sysdep.c, line 859. (gdb) b xdisp.c:1311 Breakpoint 3 at 0x4311d1: file xdisp.c, line 1311. (gdb) b xdisp.c:1566 Breakpoint 4 at 0x4324d2: file xdisp.c, line 1566. (gdb) r Starting program: /usr/local/repos/bzr/emacs/emacs-24/src/emacs -Q -fn fixed -l bug.el [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". [New Thread 0x7fffe4578700 (LWP 28308)] [New Thread 0x7fffe3d77700 (LWP 28309)] Breakpoint 3, pos_visible_p (w=0x13dbd90, charpos=80, x=0x7fffffffb78c, y= 0x7fffffffb788, rtop=0x7fffffffb79c, rbot=0x7fffffffb798, rowh= 0x7fffffffb794, vpos=0x7fffffffb790) at xdisp.c:1312 1312 if (top_y < window_top_y) Missing separate debuginfos, use: debuginfo-install [...] (gdb) p visible_p $1 = 0 (gdb) n 1314 else if (top_y < it.last_visible_y) (gdb) 1315 visible_p = 1; (gdb) 1316 if (bottom_y <= it.last_visible_y (gdb) 1341 if (visible_p) (gdb) p visible_p $2 = 1 (gdb) c Continuing. Breakpoint 4, pos_visible_p (w=0x13dbd90, charpos=80, x=0x7fffffffb78c, y= 0x7fffffffb788, rtop=0x7fffffffb79c, rbot=0x7fffffffb798, rowh= 0x7fffffffb794, vpos=0x7fffffffb790) at xdisp.c:1566 1566 return visible_p; (gdb) p visible_p $3 = 1 (gdb) The reason the test case works is that the function Fpos_visible_in_window_p contains this: /* If position is above window start or outside buffer boundaries, or if window start is out of range, position is not visible. */ if ((EQ (pos, Qt) || (posint >= CHARPOS (top) && posint <= BUF_ZV (buf))) && CHARPOS (top) >= BUF_BEGV (buf) && CHARPOS (top) <= BUF_ZV (buf) && pos_visible_p (w, posint, &x, &y, &rtop, &rbot, &rowh, &vpos) && (fully_p = !rtop && !rbot, (!NILP (partially) || fully_p))) in_window = Qt; Here pos_visible_p returns 1, but the next condition evaluates to false, since (!NILP (partially) || fully_p) is false. [src]$ gdb --quiet --args ./emacs -Q -fn fixed -l bug.el Reading symbols from /usr/local/repos/bzr/emacs/emacs-24/src/emacs...done. warning: File "/usr/local/repos/bzr/emacs/emacs-24/src/.gdbinit" auto-loading has been declined by your `auto-load safe-path' set to "/usr/share/gdb/auto-load:/usr/lib/debug:/usr/bin/mono-gdb.py". (gdb) source .gdbinit SIGINT is used by the debugger. Are you sure you want to change it? (y or n) [answered Y; input not from terminal] DISPLAY = :0 TERM = xterm Breakpoint 1 at 0x5623fd: file emacs.c, line 394. Temporary breakpoint 2 at 0x588153: file sysdep.c, line 859. (gdb) b Fpos_visible_in_window_p Breakpoint 3 at 0x48a5db: file window.c, line 1431. (gdb) r Starting program: /usr/local/repos/bzr/emacs/emacs-24/src/emacs -Q -fn fixed -l bug.el [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". [New Thread 0x7fffe4578700 (LWP 28471)] [New Thread 0x7fffe3d77700 (LWP 28472)] Breakpoint 3, Fpos_visible_in_window_p (pos=320, window=12763682, partially= 12763682) at window.c:1431 1431 Lisp_Object in_window = Qnil; Missing separate debuginfos, use: debuginfo-install [..] (gdb) n 1432 int rtop, rbot, rowh, vpos, fully_p = 1; (gdb) 1435 w = decode_window (window); (gdb) 1436 buf = XBUFFER (w->buffer); (gdb) 1437 SET_TEXT_POS_FROM_MARKER (top, w->start); (gdb) 1439 if (EQ (pos, Qt)) (gdb) 1441 else if (!NILP (pos)) (gdb) 1443 CHECK_NUMBER_COERCE_MARKER (pos); (gdb) 1444 posint = XINT (pos); (gdb) 1453 if ((EQ (pos, Qt) (gdb) 1454 || (posint >= CHARPOS (top) && posint <= BUF_ZV (buf))) (gdb) 1455 && CHARPOS (top) >= BUF_BEGV (buf) (gdb) 1456 && CHARPOS (top) <= BUF_ZV (buf) (gdb) 1457 && pos_visible_p (w, posint, &x, &y, &rtop, &rbot, &rowh, &vpos) (gdb) 1458 && (fully_p = !rtop && !rbot, (!NILP (partially) || fully_p))) (gdb) 1461 if (!NILP (in_window) && !NILP (partially)) (gdb) xprintsym in_window "nil"(gdb) p fully_p $1 = 0 (gdb) xprintsym partially "nil"(gdb) n 1471 return in_window; (gdb) -- Ari Roponen