public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/1390] New: localtime call causes Segmentation Fault
@ 2005-09-29  0:51 makhota at gmx dot net
  2005-09-29  8:38 ` [Bug libc/1390] " schwab at suse dot de
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: makhota at gmx dot net @ 2005-09-29  0:51 UTC (permalink / raw)
  To: glibc-bugs

There is a program that starts a timer. Second thing after starting a timer is 
to call localtime. Timer, in turn, calls localtime.

Second call to localtime may be started before first one is finished. This 
creates seg fault.

-- 
           Summary: localtime call causes Segmentation Fault
           Product: glibc
           Version: 2.2.5
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: gotom at debian dot or dot jp
        ReportedBy: makhota at gmx dot net
                CC: glibc-bugs at sources dot redhat dot com
 GCC build triplet: i386
  GCC host triplet: i386
GCC target triplet: i386


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.


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

* [Bug libc/1390] localtime call causes Segmentation Fault
  2005-09-29  0:51 [Bug libc/1390] New: localtime call causes Segmentation Fault makhota at gmx dot net
@ 2005-09-29  8:38 ` schwab at suse dot de
  2005-09-29 16:01 ` makhota at gmx dot net
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: schwab at suse dot de @ 2005-09-29  8:38 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From schwab at suse dot de  2005-09-29 08:38 -------
localtime is not reentrant.  You must use localtime_r instead.  

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID


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.


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

* [Bug libc/1390] localtime call causes Segmentation Fault
  2005-09-29  0:51 [Bug libc/1390] New: localtime call causes Segmentation Fault makhota at gmx dot net
  2005-09-29  8:38 ` [Bug libc/1390] " schwab at suse dot de
@ 2005-09-29 16:01 ` makhota at gmx dot net
  2005-09-29 16:02 ` makhota at gmx dot net
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: makhota at gmx dot net @ 2005-09-29 16:01 UTC (permalink / raw)
  To: glibc-bugs


------- 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.


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

* [Bug libc/1390] localtime call causes Segmentation Fault
  2005-09-29  0:51 [Bug libc/1390] New: localtime call causes Segmentation Fault makhota at gmx dot net
  2005-09-29  8:38 ` [Bug libc/1390] " schwab at suse dot de
  2005-09-29 16:01 ` makhota at gmx dot net
@ 2005-09-29 16:02 ` makhota at gmx dot net
  2005-10-11  4:25 ` drepper at redhat dot com
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: makhota at gmx dot net @ 2005-09-29 16:02 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From makhota at gmx dot net  2005-09-29 16:01 -------
Sorry guys, lcoaltime_r has the same problem. Please, see attachment from the 
previous post.

BTW, localtime never caused core when 2, 3, ... calls are preempted. Only the 
first one. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |


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.


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

* [Bug libc/1390] localtime call causes Segmentation Fault
  2005-09-29  0:51 [Bug libc/1390] New: localtime call causes Segmentation Fault makhota at gmx dot net
                   ` (2 preceding siblings ...)
  2005-09-29 16:02 ` makhota at gmx dot net
@ 2005-10-11  4:25 ` drepper at redhat dot com
  2005-11-02 22:18 ` makhota at gmx dot net
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: drepper at redhat dot com @ 2005-10-11  4:25 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From drepper at redhat dot com  2005-10-11 04:25 -------
You cannot call localtime or localtime_r from a signal handler.  Read the POSIX
spec.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |INVALID


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.


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

* [Bug libc/1390] localtime call causes Segmentation Fault
  2005-09-29  0:51 [Bug libc/1390] New: localtime call causes Segmentation Fault makhota at gmx dot net
                   ` (3 preceding siblings ...)
  2005-10-11  4:25 ` drepper at redhat dot com
@ 2005-11-02 22:18 ` makhota at gmx dot net
  2005-12-23  4:05 ` drepper at redhat dot com
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: makhota at gmx dot net @ 2005-11-02 22:18 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From makhota at gmx dot net  2005-11-02 22:18 -------
Sorry guys, I want an argumented answer. Since I did not any reply, I am re-
opening this. I could not find the answer in POSIX and asked where I can find 
it.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |


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.


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

* [Bug libc/1390] localtime call causes Segmentation Fault
  2005-09-29  0:51 [Bug libc/1390] New: localtime call causes Segmentation Fault makhota at gmx dot net
                   ` (4 preceding siblings ...)
  2005-11-02 22:18 ` makhota at gmx dot net
@ 2005-12-23  4:05 ` drepper at redhat dot com
  2005-12-28 19:14 ` makhota at gmx dot net
  2005-12-29  0:04 ` mark9781 at yahoo dot com
  7 siblings, 0 replies; 9+ messages in thread
From: drepper at redhat dot com @ 2005-12-23  4:05 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From drepper at redhat dot com  2005-12-23 04:05 -------
I have better things than to teach people for free how to program.  Read the
standard.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |INVALID


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.


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

* [Bug libc/1390] localtime call causes Segmentation Fault
  2005-09-29  0:51 [Bug libc/1390] New: localtime call causes Segmentation Fault makhota at gmx dot net
                   ` (5 preceding siblings ...)
  2005-12-23  4:05 ` drepper at redhat dot com
@ 2005-12-28 19:14 ` makhota at gmx dot net
  2005-12-29  0:04 ` mark9781 at yahoo dot com
  7 siblings, 0 replies; 9+ messages in thread
From: makhota at gmx dot net @ 2005-12-28 19:14 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From makhota at gmx dot net  2005-12-28 19:14 -------
Listen, I am not asking to teach me programming. My question is: show me that 
part of standard. I do NOT consider "read the standard" as an argumented 
answer. What I do, however, consider as an answer is something like "paragraph 
xxx from http://xxxx/xxx/xx explains what you need."

Just in case I am still not clear: please, give me a link (URL, page#, 
whatever that helps me find that) to the part of POSIX you are referring to. 

Thank you.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |


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.


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

* [Bug libc/1390] localtime call causes Segmentation Fault
  2005-09-29  0:51 [Bug libc/1390] New: localtime call causes Segmentation Fault makhota at gmx dot net
                   ` (6 preceding siblings ...)
  2005-12-28 19:14 ` makhota at gmx dot net
@ 2005-12-29  0:04 ` mark9781 at yahoo dot com
  7 siblings, 0 replies; 9+ messages in thread
From: mark9781 at yahoo dot com @ 2005-12-29  0:04 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From mark9781 at yahoo dot com  2005-12-29 00:04 -------
http://www.opengroup.org/onlinepubs/000095399/functions/xsh_chap02_04.html#tag_02_04_03

"All functions not in the above table are considered to be unsafe with respect
to signals. In the presence of signals, all functions defined by this volume of
IEEE Std 1003.1-2001 shall behave as defined when called from or interrupted by
a signal-catching function, with a single exception: when a signal interrupts an
unsafe function and the signal-catching function calls an unsafe function, the
behavior is undefined."

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |INVALID


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.


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

end of thread, other threads:[~2005-12-29  0:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-29  0:51 [Bug libc/1390] New: localtime call causes Segmentation Fault makhota at gmx dot net
2005-09-29  8:38 ` [Bug libc/1390] " schwab at suse dot de
2005-09-29 16:01 ` makhota at gmx dot net
2005-09-29 16:02 ` makhota at gmx dot net
2005-10-11  4:25 ` drepper at redhat dot com
2005-11-02 22:18 ` makhota at gmx dot net
2005-12-23  4:05 ` drepper at redhat dot com
2005-12-28 19:14 ` makhota at gmx dot net
2005-12-29  0:04 ` mark9781 at yahoo dot com

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 read-only IMAP folder(s) and NNTP newsgroup(s).