Change 32091 by [EMAIL PROTECTED] on 2007/10/10 15:03:16 newCONTSUB() wasn't thread-safe ([perl #45053])
Affected files ... ... //depot/perl/ext/threads/t/problems.t#18 edit ... //depot/perl/op.c#958 edit Differences ... ==== //depot/perl/ext/threads/t/problems.t#18 (text) ==== Index: perl/ext/threads/t/problems.t --- perl/ext/threads/t/problems.t#17~31687~ 2007-08-08 09:43:49.000000000 -0700 +++ perl/ext/threads/t/problems.t 2007-10-10 08:03:16.000000000 -0700 @@ -29,9 +29,9 @@ $| = 1; if ($] == 5.008) { - print("1..11\n"); ### Number of tests that will be run ### + print("1..12\n"); ### Number of tests that will be run ### } else { - print("1..15\n"); ### Number of tests that will be run ### + print("1..16\n"); ### Number of tests that will be run ### } }; @@ -178,4 +178,20 @@ $child = threads->create(sub { return (scalar(keys(%h))); })->join; is($child, 1, "keys correct in child with restricted hash"); + +# [perl #45053] Memory corruption with heavy module loading in threads +# +# run-time usage of newCONSTSUB (as done by the IO boot code) wasn't +# thread-safe - got occasional coredumps or malloc corruption + +{ + my @t; + push @t, threads->create( sub { require IO }) for 1..100; + $_->join for @t; + print("ok $test - [perl #45053]\n"); + $test++; +} + + + # EOF ==== //depot/perl/op.c#958 (text) ==== Index: perl/op.c --- perl/op.c#957~31936~ 2007-09-21 00:54:47.000000000 -0700 +++ perl/op.c 2007-10-10 08:03:16.000000000 -0700 @@ -5696,6 +5696,13 @@ ENTER; + if (IN_PERL_RUNTIME) { + /* at runtime, it's not safe to manipulate PL_curcop: it may be + * an op shared between threads. Use a non-shared COP for our + * dirty work */ + SAVEVPTR(PL_curcop); + PL_curcop = &PL_compiling; + } SAVECOPLINE(PL_curcop); CopLINE_set(PL_curcop, PL_parser ? PL_parser->copline : NOLINE); End of Patch.