From: Dave Mitchell Date: Fri, 14 Sep 2007 18:25:44 +0000 (+0000) Subject: [perl #45053] Memory corruption with heavy module loading in threads X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=863e9b4aa72b7b080129007c00c2b1efa2a78bca;p=p5sagit%2Fp5-mst-13.2.git [perl #45053] Memory corruption with heavy module loading in threads In void context, eval leaves garbage on the stack. Don't then copy this back into the threads->param array! p4raw-id: //depot/perl@31864 --- diff --git a/ext/threads/t/thread.t b/ext/threads/t/thread.t index 9a2a097..0cc59dc 100644 --- a/ext/threads/t/thread.t +++ b/ext/threads/t/thread.t @@ -30,7 +30,7 @@ BEGIN { } $| = 1; - print("1..33\n"); ### Number of tests that will be run ### + print("1..34\n"); ### Number of tests that will be run ### }; print("ok 1 - Loaded\n"); @@ -194,6 +194,14 @@ fresh_perl_is(<<'EOI', 'ok', { }, 'thread sub via $_[0]'); print 'ok'; EOI +# [perl #45053] Memory corruption from eval return in void context +fresh_perl_is(<<'EOI', 'ok', { }, 'void eval return'); + use threads; + threads->create(sub { eval '1' }); + $_->join() for threads->list; + print 'ok'; +EOI + # test CLONE_SKIP() functionality if ($] >= 5.008007) { my %c : shared; diff --git a/ext/threads/threads.xs b/ext/threads/threads.xs index e1414de..54fbaa0 100755 --- a/ext/threads/threads.xs +++ b/ext/threads/threads.xs @@ -452,7 +452,7 @@ S_ithread_run(void * arg) SPAGAIN; for (ii=len-1; ii >= 0; ii--) { SV *sv = POPs; - if (jmp_rc == 0) { + if (jmp_rc == 0 && (! (thread->gimme & G_VOID))) { av_store(params, ii, SvREFCNT_inc(sv)); } }