in reply to Re^4: Threads calling LWP causes exception
in thread Threads calling LWP causes exception

Sorry, I'm afraid you've moved beyond my ability to diagnose. This is your code exactly as posted, and the second run with the number of threads increased to 10, but otherwise unchanged:

c:\test>perl1 Starting LetsRock() WaitForThreads() started waiting for 1 Use of uninitialized value in print at perl_module1.pm line 43. Use of uninitialized value in print at perl_module1.pm line 43. waiting for 2 waiting for 3 Use of uninitialized value in print at perl_module1.pm line 43. waiting for 4 Use of uninitialized value in print at perl_module1.pm line 43. waiting for 5 Use of uninitialized value in print at perl_module1.pm line 43. WaitForThreads() finished Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 LetsRock() ended c:\test>perl1 Starting LetsRock() WaitForThreads() started waiting for 1 Use of uninitialized value in print at perl_module1.pm line 43. Use of uninitialized value in print at perl_module1.pm line 43. Use of uninitialized value in print at perl_module1.pm line 43. waiting for 2 waiting for 3 waiting for 4 Use of uninitialized value in print at perl_module1.pm line 43. waiting for 5 Use of uninitialized value in print at perl_module1.pm line 43. waiting for 6 Use of uninitialized value in print at perl_module1.pm line 43. waiting for 7 Use of uninitialized value in print at perl_module1.pm line 43. Use of uninitialized value in print at perl_module1.pm line 43. waiting for 8 waiting for 9 Use of uninitialized value in print at perl_module1.pm line 43. waiting for 10 Use of uninitialized value in print at perl_module1.pm line 43. WaitForThreads() finished Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 LetsRock() ended

I'm at a loss to know what else to suggest. If you had a missing required package, I would expect you to be seeing an error message detailing that, not an exception.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^6: Threads calling LWP causes exception
by mojoshaneman (Novice) on Mar 10, 2006 at 19:41 UTC
    Well this is real interesting. I setup a Windows 2003 Server without MS VS .NET 2003 installed on it. The Perl code works fine. I guess I'll move to a different dubugger soon. BTW, how can I get rid of the "Scalars leaked"?
      I setup a Windows 2003 Server without MS VS .NET 2003 installed on it. The Perl code works fine.

      Strange, but not entirely surprising. AS is built with VC++ v6, and I continue to build anything intended for use with Perl using the same compiler. Theoretically unnecessary, but maybe my instincts are good :)

      BTW, how can I get rid of the "Scalars leaked"?

      Change your LetsRock sub to call threads->create directly instead of via your (rather useless. Sorry:), Thread wrapper and the problem goes away.

      sub LetsRock { my (@kids); for (my $x=0; $x < 10; $x++) { my ($kid) = threads->create( \&ThreadFunc, 'https://www.wellsf +argo.com'); if (defined($kid)) { push(@kids, $kid); } sleep(1); } WaitForThreads(@kids); }

      Leaked scalars generally seem to be related to the use of variables passed to the thread through closure (as of 5.8.6 at least). Using the asynch() function seems particularly prone to this. Quite why this

      sub Thread { my ($function, @params) = @_; my ($thread); if (defined(&{$function})) { $thread = threads->create($function, @params); } return($thread); }

      causes a leaked scalar I'm not sure, maybe the defined(&{$function}), but I fail to see the benefit of that piece of indirection anyway? In fact, the whole sub seems pretty redundant to me.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        Thanks for your help.