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

Re: segfault in strftime



Am 26.02.2010 um 14:03 schrieb Peter Stephenson:

> Sebastian Stark wrote:
>> I just found that zsh segfaults when I do this:
>> 
>> zmodload zsh/datetime
>> strftime "%a %d.%m.%Y %H:%M:%S" 67768036191673200
>> 
>> while it doesn't for smaller numbers, like:
>> 
>> strftime "%a %d.%m.%Y %H:%M:%S" 67768036191673199
>> 
>> It will print a negative year for this value though. Negative results are n=
>> ot a big problem I think, but a segfault could be.
>> 
>> I tried this with zsh-4.3.10 under linux-gnu-x86_64. Can anyone reproduce t=
>> his?
> 
> I don't see where that would cause a problem, so I'd be interested in a
> backtrace---the only place I can see it going wrong is within strtoul().

The segfault doesn't happen with a time one second before:
sambesi% strftime "%a %d.%m.%Y %H:%M:%S" 67768036191673199
Wed 31.12.-2147481749 23:59:59

This is a freshly compiled zsh 4.3.10 with --enable-zsh-debug.

I'm not used to produce or read backtraces, is the following helpful? Does it mean the problem is my libc?

% gdb --args /usr/local/bin/zsh -f
GNU gdb 6.8-debian             
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu"...
(gdb) run
Starting program: /usr/local/bin/zsh -f
sambesi% echo $ZSH_VERSION
4.3.10
sambesi% zmodload zsh/datetime
sambesi% strftime "%a %d.%m.%Y %H:%M:%S" 67768036191673200

Program received signal SIGSEGV, Segmentation fault.
0x00002ba7cdf4b93b in ?? () from /lib/libc.so.6
(gdb) bt
#0  0x00002ba7cdf4b93b in ?? () from /lib/libc.so.6
#1  0x000000000049bb54 in ztrftime (buf=0x6feed0 "\001J!Î+", bufsize=158, fmt=0x2ba7cd751832 " %d.%m.%Y %H:%M:%S", tm=0x0)
    at utils.c:2603
#2  0x00002ba7ce8ab18e in bin_strftime (nam=0x2ba7cd751820 "strftime", argv=0x7fffdd4dc980, ops=0x7fffdd4dca60, func=0)
    at datetime.c:128
#3  0x0000000000410731 in execbuiltin (args=0x2ba7cd7517c0, bn=0x2ba7ceaab8a0) at builtin.c:439
#4  0x00000000004313be in execcmd (state=0x7fffdd4dd240, input=0, output=0, how=18, last1=2) at exec.c:3067
#5  0x000000000042cd2c in execpline2 (state=0x7fffdd4dd240, pcode=259, how=18, input=0, output=0, last1=0) at exec.c:1561
#6  0x000000000042bef4 in execpline (state=0x7fffdd4dd240, slcode=5122, how=18, last1=0) at exec.c:1347
#7  0x000000000042b630 in execlist (state=0x7fffdd4dd240, dont_change_job=0, exiting=0) at exec.c:1144
#8  0x000000000042b0bb in execode (p=0x2ba7cd7516e8, dont_change_job=0, exiting=0) at exec.c:975
#9  0x0000000000447a39 in loop (toplevel=1, justonce=0) at init.c:183
#10 0x000000000044a94e in zsh_main (argc=2, argv=0x7fffdd4dd408) at init.c:1409
#11 0x000000000040fb53 in main (argc=2, argv=0x7fffdd4dd408) at ./main.c:93


Sebastian


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