Admittedly, I have only waited roughly an hour for this to run, but that is sufficient for 100 threads to explore the possibilities of each your speculative modes of failure, for 100 million plus iterations each. (Ignoring all the other threaded code I've ever written that could have done so)
I consider that a pretty conclusive demonstration that you're talking out your a the top of your head.
Of course you could have tried this trivial test of your speculations yourself, in the same minimal amount of time, before posting such FUD, but that wouldn't meet your apparent motivations.
#! perl -slw
use strict;
use threads stack_size => 4096;
use threads::shared;
open STDOUT, '>', 'nul' or die;
my $shared1 :shared = 1;
my $shared2 :shared = 2;
my $shared3 :shared = 3;
my @counts :shared = (0)x3;
sub FUD1 {
## According to ikegami
## $shared = "abc"; # Can cause scalar type conversion
## leading to [867132|a segfault]
while( 1 ) {
my $chance = rand;
$shared1 =
$chance < 0.333333333 ? "fred$chance" :
$chance < 0.666666666 ? $chance :
int( $chance * 100 );
lock @counts;
++$counts[0];
}
}
sub FUD2 {
## According to ikegami
## [867127|my $ref = \$shared; # Increments ref count]
## leading to [867132|premature deallocation]
while( 1 ) {
{
my $ref = \$shared2;
}
die unless defined $shared2;
lock @counts;
++$counts[1];
}
}
sub FUD3 {
## According to ikegami
## [867127|print "$shared\n"; # Implicit type conversion]
## leading to [867132|a segfault]
while( 1 ) {
print "$shared3";
++$shared3;
lock @counts;
++$counts[2];
}
}
async( \&FUD1 )->detach for 1 .. 100;
async( \&FUD2 )->detach for 1 .. 100;
async( \&FUD3 )->detach for 1 .. 100;
printf STDERR "\r@counts" while sleep 1;
__END__
C:\test>ikeFUD1.pl
108788021 167537823 101758175
Terminating on signal SIGINT(2)
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|