This is the mail archive of the cygwin mailing list for the Cygwin 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]

Re: BUG: Timezone failures with threads under Cygwin 1.5.25

Jerry D. Hedden wrote:
> [...]
> Under 1.5.24, this test always passes.  Under 1.5.25, it is
> now frequently failing.  If I add a debugging call in the
> central most loop:
>             print("got: $lt  exp: $localtime\n");
> I get the following as typical of the problem:
>     5 perl-current > ./perl -Ilib ext/threads/t/libc.t
>     1..11
>     ok 1 - use threads
>     got: Wed Dec 31 20:00:08 1969  exp: Wed Dec 31 19:00:08 1969
> [...]
> This shows a 1 hour difference between the expected and
> actual results - which looks like a timezone issue.
> As the changes for 1.5.25 include numerous references to
> timezone handling changes, I suspect there may be some
> re-entrancy bug in those changes.

Corinna Vinschen wrote:
> It would be more helpful if you would send self-contained code which
> doesn't have to be tweaked to do a test.  I'm not a perl developer, so
> it took me some time to get it running.  I'd also really prefer
> testcases in plain C which I can simply run under GDB.  Interpreter code
> just adds unnecessary complexity.

I was working on this when I got your email.  Attached.

> I assume the perl libs are using localtime_r, right?  Otherwise you
> can't rely on reentrency nor thread-safety.  Anyway, localtime is
> supposed to be thread-safe in Cygwin.

I believe this is correct.

> The only change in 1.5.25 related to localtime is the fact that the
> environment variable "TZ" is now left alone by Cygwin.  Up to 1.5.24 the
> function tzset() (called by localtime()) also sets the environment
> variable "TZ", which is apparently incorrect according to POSIX.  "TZ"
> is used in later calls to decide whether some other code has to be run
> or not.
> And exactly that's the problem.  Since TZ is now never set, that other
> code, which is not thread-safe, is called much more frequent than
> necessary.  Actually it should only be called once per process, now it's
> called once per invocation of tzset().  I've applied a patch to the 1.5.x
> branch and will release an updated 1.5.25 in the next couple of days.

Hope my test program helps to verify this.

Attachment: loctim_bug.c
Description: Text document

Unsubscribe info:
Problem reports:

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