Subject: | Random exceptions in POE::Component::Server::TCP line 302 |
Date: | Sun, 18 Aug 2013 08:54:50 -0700 |
To: | bug-POE [...] rt.cpan.org |
From: | Joseph Huckaby <jhuckaby [...] gmail.com> |
Hello POE Authors!
I am using POE::Component::Server::TCP for a simple web server, and indirectly by way of POE::Component::Server::IRC (both in the same script). I am using the latest POE version (v1.354). At random times, with seemingly no web or IRC traffic on my server at all, I am getting a full crash with this error:
Can't use an undefined value as a symbol reference at /usr/local/share/perl5/POE/Component/Server/TCP.pm line 302.
I was able to capture a stack trace, in case it helps:
main::__ANON__('Can\'t use an undefined value as a symbol reference at /usr/l...') called at /usr/local/share/perl5/POE/Kernel.pm line 1256
POE::Kernel::_rethrow_kr_exception('POE::Kernel=ARRAY(0x2495f48)') called at /usr/local/share/perl5/POE/Kernel.pm line 1244
POE::Kernel::run('POE::Kernel=ARRAY(0x2495f48)') called at /opt/simpleirc/bin/simpleircd.pl line 240
I believe the problem may be in this bit of code here, from POE/Component/Server/TCP.pm lines 302 - 306:
unless (fileno($socket)) {
# TODO - Error callback? Disconnected callback?
# TODO - Should we do this before starting the child?
return;
}
I believe it is possible that $socket can be undef when this code is reached. Perhaps with a carefully constructed (i.e. bad) socket request. That would certainly help explain my random crashes. My server is publicly accessible, and does receive "noise" from the internet. I have never seen this crash on my private server running locally on my Mac.
Anyway, I believe $socket should be checked before calling fileno() on it. Perhaps something like:
unless ($socket && ref($socket) && fileno($socket)) {
I have not been able to capture a tcpdump of this crash occurring, as it is very rare (once every few hours), and I cannot reproduce it by hand.
Here is my code, in case you are interested: https://github.com/jhuckaby/simpleirc
Thanks for your time, and thank you for an awesome Perl object event system!
I'm using Perl v5.10.1 (*) built for x86_64-linux-thread-multi, running on an Amazon EC2 instance with this kernel: Linux 3.4.43-43.43.amzn1.x86_64 #1 SMP Mon May 6 18:04:41 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux. POE is version 1.354.
- Joe