summaryrefslogtreecommitdiff
path: root/ext/threads
diff options
context:
space:
mode:
authorDave Mitchell <davem@fdisolutions.com>2007-09-14 18:25:44 +0000
committerDave Mitchell <davem@fdisolutions.com>2007-09-14 18:25:44 +0000
commit863e9b4aa72b7b080129007c00c2b1efa2a78bca (patch)
treebe688134cdbbf6ff241b7ca62dbc72179d71f334 /ext/threads
parent636e63cb2d86040c1b02edfaea110c6993a0b8de (diff)
downloadperl-863e9b4aa72b7b080129007c00c2b1efa2a78bca.tar.gz
[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
Diffstat (limited to 'ext/threads')
-rw-r--r--ext/threads/t/thread.t10
-rwxr-xr-xext/threads/threads.xs2
2 files changed, 10 insertions, 2 deletions
diff --git a/ext/threads/t/thread.t b/ext/threads/t/thread.t
index 9a2a097d55..0cc59dc628 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 e1414de877..54fbaa0e06 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));
}
}