unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#24633: highlight-region func using (window-hscroll) in :align-to spec can cause inf loop
@ 2016-10-07  1:01 npostavs
  2016-10-08 11:15 ` Eli Zaretskii
  0 siblings, 1 reply; 11+ messages in thread
From: npostavs @ 2016-10-07  1:01 UTC (permalink / raw)
  To: 24633

[-- Attachment #1: Type: text/plain, Size: 1002 bytes --]

Version: 25.1 24.5

This is sort of a continuation from Bug #21468 (see
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=21468#46 and the
following).  The overlay with newline approach did indeed turn up some
more problems, so we tried moving to the :overline :underline text
method for Emacs 25, but it turns out this causes Emacs to freeze in
certain circumstances (see
https://github.com/magit/magit/issues/2758#issuecomment-250838301).

There is some sentiment to abandon the horizontal bar effect and settle
for just applying a face, but I think this is a bug in Emacs that should
be fixed regardless.  Or maybe it's just a case of "if it hurts, dont do
it"? (using (window-hscroll) in :align-to specs, that is)

-----------------------

With the code below as overlay-bars.el, run

    emacs -Q overlay-bars.el -l overlay-bars.el

then move point to the end of the long line with all the semicolons, hit
C-SPC, and then C-n.  Emacs gets stuck in an infinite loop that cannot
be interrupted by C-g.


[-- Attachment #2: demo code --]
[-- Type: text/plain, Size: 1338 bytes --]

(require 'cl-lib)

(defvar-local 21468-region-overlays nil)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;

(defun 21468-update-hunk-region (start end window rol)
  (mapc #'delete-overlay 21468-region-overlays)
  (cl-flet ((ov (start end &rest args)
                (let ((ov (make-overlay start end nil t)))
                  (while args (overlay-put ov (pop args) (pop args)))
                  (push ov 21468-region-overlays)
                  ov)))
    (let* ((align (list 'space :align-to
                        `(+ ,(window-hscroll) (0 . right))))
           (rend-line (save-excursion (goto-char end)
                                      (cons (line-beginning-position)
                                            (line-end-position))))
           (face (list :underline (face-background 'highlight nil t))))
      (message "align = %S" align)
      (ov (car rend-line) (cdr rend-line) 'face face
          'after-string (propertize "\s" 'face face 'display align 'cursor t)))))

(setq-local redisplay-highlight-region-function '21468-update-hunk-region)

(setq-local redisplay-unhighlight-region-function
            (lambda (rol) (mapc #'delete-overlay 21468-region-overlays)))

(setq-local truncate-lines t)

[-- Attachment #3: Type: text/plain, Size: 2648 bytes --]


If the frame is split vertically with C-x 2 first, then Emacs doesn't
get stuck, but does the equivalent of (scroll-left 4) about once per
second; this can be interrupted by C-g.

Modifying the :align-to expression to `(+ ,(1- (window-hscroll)) (0
. right)) causes this assertion failure after some looping:

xdisp.c:19474: Emacs fatal error: assertion failed: row->pixel_width >= 0

Thread 1 "emacs" hit Breakpoint 1, terminate_due_to_signal (sig=6, backtrace_limit=2147483647)
    at emacs.c:354
354	  signal (sig, SIG_DFL);
(gdb) bt
#0  terminate_due_to_signal (sig=6, backtrace_limit=2147483647) at emacs.c:354
#1  0x00000000005fb0aa in die (msg=0x6f64c2 "row->pixel_width >= 0", file=0x6f3450 "xdisp.c", 
    line=19474) at alloc.c:7223
#2  0x0000000000479b64 in compute_line_metrics (it=0x7fffffff9110) at xdisp.c:19474
#3  0x0000000000481e07 in display_line (it=0x7fffffff9110) at xdisp.c:21234
#4  0x0000000000471b56 in try_window (window=21548085, pos=..., flags=1) at xdisp.c:17246
#5  0x000000000046e6ae in redisplay_window (window=21548085, just_this_one_p=true) at xdisp.c:16695
#6  0x00000000004665a3 in redisplay_window_1 (window=21548085) at xdisp.c:14494
#7  0x000000000061b092 in internal_condition_case_1 (bfun=0x466561 <redisplay_window_1>, 
    arg=21548085, handlers=14582547, hfun=0x4664db <redisplay_window_error>) at eval.c:1338
#8  0x00000000004657c2 in redisplay_internal () at xdisp.c:14119
#9  0x0000000000462ca2 in redisplay () at xdisp.c:13254
#10 0x00000000005768ea in read_char (commandflag=1, map=26212659, prev_event=0, 
    used_mouse_menu=0x7fffffffe36f, end_time=0x0) at keyboard.c:2477
#11 0x00000000005866f7 in read_key_sequence (keybuf=0x7fffffffe520, bufsize=30, prompt=0, 
    dont_downcase_last=false, can_return_switch_frame=true, fix_current_buffer=true, 
    prevent_redisplay=false) at keyboard.c:9063
#12 0x000000000057386d in command_loop_1 () at keyboard.c:1365
#13 0x000000000061aff8 in internal_condition_case (bfun=0x573431 <command_loop_1>, handlers=19056, 
    hfun=0x572ac3 <cmd_error>) at eval.c:1314
#14 0x0000000000573073 in command_loop_2 (ignore=0) at keyboard.c:1107
#15 0x000000000061a5c7 in internal_catch (tag=45888, func=0x57304a <command_loop_2>, arg=0)
    at eval.c:1079
#16 0x0000000000573015 in command_loop () at keyboard.c:1086
#17 0x00000000005725b3 in recursive_edit_1 () at keyboard.c:692
#18 0x00000000005727b3 in Frecursive_edit () at keyboard.c:763
#19 0x0000000000570560 in main (argc=5, argv=0x7fffffffe9b8) at emacs.c:1626

Lisp Backtrace:
"redisplay_internal (C function)" (0x0)

I see the same failure *without* modifying the :align-to expression on
Emacs 24.5.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2016-10-22 20:43 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-07  1:01 bug#24633: highlight-region func using (window-hscroll) in :align-to spec can cause inf loop npostavs
2016-10-08 11:15 ` Eli Zaretskii
2016-10-08 17:17   ` npostavs
2016-10-08 18:01     ` Eli Zaretskii
2016-10-08 19:18       ` npostavs
2016-10-08 19:57         ` Eli Zaretskii
2016-10-09 12:29           ` npostavs
2016-10-09 12:42             ` Eli Zaretskii
2016-10-22 19:27               ` npostavs
2016-10-22 19:41                 ` Eli Zaretskii
2016-10-22 20:43                   ` npostavs

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).