This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/1390] localtime call causes Segmentation Fault


------- Additional Comments From makhota at gmx dot net  2005-09-29 15:59 -------
Created an attachment (id=680)
 --> (http://sourceware.org/bugzilla/attachment.cgi?id=680&action=view)
How to reproduce

When subsequently started, produces core dump. Here is what gdb says about core
(stack trace):

#0  0x400c3ae4 in tz_compute () from /lib/libc.so.6
#1  0x400c3c9a in __tz_convert () from /lib/libc.so.6
#2  0x400c0555 in localtime_r () from /lib/libc.so.6
#3  0x080484ed in xtimer (nCode=14) at coretest.c:38
#4  <signal handler called>
#5  0x400fb11d in mmap () from /lib/libc.so.6
#6  0x4008c4db in _IO_file_doallocate () from /lib/libc.so.6
#7  0x4009709c in _IO_doallocbuf () from /lib/libc.so.6
#8  0x4009660a in _IO_file_xsgetn () from /lib/libc.so.6
#9  0x40097233 in _IO_sgetn () from /lib/libc.so.6
#10 0x40095057 in fread_unlocked () from /lib/libc.so.6
#11 0x400c3fc0 in __tzfile_read () from /lib/libc.so.6
#12 0x400c2d50 in tzset_internal () from /lib/libc.so.6
#13 0x400c3c4f in __tz_convert () from /lib/libc.so.6
#14 0x400c0555 in localtime_r () from /lib/libc.so.6
#15 0x080484ed in xtimer (nCode=0) at coretest.c:38
#16 0x0804859a in main (argc=1, argv=0xbffff9d4) at coretest.c:66
#17 0x400437ee in __libc_start_main () from /lib/libc.so.6

As you can see, signal handler (timer) was caller while first call to
localtime_r was in progress. I guess, first call started to calculate timezone
and did not finish it when second call happened. Second call was assuming
timezone variables are ready to use and that created a confusion dump :). 

The thing is (as you see in source code comments) if you call localtime or
localtime_r once BEFORE starting a timer, segfault never happens. I assume this
is because the first time it is called, it calculates timezone and assigns all
the structures. So all the other calls just overwrite the static result buffer,
but do not cause core dump.

-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=1390

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]