X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Date: Tue, 11 Dec 2007 16:02:47 +0100 From: Corinna Vinschen To: cygwin AT cygwin DOT com Cc: perl5-porters AT perl DOT org Subject: Re: BUG: Timezone failures with threads under Cygwin 1.5.25 Message-ID: <20071211150247.GH6618@calimero.vinschen.de> Reply-To: cygwin AT cygwin DOT com, perl5-porters AT perl DOT org Mail-Followup-To: cygwin AT cygwin DOT com, perl5-porters AT perl DOT org References: <1ff86f510712101400w4e8160ccr47a0d949b7548949 AT mail DOT gmail DOT com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1ff86f510712101400w4e8160ccr47a0d949b7548949@mail.gmail.com> User-Agent: Mutt/1.5.16 (2007-06-09) Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com On Dec 10 17:00, 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. 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 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. 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. Thanks for the report, Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Project Co-Leader cygwin AT cygwin DOT com Red Hat -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/