[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
History file clobbered by multiple simultaneous exits
From: |
geoff |
Subject: |
History file clobbered by multiple simultaneous exits |
Date: |
Wed, 10 Jul 2013 16:45:36 -0700 (PDT) |
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc -I/home/abuild/rpmbuild/BUILD/bash-4.2
-L/home/abuild/rpmbuild/BUILD/bash-4.2/../readline-6.2
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-suse-linux-gnu'
-DCONF_VENDOR='suse' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL
-DHAVE_CONFIG_H -I. -I. -I./include -I./lib -fmessage-length=0 -O2 -Wall
-D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables
-fasynchronous-unwind-tables -g -D_GNU_SOURCE -DRECYCLES_PIDS -Wall -g
-std=gnu89 -Wuninitialized -Wextra -Wno-unprototyped-calls -Wno-switch-enum
-Wno-unused-variable -Wno-unused-parameter -ftree-loop-linear -pipe
-fprofile-use
uname output: Linux bow 3.7.10-1.16-desktop #1 SMP PREEMPT Fri May 31 20:21:23
UTC 2013 (97c14ba) x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-suse-linux-gnu
Bash Version: 4.2
Patch Level: 42
Release Status: release
Description:
When the history file is written, no locking is used. The
result is that when multiple bash instances exit (nearly)
simultaneously, the history file can be replaced by a
zero-length file.
Repeat-By:
Because it's a race condition, the problem can't be reliably
reproduced. The way I stumble across it is to create multiple
bash sessions 6 or more in a number of terminal windows, each
with HISTFILE set and histappend unset, and then shut the X
server down. I imagine that you could also create multiple
shells and then kill them all simultaneously.
Fix:
Locking should be used when truncating and writing the history
file. (Yes, I know it's a pain in a portable program like
bash.)
Strictly speaking, locking is only half a solution, because
the net result will be that the saved history is taken from
a randomly chosen one of the multiple exiting shells. But
that's better than the current situation where all history is lost.
What might be cooler would be to merge all the history lines
from all shells, in timestamp order. But given the current
history file format, that seems...hard.
- History file clobbered by multiple simultaneous exits,
geoff <=
- Re: History file clobbered by multiple simultaneous exits, Linda Walsh, 2013/07/11
- Re: History file clobbered by multiple simultaneous exits, Geoff Kuenning, 2013/07/17
- Re: History file clobbered by multiple simultaneous exits, Linda Walsh, 2013/07/18
- Re: History file clobbered by multiple simultaneous exits, Geoff Kuenning, 2013/07/19
- Re: History file clobbered by multiple simultaneous exits, Linda Walsh, 2013/07/19
- Re: History file clobbered by multiple simultaneous exits, Chet Ramey, 2013/07/19
- Re: History file clobbered by multiple simultaneous exits, Geoff Kuenning, 2013/07/24
- Re: History file clobbered by multiple simultaneous exits, Linda Walsh, 2013/07/24
- Re: History file clobbered by multiple simultaneous exits, Geoff Kuenning, 2013/07/25
- Re: History file clobbered by multiple simultaneous exits, Linda Walsh, 2013/07/25