| delorie.com/archives/browse.cgi | search |
| X-Recipient: | archive-cygwin AT delorie DOT com |
| X-Spam-Check-By: | sourceware.org |
| Message-ID: | <1ff86f510712101400w4e8160ccr47a0d949b7548949@mail.gmail.com> |
| Date: | Mon, 10 Dec 2007 17:00:52 -0500 |
| From: | "Jerry D. Hedden" <jdhedden AT cpan DOT org> |
| To: | cygwin AT cygwin DOT com |
| Subject: | BUG: Timezone failures with threads under Cygwin 1.5.25 |
| Cc: | pp <perl5-porters AT perl DOT org> |
| MIME-Version: | 1.0 |
| X-Google-Sender-Auth: | 4c752d149bafaf14 |
| X-IsSubscribed: | yes |
| Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
| List-Id: | <cygwin.cygwin.com> |
| List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
| List-Archive: | <http://sourceware.org/ml/cygwin/> |
| List-Post: | <mailto:cygwin AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
| Sender: | cygwin-owner AT cygwin DOT com |
| Mail-Followup-To: | cygwin AT cygwin DOT com |
| Delivered-To: | mailing list cygwin AT cygwin DOT com |
(CC'ed to perl5-porters for reference.)
The Perl test suite contains a file
(perl-current/ext/threads/t/libc.t) that exercises the
'localtime' call under threads. Here's the main code:
my $i = 10;
my $y = 20000;
my %localtime;
for (1..$i) {
$localtime{$_} = localtime($_);
};
my @threads;
for (1..$i) {
$threads[$_] = threads->create(sub {
my $arg = shift;
my $localtime = $localtime{$arg};
my $error = 0;
for (1..$y) {
my $lt = localtime($arg);
if ($localtime ne $lt) {
$error++;
}
}
return $error;
}, $_);
}
for (1..$i) {
is($threads[$_]->join(), 0, 'localtime() thread-safe');
}
This runs 10 threads that call 'localtime' 20,000 times
each.
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
got: Wed Dec 31 20:00:07 1969 exp: Wed Dec 31 19:00:07 1969
got: Wed Dec 31 20:00:06 1969 exp: Wed Dec 31 19:00:06 1969
got: Wed Dec 31 20:00:08 1969 exp: Wed Dec 31 19:00:08 1969
got: Wed Dec 31 20:00:07 1969 exp: Wed Dec 31 19:00:07 1969
got: Wed Dec 31 20:00:06 1969 exp: Wed Dec 31 19:00:06 1969
got: Wed Dec 31 20:00:10 1969 exp: Wed Dec 31 19:00:10 1969
ok 2 - localtime() thread-safe
ok 3 - localtime() thread-safe
ok 4 - localtime() thread-safe
ok 5 - localtime() thread-safe
ok 6 - localtime() thread-safe
not ok 7 - localtime() thread-safe
# Failed at ext/threads/t/libc.t line 52
# got '2'
# expected '0'
not ok 8 - localtime() thread-safe
# Failed at ext/threads/t/libc.t line 52
# got '2'
# expected '0'
not ok 9 - localtime() thread-safe
# Failed at ext/threads/t/libc.t line 52
# got '2'
# expected '0'
ok 10 - localtime() thread-safe
not ok 11 - localtime() thread-safe
# Failed at ext/threads/t/libc.t line 52
# got '1'
# expected '0'
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.
--
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/
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |