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

From: Michael Albinus <[email-masked]>
Date: Sun, 03 Jul 2016 13:55:49 +0200

MICHAEL J MCCLENNEN <[email-masked]> writes:

Hi,

> 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.

Thanks for the report. I'll try to reproduce it with the recent Emacs
from git; I cannot promise I'll succeed.

Which remote file name have you used? I'm mainly interested in the
method name.

> 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.

Well, this change would prevent to raise an error. However, it seems
like there is a reason that POS is not valid anymore when the problem
happens. I believe we shall try to understand why this happens; maybe
there's something we need to fix as well, but only to fight the
symptoms.

Could you please try to provoke the error again? Prior this, pls set
tramp-verbose to 10, and send the Tramp debug buffer once it happened.

Best regards, Michael.