| Line | |
|---|
| 1 | #!./perl
|
|---|
| 2 | BEGIN {
|
|---|
| 3 | chdir 't' if -d 't';
|
|---|
| 4 | @INC = '../lib';
|
|---|
| 5 | require './test.pl'; # for which_perl() etc
|
|---|
| 6 | $| = 1;
|
|---|
| 7 | }
|
|---|
| 8 |
|
|---|
| 9 | use strict;
|
|---|
| 10 | use Config;
|
|---|
| 11 |
|
|---|
| 12 | BEGIN {
|
|---|
| 13 | if (!$Config{useithreads}) {
|
|---|
| 14 | print "1..0 # Skip: no ithreads\n";
|
|---|
| 15 | exit 0;
|
|---|
| 16 | }
|
|---|
| 17 | if ($ENV{PERL_CORE_MINITEST}) {
|
|---|
| 18 | print "1..0 # Skip: no dynamic loading on miniperl, no threads\n";
|
|---|
| 19 | exit 0;
|
|---|
| 20 | }
|
|---|
| 21 | plan(3);
|
|---|
| 22 | }
|
|---|
| 23 | use threads;
|
|---|
| 24 |
|
|---|
| 25 | # test that we don't get:
|
|---|
| 26 | # Attempt to free unreferenced scalar: SV 0x40173f3c
|
|---|
| 27 | fresh_perl_is(<<'EOI', 'ok', { }, 'delete() under threads');
|
|---|
| 28 | use threads;
|
|---|
| 29 | threads->new(sub { my %h=(1,2); delete $h{1}})->join for 1..2;
|
|---|
| 30 | print "ok";
|
|---|
| 31 | EOI
|
|---|
| 32 |
|
|---|
| 33 | #PR24660
|
|---|
| 34 | # test that we don't get:
|
|---|
| 35 | # Attempt to free unreferenced scalar: SV 0x814e0dc.
|
|---|
| 36 | fresh_perl_is(<<'EOI', 'ok', { }, 'weaken ref under threads');
|
|---|
| 37 | use threads;
|
|---|
| 38 | use Scalar::Util;
|
|---|
| 39 | my $data = "a";
|
|---|
| 40 | my $obj = \$data;
|
|---|
| 41 | my $copy = $obj;
|
|---|
| 42 | Scalar::Util::weaken($copy);
|
|---|
| 43 | threads->new(sub { 1 })->join for (1..1);
|
|---|
| 44 | print "ok";
|
|---|
| 45 | EOI
|
|---|
| 46 |
|
|---|
| 47 | #PR24663
|
|---|
| 48 | # test that we don't get:
|
|---|
| 49 | # panic: magic_killbackrefs.
|
|---|
| 50 | # Scalars leaked: 3
|
|---|
| 51 | fresh_perl_is(<<'EOI', 'ok', { }, 'weaken ref #2 under threads');
|
|---|
| 52 | package Foo;
|
|---|
| 53 | sub new { bless {},shift }
|
|---|
| 54 | package main;
|
|---|
| 55 | use threads;
|
|---|
| 56 | use Scalar::Util qw(weaken);
|
|---|
| 57 | my $object = Foo->new;
|
|---|
| 58 | my $ref = $object;
|
|---|
| 59 | weaken $ref;
|
|---|
| 60 | threads->new(sub { $ref = $object } )->join; # $ref = $object causes problems
|
|---|
| 61 | print "ok";
|
|---|
| 62 | EOI
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.