Skip Menu |

This queue is for tickets about the IO-Socket-SSL CPAN distribution.

Report information
The Basics
Id: 20824
Status: rejected
Priority: 0/
Queue: IO-Socket-SSL

People
Owner: Nobody in particular
Requestors: nicolas [...] hni.uni-paderborn.de
Cc:
AdminCc:

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



Subject: IO::Socket::SSL not threadsave?
Date: Thu, 03 Aug 2006 10:32:14 +0200
To: bug-IO-Socket-SSL [...] rt.cpan.org
From: Nicolas Lerch <nicolas [...] hni.uni-paderborn.de>
Hallo, I have tried to build a multi threaded SSL server but every time a client tries to connect the server crashes with a segmentation fault: Server: nicolas@plucky[perl]>>./ssl_server.pl Enter PEM pass phrase: Client: nicolas@plucky[perl]>>./ssl_client.pl write_all VM at entry=vm_unknown partial `Hallo ' written so far 6:6 bytes (VM=vm_unknown) nicolas@plucky[perl]>> Server: Segmentation fault nicolas@plucky[perl]>> I have tested it with the versions 0.96 and 0.994 of the IO::Socket::SSL module. My perl version is 5.8.4 running on Debian Linux with 2.6.15 kernel. Below is the code for the client and the server. The same code without threads works as it should. Server: --------------------------------------------------------------- #!/usr/bin/perl -w use strict; use threads; use IO::Socket::SSL qw(debug4); my $listen = new IO::Socket::SSL ( LocalPort => 6666, Proto => 'tcp', Listen => 10, SSL_key_file => 'certs/test-key.pem', SSL_cert_file => 'certs/test-cert.pem', SSL_use_cert => 1, SSL_ca_file => 'certs/testca-cacert.pem' ) or die "Error: $!\n"; while(my $socket = $listen->accept) { async(\&receive, $socket)->detach; } sub receive { my $socket = shift; while (<$socket>) { print "DATA: ".$_."\n"; } } --------------------------------------------------------------- Client: --------------------------------------------------------------- #!/usr/bin/perl -w use strict; use threads; use IO::Socket::SSL qw(debug4); my $port = 6666; my $server = 'plucky.hni.uni-paderborn.de'; my $sock = new IO::Socket::SSL ( PeerAddr => 'localhost', PeerPort => 6666, Proto => 'tcp', Timeout => '5', SSL_verify_mode => 0x01, SSL_ca_file => 'certs/testca-cacert.pem' ); my $select = IO::Select->new(); $select->add($sock); print $sock "Hallo\n"; --------------------------------------------------------------- Best regards Nicolas Lerch -- ====================================================== Nicolas Lerch HNI Rechnerbetrieb nicolas@hni.uni-paderborn.de ======================================================
IO::Socket::SSL is a pure perl wrapper around Net::SSLeay and has no thread shared variables. Therefore one can assume, that the problem is not within IO::Socket::SSL but in Net::SSleay. From the documentation of Net::SSLeay: | The high level API functions use a global file handle SSLCAT_S | internally. This really should not be a problem because there is no way | to interleave the high level API functions, unless you use threads (but | threads are not very well supported in perl anyway (as of version | 5.6.1). However, you may run into problems if you call undocumented | internal functions in an interleaved fashion. So I assume Net::SSLeay is not thread safe and therefore IO::Socket::SSL is not thread safe. Sorry. I'll put a note into the documentation about it.