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)
In reply to Re^2: Utter FUD!
by BrowserUk
in thread is ||= threadsafe?
by perl-diddler
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |