in reply to Re: Activestate 5.8.2 broke my threads :(
in thread Activestate 5.8.2 broke my threads :(

Roger, Thanks for your effort, much appreciated, especially that as side effect fixed my problem :), which I now consider real Perl 5.8.2 bug, at least for AS Windows. But one word first. My problem was also to do with sockets in concurrent threads, so replacing in the thread the socket code with sleep() is not true simulation of the problem. So I want to report the fix for the record: What fixes the problem is moving the threads->detach() on separate line! Thats all. (Long time ago I used to have the lines separate, but some Perl Guru told me it is not Perlish :(, but it worked until 5.8.2. BTW, I still have some instability problems that were not present in earlier version. Thanks all.
  • Comment on Re: Re: Activestate 5.8.2 broke my threads :(

Replies are listed 'Best First'.
Re: Re: Re: Activestate 5.8.2 broke my threads :(
by Roger (Parson) on Dec 22, 2003 at 21:01 UTC
    I have considered moving threads->detach() on a separate line before I made my original post though, but moving detach on to another line is not doing what you think it's doing. The following codes are not equivalent:
    threads->create(\&create_threads, "param")->detach();
    and
    threads->create(\&create_threads, "param"); threads->detach();
    In the first example, detach() is performed on the object returned by threads->create(), which detaches the thread created. Moving detach() on a separate line does not detach the thread at all, calling threads->detach() separately has no effect on the thread you just created.

    The proof? Well, there is a threads->list() function that lists all non-joined, non-detached threads. Add threads->list() after threads->detach() showed that the created thread did not get detached at all.

    I agree there is definitely a bug with detach() on out of scope object, but moving detach() on a separate line is not a fix. You must call $thread_created->detach() to truly detach the thread.

      Roger,

      Thanks again for your time and effort. Your help was to the point. Much appreciated.

      Alas, you were right that the threads were not detached, so Perl didn't crash as apparently the detach() causes it. With the proper detach(), even on separate line, Perl crashs again :(

      Also crashes if I move the detach to inside the thread

      threads->self->detach();

      Now if only AS will fix the problems in Windows Perl v5.8.2 soon or I will have to fall back to 5.8.0:(