From e42956688f2e0df936f1a42811962946e4e185bf Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Thu, 25 Feb 2010 11:12:03 +0000 Subject: When deleting CLONE_PARAMS, push any unreferenced SVs onto the temps stack. Effectively this leaves the cloned-into interpreter in a consistent state. In the cloned-from interpreter, the SV targets of non-reference owning pointers *are* referenced and managed by other pointers. SvREFCNT() == 0 SVs in the cloned-into interpreter result from the non-reference owning pointers being found and followed, but the reference owning and managing pointers not being part of the subsection of interpreter state cloned over. Hence, this change creates reference owning pointers to this SVs on the temps stack, which ensures that they are correctly cleaned up, and don't "leak" until interpreter destruction. (Which might be some time away, in a persistent process.) --- t/op/threads.t | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 't') diff --git a/t/op/threads.t b/t/op/threads.t index 364045d995..95f5776bd3 100644 --- a/t/op/threads.t +++ b/t/op/threads.t @@ -116,10 +116,6 @@ print do 'op/threads_create.pl' || die $@; EOI -TODO: { - no strict 'vars'; # Accessing $TODO from test.pl - local $TODO = 'refcount issues with threads'; - # Scalars leaked: 1 foreach my $BLOCK (qw(CHECK INIT)) { fresh_perl_is(<create(sub{sub{}})->join() for 1...10; print "ok"; @@ -216,10 +210,10 @@ fresh_perl_like( # Simple closure-returning test: At least this case works (though it # leaks), and we don't want to break it. -fresh_perl_like(<<'EOJ', qr/^foo\n/, {}, 'returning a closure'); +fresh_perl_is(<<'EOJ', 'foo', {}, 'returning a closure'); use threads; print create threads sub { - my $x = "foo\n"; + my $x = 'foo'; sub{sub{$x}} }=>->join->()() //"undef" -- cgit v1.2.1