Skip Menu |

This queue is for tickets about the Net-SSH2 CPAN distribution.

Report information
The Basics
Id: 27582
Status: rejected
Priority: 0/
Queue: Net-SSH2

People
Owner: Nobody in particular
Requestors: rbsmithz [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: segfault with threads
Date: Thu, 14 Jun 2007 07:41:16 -0600
To: bug-Net-SSH2 [...] rt.cpan.org
From: "Randall Smith" <rbsmithz [...] gmail.com>
The following code generates a segfault because the same Net:SSH2 object is destroyed twice. It would be great if SSH2 could be thread safe. Randy use Net::SSH2; use threads; sub s { print "sub s"; } my $ssh = Net::SSH2->new(); $ssh->debug(1); my $thread = threads->create('s'); $thread->join();
The problem seems to be outline in http://perlmonks.org/?node_id=632731: as you say, in DESTROY we destroy the object in each thread, which results in multiple releases which understandably makes the library very grumpy. I don't like the idea of having to manually keep track of a threaded reference count (by tracking CLONE or using threads::shared::refcnt), since neither method is especially reliable (see e.g. http://www.nntp.perl.org/group/perl.ithreads/2007/08/msg1197.html). For now I'm going to have to recommend you declare the Net::SSH2 objects as shared, rather than thread-local, until a better solution exists.