wolray / symbol-overlay

Highlight symbols with keymap-enabled overlays
346 stars 42 forks source link

args-out-of-range error #64

Closed seagle0128 closed 4 years ago

seagle0128 commented 4 years ago
Debugger entered--Lisp error: (args-out-of-range 1 226)
  symbol-overlay-narrow(nil t)
  symbol-overlay-maybe-put-temp()
  apply(symbol-overlay-maybe-put-temp nil)
  timer-event-handler([t 0 0 100000 t symbol-overlay-maybe-put-temp nil idle 0])
  accept-process-output(#<process emacsql-sqlite> 30)
  #f(compiled-function (connection &optional timeout) "Block until CONNECTION is waiting for further input." #<bytecode 0x1ffbed32b0d9>)(#<forge-database forge-database-1ffbee23a43c>)
  apply(#f(compiled-function (connection &optional timeout) "Block until CONNECTION is waiting for further input." #<bytecode 0x1ffbed32b0d9>) #<forge-database forge-database-1ffbee23a43c> nil)
  emacsql-wait(#<forge-database forge-database-1ffbee23a43c>)
  #f(compiled-function (connection sql &rest args) "Send SQL s-expression to CONNECTION and return the results." #<bytecode 0x1ffbed32d8ed>)(#<forge-database forge-database-1ffbee23a43c> [:select * :from repository :where (and (= forge $s1) (= owner $s2) (= name $s3))] "github.com" "ztlevi" "python-test2")
  apply(#f(compiled-function (connection sql &rest args) "Send SQL s-expression to CONNECTION and return the results." #<bytecode 0x1ffbed32d8ed>) (#<forge-database forge-database-1ffbee23a43c> [:select * :from repository :where (and (= forge $s1) (= owner $s2) (= name $s3))] "github.com" "ztlevi" "python-test2"))
  #f(compiled-function (&rest cnm-args) #<bytecode 0x1ffbe0738bed>)(#<forge-database forge-database-1ffbee23a43c> [:select * :from repository :where (and (= forge $s1) (= owner $s2) (= name $s3))] "github.com" "ztlevi" "python-test2")
  apply(#f(compiled-function (&rest cnm-args) #<bytecode 0x1ffbe0738bed>) #<forge-database forge-database-1ffbee23a43c> [:select * :from repository :where (and (= forge $s1) (= owner $s2) (= name $s3))] ("github.com" "ztlevi" "python-test2"))
  #f(compiled-function (connection sql &rest args) #<bytecode 0x1ffbee2caea1>)(#f(compiled-function (&rest cnm-args) #<bytecode 0x1ffbe0738bed>) #<forge-database forge-database-1ffbee23a43c> [:select * :from repository :where (and (= forge $s1) (= owner $s2) (= name $s3))] "github.com" "ztlevi" "python-test2")
  apply(#f(compiled-function (connection sql &rest args) #<bytecode 0x1ffbee2caea1>) #f(compiled-function (&rest cnm-args) #<bytecode 0x1ffbe0738bed>) (#<forge-database forge-database-1ffbee23a43c> [:select * :from repository :where (and (= forge $s1) (= owner $s2) (= name $s3))] "github.com" "ztlevi" "python-test2"))
  #f(compiled-function (&rest args) #<bytecode 0x1ffbeea0db81>)(#<forge-database forge-database-1ffbee23a43c> [:select * :from repository :where (and (= forge $s1) (= owner $s2) (= name $s3))] "github.com" "ztlevi" "python-test2")
  apply(#f(compiled-function (&rest args) #<bytecode 0x1ffbeea0db81>) #<forge-database forge-database-1ffbee23a43c> ([:select * :from repository :where (and (= forge $s1) (= owner $s2) (= name $s3))] "github.com" "ztlevi" "python-test2"))
  emacsql(#<forge-database forge-database-1ffbee23a43c> [:select * :from repository :where (and (= forge $s1) (= owner $s2) (= name $s3))] "github.com" "ztlevi" "python-test2")
  apply(emacsql #<forge-database forge-database-1ffbee23a43c> [:select * :from repository :where (and (= forge $s1) (= owner $s2) (= name $s3))] ("github.com" "ztlevi" "python-test2"))
  forge-sql([:select * :from repository :where (and (= forge $s1) (= owner $s2) (= name $s3))] "github.com" "ztlevi" "python-test2")
  #f(compiled-function (&rest rest) "((host owner name) &optional remote demand)\n\nReturn the repository identified by HOST, OWNER and NAME." #<bytecode 0x1ffbec4c96c5>)(("github.com" "ztlevi" "python-test2") "origin" full)
  apply(#f(compiled-function (&rest rest) "((host owner name) &optional remote demand)\n\nReturn the repository identified by HOST, OWNER and NAME." #<bytecode 0x1ffbec4c96c5>) ("github.com" "ztlevi" "python-test2") ("origin" full))
  forge-get-repository(("github.com" "ztlevi" "python-test2") "origin" full)
  #f(compiled-function (url &optional remote demand) "Return the repository at URL." #<bytecode 0x1ffbec4c9659>)("https://github.com/ztlevi/python-test2.git" "origin" full)
  apply(#f(compiled-function (url &optional remote demand) "Return the repository at URL." #<bytecode 0x1ffbec4c9659>) "https://github.com/ztlevi/python-test2.git" ("origin" full))
  forge-get-repository("https://github.com/ztlevi/python-test2.git" "origin" full)
  #f(compiled-function (demand &optional remote) "Return the current forge repository.\n\nIf the `forge-buffer-repository' is non-nil, then return that.\nOtherwise if `forge-buffer-topic' is non-nil, then return the\nrepository for that.  Finally if both variables are nil, then\nreturn the forge repository corresponding to the current Git\nrepository, if any." #<bytecode 0x1ffbec4c9641>)(full)
  apply(#f(compiled-function (demand &optional remote) "Return the current forge repository.\n\nIf the `forge-buffer-repository' is non-nil, then return that.\nOtherwise if `forge-buffer-topic' is non-nil, then return the\nrepository for that.  Finally if both variables are nil, then\nreturn the forge repository corresponding to the current Git\nrepository, if any." #<bytecode 0x1ffbec4c9641>) full nil)
  forge-get-repository(full)
  forge-bug-reference-setup()
  run-hooks(find-file-hook)
  after-find-file(nil t)
  find-file-noselect-1(#<buffer test.py> "~/src/python-test2/test.py" nil nil "~/src/python-test2/test.py" (14531044 16777223))
  find-file-noselect("/Users/nd/src/python-test2/test.py")
  #f(compiled-function (files proc &optional nowait) "Find FILES and return a list of buffers created.\nFILES is an alist whose elements are (FILENAME . FILEPOS)\nwhere FILEPOS can be nil or a pair (LINENUMBER . COLUMNNUMBER).\nPROC is the client that requested this operation.\nNOWAIT non-nil means this client is not waiting for the results,\nso don't mark these buffers specially, just visit them normally." #<bytecode 0x1ffbe8c41019>)((("/Users/nd/src/python-test2/test.py")) #<process server <3>> t)
  apply(#f(compiled-function (files proc &optional nowait) "Find FILES and return a list of buffers created.\nFILES is an alist whose elements are (FILENAME . FILEPOS)\nwhere FILEPOS can be nil or a pair (LINENUMBER . COLUMNNUMBER).\nPROC is the client that requested this operation.\nNOWAIT non-nil means this client is not waiting for the results,\nso don't mark these buffers specially, just visit them normally." #<bytecode 0x1ffbe8c41019>) ((("/Users/nd/src/python-test2/test.py")) #<process server <3>> t))
  server-visit-files((("/Users/nd/src/python-test2/test.py")) #<process server <3>> t)
  server-execute(#<process server <3>> (("/Users/nd/src/python-test2/test.py")) t nil t nil nil)
  #f(compiled-function () #<bytecode 0x1ffbede94e61>)()
  server-execute-continuation(#<process server <3>>)
  server-process-filter(#<process server <3>> "-dir /Users/nd/src/python-test2/ -nowait -current-...")
purcell commented 4 years ago

I just pushed a commit which I suspect should avoid this: my guess is that the timer was triggering while a different buffer was current.

purcell commented 4 years ago

The failing code was narrowing to (window-start) and (window-end), and this causes an error like the one you saw if (window-end) is larger than (point-max). I'm not exactly sure how this happened though. :-/

manuel-uberti commented 4 years ago

I am not sure this is related, but after upgrading the package I get:

Debugger entered--Lisp error: (error "Selecting deleted buffer")
  set-buffer(#<killed buffer>)
  (save-current-buffer (set-buffer buf) (symbol-overlay-maybe-put-temp))
  (lambda (buf) (save-current-buffer (set-buffer buf) (symbol-overlay-maybe-put-temp)))(#<killed buffer>)
  apply((lambda (buf) (save-current-buffer (set-buffer buf) (symbol-overlay-maybe-put-temp))) #<killed buffer>)
  timer-event-handler([t 0 0 500000 t (lambda (buf) (save-current-buffer (set-buffer buf) (symbol-overlay-maybe-put-temp))) (#<killed buffer>) idle 0])
seagle0128 commented 4 years ago

Unfortunately I still encountered this error, and also got the new error @manuel-uberti mentioned.

purcell commented 4 years ago

Hmm, I did push a follow-up commit that checked for liveness of the buffer before invoking with-current-buffer. It looks like the code in the backtrace above is from before that fix. Are you still seeing this with the very latest MELPA package?

purcell commented 4 years ago

(See 66eaaef)

galeo commented 4 years ago

I've met the same error. Here is the backtrace log:

Debugger entered--Lisp error: (args-out-of-range 13655 15402)
  narrow-to-region(13655 15402)
  (progn (narrow-to-region (window-start) (window-end)))
  (if window (progn (narrow-to-region (window-start) (window-end))))
  (if scope (let ((pt (point)) min max p) (save-excursion (save-restriction (narrow-to-defun) (setq min (point-min) max (point-max) p (or (/= pt (point)) (= pt (point-max)))))) (save-excursion (and p (setq min (progn (backward-paragraph) (point)) max (progn (forward-paragraph) (point)))) (narrow-to-region min max))) (if window (progn (narrow-to-region (window-start) (window-end)))))
  symbol-overlay-narrow(nil t)
  (save-restriction (symbol-overlay-narrow symbol-overlay-scope symbol-overlay-displayed-window) (goto-char (point-min)) (let ((re (symbol-overlay-regexp symbol))) (re-search-forward re nil t) (let ((save-match-data-internal (match-data))) (unwind-protect (progn (while (re-search-forward re nil t) (symbol-overlay-put-one symbol) (or p (setq p t)))) (set-match-data save-match-data-internal 'evaporate))) (if p (progn (symbol-overlay-put-one symbol) (setq symbol-overlay-temp-symbol symbol)))))
  (save-excursion (save-restriction (symbol-overlay-narrow symbol-overlay-scope symbol-overlay-displayed-window) (goto-char (point-min)) (let ((re (symbol-overlay-regexp symbol))) (re-search-forward re nil t) (let ((save-match-data-internal (match-data))) (unwind-protect (progn (while (re-search-forward re nil t) (symbol-overlay-put-one symbol) (or p ...))) (set-match-data save-match-data-internal 'evaporate))) (if p (progn (symbol-overlay-put-one symbol) (setq symbol-overlay-temp-symbol symbol))))))
  (progn (symbol-overlay-remove-temp) (save-excursion (save-restriction (symbol-overlay-narrow symbol-overlay-scope symbol-overlay-displayed-window) (goto-char (point-min)) (let ((re (symbol-overlay-regexp symbol))) (re-search-forward re nil t) (let ((save-match-data-internal (match-data))) (unwind-protect (progn (while ... ... ...)) (set-match-data save-match-data-internal 'evaporate))) (if p (progn (symbol-overlay-put-one symbol) (setq symbol-overlay-temp-symbol symbol)))))))
  (if (and symbol (not (symbol-overlay-assoc symbol)) (not (symbol-overlay-ignored-p symbol))) (progn (symbol-overlay-remove-temp) (save-excursion (save-restriction (symbol-overlay-narrow symbol-overlay-scope symbol-overlay-displayed-window) (goto-char (point-min)) (let ((re (symbol-overlay-regexp symbol))) (re-search-forward re nil t) (let ((save-match-data-internal ...)) (unwind-protect (progn ...) (set-match-data save-match-data-internal ...))) (if p (progn (symbol-overlay-put-one symbol) (setq symbol-overlay-temp-symbol symbol))))))))
  (let* ((case-fold-search nil) (symbol (symbol-overlay-get-symbol t)) p) (if (and symbol (not (symbol-overlay-assoc symbol)) (not (symbol-overlay-ignored-p symbol))) (progn (symbol-overlay-remove-temp) (save-excursion (save-restriction (symbol-overlay-narrow symbol-overlay-scope symbol-overlay-displayed-window) (goto-char (point-min)) (let ((re ...)) (re-search-forward re nil t) (let (...) (unwind-protect ... ...)) (if p (progn ... ...))))))))
  (progn (let* ((case-fold-search nil) (symbol (symbol-overlay-get-symbol t)) p) (if (and symbol (not (symbol-overlay-assoc symbol)) (not (symbol-overlay-ignored-p symbol))) (progn (symbol-overlay-remove-temp) (save-excursion (save-restriction (symbol-overlay-narrow symbol-overlay-scope symbol-overlay-displayed-window) (goto-char (point-min)) (let (...) (re-search-forward re nil t) (let ... ...) (if p ...))))))))
  (if symbol-overlay-mode (progn (let* ((case-fold-search nil) (symbol (symbol-overlay-get-symbol t)) p) (if (and symbol (not (symbol-overlay-assoc symbol)) (not (symbol-overlay-ignored-p symbol))) (progn (symbol-overlay-remove-temp) (save-excursion (save-restriction (symbol-overlay-narrow symbol-overlay-scope symbol-overlay-displayed-window) (goto-char ...) (let ... ... ... ...))))))))
  symbol-overlay-maybe-put-temp()
  (save-current-buffer (set-buffer buf) (symbol-overlay-maybe-put-temp))
  (progn (save-current-buffer (set-buffer buf) (symbol-overlay-maybe-put-temp)))
  (if (buffer-live-p buf) (progn (save-current-buffer (set-buffer buf) (symbol-overlay-maybe-put-temp))))
  (lambda (buf) (if (buffer-live-p buf) (progn (save-current-buffer (set-buffer buf) (symbol-overlay-maybe-put-temp)))))(#<buffer *Pp Eval Output*>)
  apply((lambda (buf) (if (buffer-live-p buf) (progn (save-current-buffer (set-buffer buf) (symbol-overlay-maybe-put-temp))))) #<buffer *Pp Eval Output*>)
  timer-event-handler([t 0 0 500000 t (lambda (buf) (if (buffer-live-p buf) (progn (save-current-buffer (set-buffer buf) (symbol-overlay-maybe-put-temp))))) (#<buffer *Pp Eval Output*>) idle 0])

Tested with the latest code (8aa6b11) in master branch.

purcell commented 4 years ago

Yeah, I've been looking into this - thanks folks! I think ca3b02c should help. It turns out that when some of these timers fire, they are for in buffers that are not currently visible, yet the previous code assumed that (selected-window) would also contain the buffer that fired the timer.

purcell commented 4 years ago

You'll have to restart Emacs for the fix to work, btw, because old broken timer functions will still be present in buffers.

purcell commented 4 years ago

Latest version is now in MELPA btw, in case anyone would like to try it out and confirm that the issue is fixed. :-)

manuel-uberti commented 4 years ago

Thank you for working on this, Steve. I've been trying the latest changes and so far so good. I'll report back here whether I find problems or not to give a feedback. Thanks again!

galeo commented 4 years ago

I can also confirm it works. Thanks.

manuel-uberti commented 4 years ago

OK, I've been using it all day at work with no problem. :+1:

seagle0128 commented 4 years ago

I can confirm it works fine now. Close it. Thank you! @purcell

purcell commented 4 years ago

Thanks folks!