bug-texinfo
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug #46481] install-info can "corrupt" dir file if interrupted.


From: Gavin Smith
Subject: Re: [bug #46481] install-info can "corrupt" dir file if interrupted.
Date: Fri, 20 Nov 2015 11:19:59 +0000

On 19 November 2015 at 21:48, Pedrum Mohageri <address@hidden> wrote:

> Details:
>
> I use Arch and the package manager bailed out on several packages during the
> install. I traced this to a failed install-info call to add entries for
> package to the 'dir' that info use.
>
> After strace'ng the code, I observe it will do a open with O_TRUNC flag, and
> then write out some data. If the process is killed between the open and write,
> it will leave 0 byte dir file which can't written to by subsequent
> install-info calls. You should consider replacing this with a 'write to
> temp/rename temp to dir' changeover that's atomic.

I think this "open" is done when "fopen" is called.

Can you point to an explanation or example of how to update a file
without the risk of truncation? It would seem that there's the risk of
this happening any time that fopen (... , "w") is used; should that be
considered a bad way to update a file.

> While this is rare occurrence, I've seen numerous failures like this reported
> on Redhat and Arch forums.

Can you email links to these reports?

Why was install-info killed anyway? If it was due to C-c being typed
on the controlling terminal, could we maybe catch and ignore the
signal to make sure we finish?

>
> Strace results:
> open("dir", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
> fstat(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
> mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
> 0x7fcf1c842000
> write(3, "This is the file .../info/dir, w"..., 867) = 867



reply via email to

[Prev in Thread] Current Thread [Next in Thread]