Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: segfault in strftime



On Fri, 26 Feb 2010 14:59:09 +0100
Sebastian Stark <seb-zsh@xxxxxxxxxxx> wrote:
> I'm not used to produce or read backtraces, is the following helpful?

That's very interesting, thank you.

> Does it mean the problem is my libc?

No...

> #1  0x000000000049bb54 in ztrftime (buf=0x6feed0 "\001J!Î+", bufsize=158, fmt=0x2ba7cd751832 " %d.%m.%Y %H:%M:%S", tm=0x0)
                    ^^^^^^
>     at utils.c:2603

This is the interesting bit.  localtime() dectected a value it couldn't
convert to a structure and returned NULL.  It's allowed to do that if it
didn't like the value passed, though I'm not sure why it wouldn't.  It
seems not all time_t's can be converted to times, a fact I was hitherto
unaware of.

Index: Src/Modules/datetime.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/datetime.c,v
retrieving revision 1.18
diff -p -u -r1.18 datetime.c
--- Src/Modules/datetime.c	9 Dec 2007 14:58:36 -0000	1.18
+++ Src/Modules/datetime.c	26 Feb 2010 14:08:55 -0000
@@ -121,6 +121,10 @@ bin_strftime(char *nam, char **argv, Opt
     }
 
     t = localtime(&secs);
+    if (!t) {
+	zwarnnam(nam, "%s: unable to convert to time", argv[1]);
+	return 1;
+    }
     bufsize = strlen(argv[0]) * 8;
     buffer = zalloc(bufsize);
 

-- 
Peter Stephenson <pws@xxxxxxx>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom



Messages sorted by: Reverse Date, Date, Thread, Author