Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit 230d1da

Browse files
committed
threads: Update to 2.16_01
Fix Clang macro backward compatibility per patch by Andy Grundman cperl: Keep the old better pod, bump to 2.16_01. The old pod had the technical explanation, why ithreads are slow, how it works and why fork is preferred. Keep our modglobal fix on global destruction from our 2.12_01 (upstream still broken).
1 parent c87a551 commit 230d1da

File tree

12 files changed

+131
-73
lines changed

12 files changed

+131
-73
lines changed

MANIFEST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3874,6 +3874,7 @@ dist/threads/t/stress_cv.t Test with multiple threads, coderef cv argument.
38743874
dist/threads/t/stress_re.t Test with multiple threads, string cv argument and regexes.
38753875
dist/threads/t/stress_string.t Test with multiple threads, string cv argument.
38763876
dist/threads/t/thread.t General ithread tests from thr5005
3877+
dist/threads/t/unique.t
38773878
dist/threads/threads.xs ithreads
38783879
dist/threads-shared/Changes threads::shared ChangeLog
38793880
dist/threads-shared/hints/linux.pl thread shared variables

Porting/Maintainers.pl

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,7 +1460,7 @@ package Maintainers;
14601460
},
14611461

14621462
'threads' => {
1463-
'DISTRIBUTION' => 'JDHEDDEN/threads-2.15.tar.gz',
1463+
'DISTRIBUTION' => 'JDHEDDEN/threads-2.16.tar.gz',
14641464
'FILES' => q[dist/threads],
14651465
'EXCLUDED' => [
14661466
qr{^examples/},
@@ -1469,12 +1469,15 @@ package Maintainers;
14691469
threads.h
14701470
),
14711471
],
1472-
# protect ithread_free from deleted PL_modglobal
1473-
#'CUSTOMIZED' => [
1474-
# qw( threads.xs
1475-
# lib/threads.pm
1476-
# ),
1477-
#],
1472+
# test locale race #127708
1473+
# use old pod, tech. explanation: slow, rather use fork
1474+
# fix my_pool init in global destruction
1475+
'CUSTOMIZED' => [
1476+
qw( t/locale.t
1477+
lib/threads.pm
1478+
threads.xs
1479+
),
1480+
],
14781481
},
14791482

14801483
'threads::shared' => {

dist/Module-CoreList/lib/Module/CoreList.pm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14978,6 +14978,7 @@ our %delta = (
1497814978
'Net::Ping' => '2.61',
1497914979
'Search::Dict' => '1.07_01',
1498014980
'SelectSaver' => '1.02_01',
14981+
'threads' => '2.16_01',
1498114982
'VMS::Studio' => '2.41_01',
1498214983
},
1498314984
removed => {
@@ -15154,6 +15155,7 @@ our %delta = (
1515415155
'SelectSaver' => '1.02_01',
1515515156
'Storable' => '3.05_13',
1515615157
'strict' => '1.13c',
15158+
'threads' => '2.16_01',
1515715159
'VMS::Studio' => '2.41_01',
1515815160
'Win32API::File' => '0.1204',
1515915161
},

dist/threads/Changes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
Revision history for Perl extension threads.
22

3+
2.16 Sun May 7 22:32:59 2017
4+
- Fix Clang macro backward compatibility per patch by Andy Grundman
5+
- Sync from blead
6+
37
2.15 Sun Feb 26 22:45:33 2017
48
- Sync from blead
59

dist/threads/lib/threads.pm

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use 5.008;
55
use strict;
66
use warnings;
77

8-
our $VERSION = '2.15';
8+
our $VERSION = '2.16_01';
99
my $XS_VERSION = $VERSION;
1010
$VERSION = eval $VERSION;
1111

@@ -29,7 +29,8 @@ $threads::threads = 1;
2929

3030
# Load the XS code
3131
require XSLoader;
32-
XSLoader::load("threads", $XS_VERSION);
32+
XSLoader::load('threads', $XS_VERSION);
33+
3334

3435
### Export ###
3536

@@ -133,7 +134,7 @@ threads - Perl interpreter-based threads
133134
134135
=head1 VERSION
135136
136-
This document describes threads version 2.15
137+
This document describes threads version 2.16
137138
138139
=head1 WARNING
139140

dist/threads/t/exit.t

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ my $rc = $thr->join();
4848
ok(! defined($rc), 'Exited: threads->exit()');
4949

5050

51-
run_perl(prog => 'use threads 2.15;' .
51+
run_perl(prog => 'use threads 2.16;' .
5252
'threads->exit(86);' .
5353
'exit(99);',
5454
nolib => ($ENV{PERL_CORE}) ? 0 : 1,
@@ -98,7 +98,7 @@ $rc = $thr->join();
9898
ok(! defined($rc), 'Exited: $thr->set_thread_exit_only');
9999

100100

101-
run_perl(prog => 'use threads 2.15 qw(exit thread_only);' .
101+
run_perl(prog => 'use threads 2.16 qw(exit thread_only);' .
102102
'threads->create(sub { exit(99); })->join();' .
103103
'exit(86);',
104104
nolib => ($ENV{PERL_CORE}) ? 0 : 1,
@@ -108,7 +108,7 @@ run_perl(prog => 'use threads 2.15 qw(exit thread_only);' .
108108
is($?>>8, 86, "'use threads 'exit' => 'thread_only'");
109109
}
110110

111-
my $out = run_perl(prog => 'use threads 2.15;' .
111+
my $out = run_perl(prog => 'use threads 2.16;' .
112112
'threads->create(sub {' .
113113
' exit(99);' .
114114
'});' .
@@ -124,7 +124,7 @@ my $out = run_perl(prog => 'use threads 2.15;' .
124124
like($out, qr/1 finished and unjoined/, "exit(status) in thread");
125125

126126

127-
$out = run_perl(prog => 'use threads 2.15 qw(exit thread_only);' .
127+
$out = run_perl(prog => 'use threads 2.16 qw(exit thread_only);' .
128128
'threads->create(sub {' .
129129
' threads->set_thread_exit_only(0);' .
130130
' exit(99);' .
@@ -141,7 +141,7 @@ $out = run_perl(prog => 'use threads 2.15 qw(exit thread_only);' .
141141
like($out, qr/1 finished and unjoined/, "set_thread_exit_only(0)");
142142

143143

144-
run_perl(prog => 'use threads 2.15;' .
144+
run_perl(prog => 'use threads 2.16;' .
145145
'threads->create(sub {' .
146146
' $SIG{__WARN__} = sub { exit(99); };' .
147147
' die();' .

dist/threads/t/problems.t

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,14 @@ BEGIN {
2121

2222
$| = 1;
2323
if ($] == 5.008) {
24-
print("1..11\n"); ### Number of tests that will be run ###
24+
print("1..6\n"); ### Number of tests that will be run ###
2525
} else {
26-
print("1..15\n"); ### Number of tests that will be run ###
26+
print("1..10\n"); ### Number of tests that will be run ###
2727
}
2828
};
2929

3030
print("ok 1 - Loaded\n");
3131

32-
### Start of Testing ###
33-
34-
no warnings 'deprecated'; # Suppress warnings related to :unique
35-
3632
use Hash::Util 'lock_keys';
3733

3834
my $test :shared = 2;
@@ -93,50 +89,6 @@ if ($] != 5.008)
9389
}
9490

9591

96-
# bugid 24383 - :unique hashes weren't being made readonly on interpreter
97-
# clone; check that they are.
98-
99-
our $unique_scalar : unique;
100-
our @unique_array : unique;
101-
our %unique_hash : unique;
102-
threads->create(sub {
103-
lock($test);
104-
my $TODO = ":unique needs to be re-implemented in a non-broken way";
105-
eval { $unique_scalar = 1 };
106-
print $@ =~ /read-only/
107-
? '' : 'not ', "ok $test # TODO $TODO - unique_scalar\n";
108-
$test++;
109-
eval { $unique_array[0] = 1 };
110-
print $@ =~ /read-only/
111-
? '' : 'not ', "ok $test # TODO $TODO - unique_array\n";
112-
$test++;
113-
if ($] >= 5.008003 && $^O ne 'MSWin32') {
114-
eval { $unique_hash{abc} = 1 };
115-
print $@ =~ /disallowed/
116-
? '' : 'not ', "ok $test # TODO $TODO - unique_hash\n";
117-
} else {
118-
print("ok $test # SKIP $TODO - unique_hash\n");
119-
}
120-
$test++;
121-
})->join;
122-
123-
# bugid #24940 :unique should fail on my and sub declarations
124-
125-
for my $decl ('my $x : unique', 'sub foo : unique') {
126-
{
127-
lock($test);
128-
if ($] >= 5.008005) {
129-
eval $decl;
130-
print $@ =~ /^The 'unique' attribute may only be applied to 'our' variables/
131-
? '' : 'not ', "ok $test - $decl\n";
132-
} else {
133-
print("ok $test # SKIP $decl\n");
134-
}
135-
$test++;
136-
}
137-
}
138-
139-
14092
# Returning a closure from a thread caused problems. If the last index in
14193
# the anon sub's pad wasn't for a lexical, then a core dump could occur.
14294
# Otherwise, there might be leaked scalars.

dist/threads/t/thread.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ package main;
161161

162162
# bugid #24165
163163

164-
run_perl(prog => 'use threads 2.15;' .
164+
run_perl(prog => 'use threads 2.16;' .
165165
'sub a{threads->create(shift)} $t = a sub{};' .
166166
'$t->tid; $t->join; $t->tid',
167167
nolib => ($ENV{PERL_CORE}) ? 0 : 1,

dist/threads/t/unique.t

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
use strict;
2+
use warnings;
3+
4+
BEGIN {
5+
use Config;
6+
if (! $Config{'useithreads'}) {
7+
print("1..0 # SKIP Perl not compiled with 'useithreads'\n");
8+
exit(0);
9+
}
10+
if ($] >= 5.027000) {
11+
print("1..0 # SKIP 'unique' attribute no longer exists\n");
12+
exit(0);
13+
}
14+
}
15+
16+
use ExtUtils::testlib;
17+
18+
use threads;
19+
20+
BEGIN {
21+
if (! eval 'use threads::shared; 1') {
22+
print("1..0 # SKIP threads::shared not available\n");
23+
exit(0);
24+
}
25+
26+
$| = 1;
27+
print("1..6\n") ; ### Number of tests that will be run ###
28+
}
29+
30+
print("ok 1 - Loaded\n");
31+
32+
### Start of Testing ###
33+
34+
no warnings 'deprecated'; # Suppress warnings related to :unique
35+
36+
my $test :shared = 2;
37+
38+
# bugid 24383 - :unique hashes weren't being made readonly on interpreter
39+
# clone; check that they are.
40+
41+
our $unique_scalar : unique;
42+
our @unique_array : unique;
43+
our %unique_hash : unique;
44+
threads->create(sub {
45+
lock($test);
46+
my $TODO = ":unique needs to be re-implemented in a non-broken way";
47+
eval { $unique_scalar = 1 };
48+
print $@ =~ /read-only/
49+
? '' : 'not ', "ok $test # TODO $TODO - unique_scalar\n";
50+
$test++;
51+
eval { $unique_array[0] = 1 };
52+
print $@ =~ /read-only/
53+
? '' : 'not ', "ok $test # TODO $TODO - unique_array\n";
54+
$test++;
55+
if ($] >= 5.008003 && $^O ne 'MSWin32') {
56+
eval { $unique_hash{abc} = 1 };
57+
print $@ =~ /disallowed/
58+
? '' : 'not ', "ok $test # TODO $TODO - unique_hash\n";
59+
} else {
60+
print("ok $test # SKIP $TODO - unique_hash\n");
61+
}
62+
$test++;
63+
})->join;
64+
65+
# bugid #24940 :unique should fail on my and sub declarations
66+
67+
for my $decl ('my $x : unique', 'sub foo : unique') {
68+
{
69+
lock($test);
70+
if ($] >= 5.008005) {
71+
eval $decl;
72+
print $@ =~ /^The 'unique' attribute may only be applied to 'our' variables/
73+
? '' : 'not ', "ok $test - $decl\n";
74+
} else {
75+
print("ok $test # SKIP $decl\n");
76+
}
77+
$test++;
78+
}
79+
}
80+
81+

dist/threads/threads.xs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#endif
2121
#ifdef HAS_PPPORT_H
2222
# define NEED_PL_signals
23-
# define NEED_newRV_noinc
2423
# define NEED_sv_2pv_flags
2524
# include "ppport.h"
2625
# include "threads.h"
@@ -133,9 +132,9 @@ typedef struct {
133132
IV page_size;
134133
} my_pool_t;
135134

136-
#define dMY_POOL \
137-
SV *my_pool_sv = *hv_fetch(PL_modglobal, MY_POOL_KEY, \
138-
sizeof(MY_POOL_KEY)-1, TRUE); \
135+
#define dMY_POOL \
136+
SV *my_pool_sv = *hv_fetch(PL_modglobal, MY_POOL_KEY, \
137+
sizeof(MY_POOL_KEY)-1, TRUE); \
139138
my_pool_t *my_poolp = INT2PTR(my_pool_t*, SvUV(my_pool_sv))
140139

141140
#define MY_POOL_set \
@@ -1031,10 +1030,13 @@ S_ithread_create(
10311030
MUTEX_UNLOCK(&my_pool->create_destruct_mutex);
10321031
return (thread);
10331032

1033+
#if defined(CLANG_DIAG_IGNORE)
10341034
CLANG_DIAG_IGNORE(-Wthread-safety);
10351035
/* warning: mutex 'thread->mutex' is not held on every path through here [-Wthread-safety-analysis] */
1036+
#endif
10361037
}
1037-
#if defined(__clang__) || defined(__clang)
1038+
/* perl.h defines CLANG_DIAG_* but only in 5.24+ */
1039+
#if defined(CLANG_DIAG_RESTORE)
10381040
CLANG_DIAG_RESTORE
10391041
#endif
10401042

@@ -1506,7 +1508,9 @@ ithread_kill(...)
15061508
MUTEX_UNLOCK(&thread->mutex);
15071509

15081510
if (no_handler) {
1509-
Perl_croak(aTHX_ "Signal %s received in thread %" UVuf ", but no signal handler set.", sig_name, thread->tid);
1511+
Perl_croak(aTHX_ "Signal %s received in thread %" UVuf
1512+
", but no signal handler set.",
1513+
sig_name, thread->tid);
15101514
}
15111515

15121516
/* Return the thread to allow for method chaining */
@@ -1830,6 +1834,7 @@ BOOT:
18301834
SV *my_pool_sv = *hv_fetch(PL_modglobal, MY_POOL_KEY,
18311835
sizeof(MY_POOL_KEY)-1, TRUE);
18321836
my_pool_t *my_poolp = (my_pool_t*)SvPVX(newSV(sizeof(my_pool_t)-1));
1837+
18331838
MY_CXT_INIT;
18341839

18351840
Zero(my_poolp, 1, my_pool_t);

0 commit comments

Comments
 (0)