Attached patch fixes return value of ref() on shared refs of refs when stored in other shared structures. (See below for sample test.) The patch also makes t/stress.t not fail if thread creations fail due to ENOMEM. Sample program: #!/usr/bin/perl use strict; use warnings; use threads; use threads::shared; use Test::More ('tests' => 3); my $x : shared; my $y : shared; my $z : shared; $x = \$y; $y = \$z; is(ref($x), 'REF', '$x is a REF'); my @q : shared = ($x); is(ref($q[0]), 'REF', '$q[0] is a REF'); my $w = $q[0]; is(ref($w), 'REF', '$w is a REF'); # EOF Output before patch: 1..3 ok 1 - $x is a REF not ok 2 - $q[0] is a REF # Failed test '$q[0] is a REF' # at stuff/bugs/debug.pl line 19. # got: 'SCALAR' # expected: 'REF' not ok 3 - $w is a REF # Failed test '$w is a REF' # at stuff/bugs/debug.pl line 22. # got: 'SCALAR' # expected: 'REF' # Looks like you failed 2 tests of 3. Output after patch: 1..3 ok 1 - $x is a REF ok 2 - $q[0] is a REF ok 3 - $w is a REFThread Next