NetBSD Problem Report #28324
From www@netbsd.org Tue Nov 16 04:05:40 2004
Return-Path: <www@netbsd.org>
Received: by narn.netbsd.org (Postfix, from userid 31301)
id A6D522520F7; Tue, 16 Nov 2004 04:05:40 +0000 (UTC)
Message-Id: <20041116040540.A6D522520F7@narn.netbsd.org>
Date: Tue, 16 Nov 2004 04:05:40 +0000 (UTC)
From: kochi@NetBSD.org
Reply-To: kochi@NetBSD.org
To: gnats-bugs@netbsd.org
Subject: localtime_r(3) returns GMT
X-Send-Pr-Version: www-1.0
>Number: 28324
>Category: lib
>Synopsis: localtime_r(3) returns GMT
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: lib-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Nov 16 04:06:00 +0000 2004
>Closed-Date: Tue Nov 16 04:16:28 +0000 2004
>Last-Modified: Sun Mar 18 07:35:00 +0000 2012
>Originator: Takayoshi Kochi
>Release: 2.0 RC3
>Organization:
>Environment:
NetBSD 2.0 RC3
>Description:
Whether environment variable 'TZ' is set or not, localtime_r(3)
doesn't return localtime but returns GMT.
This occurs on NetBSD RC3 but from the glance of the sourcecode
(libc/time/localtime.c) -current also has the same bug.
>How-To-Repeat:
Compile and run this program.
If functions are called in reverse order (localtime, localtime_r),
localtime_r returns correct localtime.
----------------------------------------------------------------------
#include <time.h>
#include <stdio.h>
int
main()
{
struct tm t;
struct tm *pt;
time_t x;
x = time(NULL);
localtime_r(&x, &t);
printf("localtime_r: %d %d %d\n", t.tm_hour, t.tm_min, t.tm_sec);
pt = localtime(&x);
printf("localtime : %d %d %d\n", pt->tm_hour, pt->tm_min, pt->tm_sec);
}
----------------------------------------------------------------------
>Fix:
call tzset_unlocked() in localtime_r() as well as localtime()?
i haven't tried and not sure the locking rule.
>Release-Note:
>Audit-Trail:
From: Christos Zoulas <christos@netbsd.org>
To: gnats-bugs@netbsd.org
Cc:
Subject: PR/28324 CVS commit: src/lib/libc/time
Date: Tue, 16 Nov 2004 04:15:28 +0000 (UTC)
Module Name: src
Committed By: christos
Date: Tue Nov 16 04:15:28 UTC 2004
Modified Files:
src/lib/libc/time: localtime.c
Log Message:
PR/28324: Takayoshi Kochi: localtime_r(3) returns GMT
Add missing tzset_unlocked(); as suggested.
To generate a diff of this commit:
cvs rdiff -r1.35 -r1.36 src/lib/libc/time/localtime.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->closed
State-Changed-By: christos@netbsd.org
State-Changed-When: Mon, 15 Nov 2004 23:16:28 -0500
State-Changed-Why:
fix as suggested
From: Matthias Scheler <tron@netbsd.org>
To: gnats-bugs@netbsd.org
Cc:
Subject: PR/28324 CVS commit: [netbsd-2] src/lib/libc/time
Date: Sat, 16 Apr 2005 10:44:52 +0000 (UTC)
Module Name: src
Committed By: tron
Date: Sat Apr 16 10:44:52 UTC 2005
Modified Files:
src/lib/libc/time [netbsd-2]: localtime.c
Log Message:
Pull up revision 1.36 (requested by kochi in ticket #1087):
PR/28324: Takayoshi Kochi: localtime_r(3) returns GMT
Add missing tzset_unlocked(); as suggested.
To generate a diff of this commit:
cvs rdiff -r1.35 -r1.35.4.1 src/lib/libc/time/localtime.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Jukka Ruohonen" <jruoho@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/28324 CVS commit: src/tests/lib/libc/time
Date: Sun, 18 Mar 2012 07:33:59 +0000
Module Name: src
Committed By: jruoho
Date: Sun Mar 18 07:33:58 UTC 2012
Modified Files:
src/tests/lib/libc/time: t_mktime.c
Log Message:
Add a test case for the old NetBSD 2.0 era PR lib/28324.
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/time/t_mktime.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.