Debian Bug report logs -
#283702
Race condition when writing ~/.bash_history
Reported by: Cyril Bouthors <cyb@debian.org>
Date: Tue, 30 Nov 2004 19:03:04 UTC
Severity: minor
Tags: upstream, wontfix
Found in version 3.0-10
Forwarded to chet.ramey@case.edu
Reply or subscribe to this bug.
Toggle useless messages
Report forwarded to debian-bugs-dist@lists.debian.org, loic@gnu.org, Matthias Klose <doko@debian.org>:
Bug#283702; Package bash.
(full text, mbox, link).
Acknowledgement sent to Cyril Bouthors <cyb@debian.org>:
New Bug report received and forwarded. Copy sent to loic@gnu.org, Matthias Klose <doko@debian.org>.
(full text, mbox, link).
Message #5 received at submit@bugs.debian.org (full text, mbox, reply):
Package: bash
Version: 3.0-10
Severity: critical
Justification: causes serious data loss
Hi,
About once a month, my ~/.bash_history gets empty. This is quite
annoying because I'm using C-r really often.
I get the same problem again and again for quite some time now, maybe
two years.
I think it comes from the fact that I'm not using a typical setup.
I'm running 5 different "bash --noediting -i" under Emacs with
shell-mode buffers and I'm often exiting Emacs without closing all the
shells by hand. The 5 bash processes get killed and I guess they try
to write ~/.bash_history at the exact same time.
I think it's a basic race condition, bash should lock the file before
trying to write it but I haven't checked if it does.
I haven't reproduced the exact same bug where ~/.bash_history gets
empty but a similar unwanted behaviour can be reproduced by doing
massive parallel "history -w" with:
cyb@wide:~$ export HISTFILE=/tmp/history
cyb@wide:~$ export HISTSIZE=100000
cyb@wide:~$ rm -f $HISTFILE
cyb@wide:~$ for a in `seq 5`; do xterm -e 'for a in `seq 1000`; do echo "echo $a; history -w"; done | bash -i' ; done
cyb@wide:~$ wc -l $HISTFILE
10000 /tmp/history
cyb@wide:~$ rm $HISTFILE
cyb@wide:~$ for a in `seq 5`; do xterm -e 'for a in `seq 1000`; do echo "echo $a; history -w"; done | bash -i' & done
[1] 4715
[2] 4721
[3] 4722
[4] 4723
[5] 4724
cyb@wide:~$ wait
[1] Done xterm -e 'for a in `seq 1000`; do echo "echo $a; history -w"; done | bash -i'
[2] Done xterm -e 'for a in `seq 1000`; do echo "echo $a; history -w"; done | bash -i'
[4]- Done xterm -e 'for a in `seq 1000`; do echo "echo $a; history -w"; done | bash -i'
[5]+ Done xterm -e 'for a in `seq 1000`; do echo "echo $a; history -w"; done | bash -i'
[3]+ Done xterm -e 'for a in `seq 1000`; do echo "echo $a; history -w"; done | bash -i'
cyb@wide:~$ wc -l $HISTFILE
2794 /tmp/history
cyb@wide:~$ unset HISTFILE
cyb@wide:~$
/tmp/history should be 10k lines long in both cases (5*1000*2).
Regards
-- System Information:
Debian Release: 3.1
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: i386 (i686)
Kernel: Linux 2.6.9-1-686
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Versions of packages bash depends on:
ii base-files 3.1.0 Debian base system miscellaneous f
ii libc6 2.3.2.ds1-18 GNU C Library: Shared libraries an
ii libncurses5 5.4-4 Shared libraries for terminal hand
ii passwd 1:4.0.3-30.4 Change and administer password and
-- no debconf information
Information forwarded to debian-bugs-dist@lists.debian.org, Matthias Klose <doko@debian.org>:
Bug#283702; Package bash.
(full text, mbox, link).
Acknowledgement sent to Peter Walser <peterwalser@yahoo.com>:
Extra info received and forwarded to list. Copy sent to Matthias Klose <doko@debian.org>.
(full text, mbox, link).
Message #10 received at 283702@bugs.debian.org (full text, mbox, reply):
As far as I understand uses bash/history the function readline.
with bash 2.05b.0 :
[... steps described above ...]
$ wc -l $HISTFILE
2805 /tmp/history
So I get quite the same behavior.
I think readline/history is not thread save, but it's not critical.
Regards
Peter
Severity set to `important'.
Request was from Matthias Klose <doko@cs.tu-berlin.de>
to control@bugs.debian.org.
(full text, mbox, link).
Information forwarded to debian-bugs-dist@lists.debian.org, Matthias Klose <doko@debian.org>:
Bug#283702; Package bash.
(full text, mbox, link).
Acknowledgement sent to Cyril Bouthors <cyril@bouthors.org>:
Extra info received and forwarded to list. Copy sent to Matthias Klose <doko@debian.org>.
(full text, mbox, link).
Message #17 received at 283702@bugs.debian.org (full text, mbox, reply):
[Message part 1 (text/plain, inline)]
This is a bug in upstream, maybe we should forward this to upstream
authors, they'll probably have a good reactivity.
--
Cyril Bouthors
[Message part 2 (application/pgp-signature, inline)]
Information forwarded to debian-bugs-dist@lists.debian.org, Matthias Klose <doko@debian.org>:
Bug#283702; Package bash.
(full text, mbox, link).
Acknowledgement sent to chet.ramey@case.edu:
Extra info received and forwarded to list. Copy sent to Matthias Klose <doko@debian.org>.
(full text, mbox, link).
Message #22 received at 283702@bugs.debian.org (full text, mbox, reply):
Matthias Klose wrote:
> [severity was lowerd in the Debian BTS]
I'm not inclined to do anything about this.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet )
Live Strong.
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/
Severity set to `minor'.
Request was from Matthias Klose <doko@cs.tu-berlin.de>
to control@bugs.debian.org.
(full text, mbox, link).
Tags added: wontfix
Request was from Matthias Klose <doko@cs.tu-berlin.de>
to control@bugs.debian.org.
(full text, mbox, link).
Noted your statement that Bug has been forwarded to chet@case.edu.
Request was from Matthias Klose <doko@cs.tu-berlin.de>
to control@bugs.debian.org.
(full text, mbox, link).
Forwarded-to-address changed from chet@case.edu to chet.ramey@case.edu.
Request was from Matthias Klose <doko@cs.tu-berlin.de>
to control@bugs.debian.org.
(full text, mbox, link).
Tags added: upstream
Request was from Matthias Klose <doko@cs.tu-berlin.de>
to control@bugs.debian.org.
(full text, mbox, link).
Send a report that this bug log contains spam.
Debian bug tracking system administrator <owner@bugs.debian.org>.
Last modified:
Mon Jun 5 01:11:19 2023;
Machine Name:
buxtehude
Debian Bug tracking system
Debbugs is free software and licensed under the terms of the GNU
Public License version 2. The current version can be obtained
from https://bugs.debian.org/debbugs-source/.
Copyright © 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson,
2005-2017 Don Armstrong, and many other contributors.