Created
March 23, 2012 11:19
-
-
Save schwern/2169715 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Individually change to any of the "no segfault" versions and it works. | |
use strict; | |
use warnings; | |
use threads; | |
use threads::shared; | |
use TB2::TestState; | |
{ | |
my %defaults; # segfault | |
# my %defaults :shared; # no segfault | |
sub default { | |
my $class = shift; | |
if( !$defaults{$class} ) { | |
my $o = $class->create; | |
# See TB2::CanThread for the shared_clone wrapper | |
$o = $o->shared_clone($o); # segfault | |
# $o = shared_clone($o); # no segfault | |
$defaults{$class} = $o; | |
} | |
return $defaults{$class}; | |
} | |
} | |
print default("TB2::TestState"); # segfault | |
# my %defaults; | |
# $defaults{"TB2::TestState"} = TB2::TestState->make_default; # no segfault |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment