develooper Front page | perl.perl5.porters | Postings from April 2018

[perl #125106] Why are threads discouraged?

Thread Previous | Thread Next
From:
Sergey Aleynikov via RT
Date:
April 10, 2018 13:43
Subject:
[perl #125106] Why are threads discouraged?
Message ID:
rt-4.0.24-17385-1523367764-1403.125106-15-0@perl.org
On Tue, 10 Apr 2018 04:04:06 -0700, davem wrote:

The problem is in people's expectations. When most part of something is thread-safe, they'll just assume "everything is thread-safe" and then'll be hit very hard. One of the examples I like is Mouse, which was thread-unsafe until the year 2015. While it's not as popular as Moose, it's still a module with large a large user base. And your chances to encounter bugs in not so popular XS modules are much, much higher. What's even worse, you're likely to hit them only under some unlucky circumstances (see example below).

As for the core, I agree that it's now much more thread-stable than before. Somewhere around 5.12 or 5.14 I've prepared a talk named "no threads" with some nice crash examples in it - they crash no more. But still, locale handling was thread-unsafe until 5.24 (or 5.26?) - just because of no one has discovered that. And the following still fails loudly (though not dumps a core);

while (1) {
    push @foo, threads->create(sub {
        require IO::Handle;
    });
    $_->detach for(splice @foo);
}

So while yes, perl is much more thread-safe inherently as it used to be, I won't recommend using threads in it to anyone.

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=125106

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About