zsh-workers
 help / color / mirror / code / Atom feed
* Re: vanishing history
       [not found] ` <Pine.LNX.4.33L2.0202160123440.1473-100000@phong.blorf.net>
@ 2002-02-18 18:10   ` Adam Spiers
  2002-02-18 18:15     ` Adam Spiers
  2002-02-18 19:31     ` Wayne Davison
  0 siblings, 2 replies; 3+ messages in thread
From: Adam Spiers @ 2002-02-18 18:10 UTC (permalink / raw)
  To: zsh workers mailing list

[moved to zsh-workers]

Wayne Davison (wayned@users.sourceforge.net) wrote:
> On Wed, 28 Nov 2001, Adam Spiers wrote:
> > Does anyone have any idea why my .zshhistory occasionally looses the
> > vast majority of its contents?  I can't reproduce it, so I can't begin
> > to track down what's going on.
> 
> I've seen this from time to time, but also have been unable to reproduce
> it.  In pouring over the code I did finally see one potential way that
> the loss of contents could happen: if the history file is locked by
> another process while we're trying to rewrite it.  Here's the fix (which
> causes us to just punt on the rewrite if we read nothing):
> 
> Index: Src/hist.c
> --- Src/hist.c	16 Feb 2002 09:15:07 -0000	1.39
> +++ Src/hist.c	16 Feb 2002 09:21:16 -0000
> @@ -2083,7 +2083,8 @@
>  	    hist_ignore_all_dups |= isset(HISTSAVENODUPS);
>  	    readhistfile(fn, err, 0);
>  	    hist_ignore_all_dups = isset(HISTIGNOREALLDUPS);
> -	    savehistfile(fn, err, 0);
> +	    if (histlinect)
> +		savehistfile(fn, err, 0);
>  	    deletehashtable(histtab);
> 
>  	    curhist = remember_curhist;

Thanks for that.  I've found a way to reproduce the bug, and this
patch (or at least, the combination of all cvs commits over the last
few weeks) makes zsh core dump when I try that way, which is to simply
type ^X?, which is bound to _complete_debug.  This somehow manages to
reset the history file to almost empty.  I've tracked it as far as the
inc_append_history option, which disabling stops the core dump.
Beyond that I'm out of my depth.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: vanishing history
  2002-02-18 18:10   ` vanishing history Adam Spiers
@ 2002-02-18 18:15     ` Adam Spiers
  2002-02-18 19:31     ` Wayne Davison
  1 sibling, 0 replies; 3+ messages in thread
From: Adam Spiers @ 2002-02-18 18:15 UTC (permalink / raw)
  To: zsh workers mailing list

Adam Spiers (adam@spiers.net) wrote:
> Thanks for that.  I've found a way to reproduce the bug, and this
> patch (or at least, the combination of all cvs commits over the last
> few weeks) makes zsh core dump when I try that way, which is to simply
> type ^X?, which is bound to _complete_debug.  This somehow manages to
> reset the history file to almost empty.  I've tracked it as far as the
> inc_append_history option, which disabling stops the core dump.
> Beyond that I'm out of my depth.

Apologies, I forgot to include a stack trace.

#0  0x0807931f in savehistfile (fn=0x80ef1c0 "/nfs-home/adams/.zshhistory",
    err=0, writeflags=32771) at hist.c:2050
2050                for (; *t; t++) {
(gdb) bt
#0  0x0807931f in savehistfile (fn=0x80ef1c0 "/nfs-home/adams/.zshhistory",
    err=0, writeflags=32771) at hist.c:2050
#1  0x08076f52 in hend (prog=0x0) at hist.c:1154
#2  0x08079ff8 in loop (toplevel=1, justonce=0) at init.c:129
#3  0x0807c849 in zsh_main (argc=1, argv=0xbffff374) at init.c:1214
#4  0x080518f0 in main (argc=1, argv=0xbffff374) at ./main.c:37
#5  0x4008f6f7 in __libc_start_main (main=0x80518e0 <main>, argc=1,
    ubp_av=0xbffff374, init=0x8050e08 <_init>, fini=0x80bd89c <_fini>,
    rtld_fini=0x4000dcd4 <_dl_fini>, stack_end=0xbffff36c)
    at ../sysdeps/generic/libc-start.c:129


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: vanishing history
  2002-02-18 18:10   ` vanishing history Adam Spiers
  2002-02-18 18:15     ` Adam Spiers
@ 2002-02-18 19:31     ` Wayne Davison
  1 sibling, 0 replies; 3+ messages in thread
From: Wayne Davison @ 2002-02-18 19:31 UTC (permalink / raw)
  To: Adam Spiers; +Cc: zsh workers mailing list

On Mon, 18 Feb 2002, Adam Spiers wrote:
> this patch (or at least, the combination of all cvs commits over the
> last few weeks) makes zsh core dump when I try that way, which is to
> simply type ^X?, which is bound to _complete_debug.

This is because of a bug in my recent changes in prepnexthistent().
I've just checked in a fix for this.

My history doesn't vanish running this, so if you can still duplicate
the vanishing-history problem, let me know.

..wayne..

---8<------8<------8<------8<---cut here--->8------>8------>8------>8---
Index: Src/hist.c
--- Src/hist.c	16 Feb 2002 09:21:34 -0000	1.40
+++ Src/hist.c	18 Feb 2002 19:24:34 -0000
@@ -947,6 +947,7 @@
 Histent
 prepnexthistent(void)
 {
+    Histent he;
     int curline_in_ring = hist_ring == &curline;

     if (curline_in_ring)
@@ -957,7 +958,7 @@
     }

     if (histlinect < histsiz) {
-	Histent he = (Histent)zcalloc(sizeof *he);
+	he = (Histent)zcalloc(sizeof *he);
 	if (!hist_ring)
 	    hist_ring = he->up = he->down = he;
 	else {
@@ -970,12 +971,12 @@
     }
     else {
 	putoldhistentryontop(0);
-	freehistdata(hist_ring, 0);
+	freehistdata(he = hist_ring, 0);
     }
-    hist_ring->histnum = ++curhist;
+    he->histnum = ++curhist;
     if (curline_in_ring)
 	linkcurline();
-    return hist_ring;
+    return he;
 }

 /* A helper function for hend() */
---8<------8<------8<------8<---cut here--->8------>8------>8------>8---


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-02-18 19:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20011128161905.A9726@corelli.new.ox.ac.uk>
     [not found] ` <Pine.LNX.4.33L2.0202160123440.1473-100000@phong.blorf.net>
2002-02-18 18:10   ` vanishing history Adam Spiers
2002-02-18 18:15     ` Adam Spiers
2002-02-18 19:31     ` Wayne Davison

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).