Subject: 24.4.51; tramp sometimes reports "Args out of range" error when resuming editing a remote file after a period of inactivity

From: MICHAEL J MCCLENNEN <[email-masked]>
Date: Sat, 02 Jul 2016 01:55:21 +0000

To reproduce this bug:

1) Edit a remote file using tramp.
2) Wait for at least 24 hours.
3) Make a change to the file in the local buffer.  Emacs will then attempt to query
   the remote system using tramp in order to check whether it has changed on disk
   before allowing any local editing.
4) Sometimes (not always) this check aborts with the error message "Args out of range".
   The buffer is left in read-only mode, preventing you from working on the file.

I have actually figured out where in the code the error occurs, and have a fix for it.  The
error occurs at the last line of the function `tramp-process-actions' in tramp.el, in the
call to `delete-region'.

The following patch will fix the problem:
3593c3593
< 	  (let (buffer-read-only) (if (< pos (point)) (delete-region pos (point)))))))))
---
> 	  (let (buffer-read-only) (delete-region pos (point))))))))

I have tested this patch, and it solves the problem without causing any other 
problems that I can detect.  I would appreciate if you would apply this patch 
to the Emacs source.

In Aquamacs 3.2 GNU Emacs 24.4.51.2
(x86_64-apple-darwin14.0.0, NS apple-appkit-1343.14)
of 2014-11-07 (Aquamacs-3.2) on watson.local
Operating System: OS X Version 10.8.5 (Build 12F2560)
Configured using:
`configure --with-ns --without-x 'CFLAGS=-arch x86_64 -O3 -g
-mtune=corei7 -mmacosx-version-min=10.6' 'LDFLAGS=-arch x86_64 -O3 -g
-mtune=corei7 -mmacosx-version-min=10.6''

Important settings:
  locale-coding-system: utf-8-unix

Major mode: Emacs-Lisp

Minor modes in effect:
  diff-auto-refine-mode: t
  savehist-mode: t
  smart-frame-positioning-mode: t
  shell-dirtrack-mode: t
  aquamacs-autoface-mode: t
  recentf-mode: t
  osx-key-mode: t
  tabbar-mwheel-mode: t
  tabbar-mode: t
  show-paren-mode: t
  delete-selection-mode: t
  cua-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Memory information:
((conses 16 866516 175475)
(symbols 48 45081 0)
(miscs 40 2907 3571)
(strings 32 103591 20533)
(string-bytes 1 4546451)
(vectors 16 50097)
(vector-slots 8 1858179 143262)
(floats 8 1921 792)
(intervals 56 167401 177)
(buffers 960 779))