Subject: bug#22795: 25.0.91; Can't write read only file on w32

From: Eli Zaretskii <[email-masked]>
Date: Mon, 29 Feb 2016 19:13:43 +0200

> Date: Mon, 29 Feb 2016 08:40:35 -0800
> CC: <[email-masked]>
> From: "Ota, Takaaki" <[email-masked]>
> 
> I am now very much puzzled.  Here is the trace up to _wopen().  I
> printed parameters to _wopen() and they are identical yet one succeeds
> and the other fails.

Hmm... strange, indeed.

Do you have a dependency walker program?  (If not, you can download it
from http://www.dependencywalker.com/.)  Can you tell whether the two
executables differ in the versions of msvcrt.dll they are linked
against?  Or any other dynamic libraries, for that matter?

Also, what is the value of errno after the _wopen call that fails?

Finally, what about this part of my questions, did you look into this:

> Also, I think by the time this code is run, the original file should
> have been renamed to the backup-file name, so the file you are saving
> should not exist on disk by the time we open it.  If that is not the
> case with 25.0.91, then perhaps what fails is not the open call, but
> the rename call before that.

Does the file that Emacs tries to open here, c:\d\ota\memo, exist when
_wopen is called, and if so, is it read-only?  Please check this with
both versions of Emacs, and see if there's any differences in what
happens.

Thanks.