Skip Menu |
 

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

Report information
The Basics
Id: 67643
Status: open
Priority: 0/
Queue: Net-Daemon

People
Owner: Nobody in particular
Requestors: FBRIERE [...] cpan.org
Cc:
AdminCc:

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



Subject: config file parsing errors may trigger incorrect threading
Download (untitled) / with headers
text/plain 686b
(This is a forward of <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=623540>.) Here's an easy demonstration: $ dbiproxy --configfile foo Can't locate object method "self" via package "Thread" at /usr/share/perl5/Net/Daemon/Log.pm line 82. Basically, if Net::Daemon cannot properly parse the config file, it will call Fatal(), and thus Log(), to report the error. Log() expects the mode to have already been set, which it hasn't yet, as it is done a bit later in the constructor (since picking a default value may depend on other config options). I guess the easiest fix would be to set the mode so 'single' at first; there's not much threading information to report anyway.
From: m.nooning [...] comcast.net
Download (untitled) / with headers
text/plain 108b
You look like you are using Net-Daemon 0.47. Please try the newest module, Net-Daemon-0.48.tar.gz Thanks
Subject: Re: [rt.cpan.org #67643] config file parsing errors may trigger incorrect threading
Date: Thu, 21 Apr 2011 20:48:42 -0400
To: Malcolm Nooning via RT <bug-Net-Daemon [...] rt.cpan.org>
From: Frédéric Brière <fbriere [...] fbriere.net>
Download (untitled) / with headers
text/plain 756b
On Thu, Apr 21, 2011 at 08:12:09AM -0400, Malcolm Nooning via RT wrote: Show quoted text
> You look like you are using Net-Daemon 0.47. Please try the newest > module, Net-Daemon-0.48.tar.gz
$ perl -Ilib -MNet::Daemon -le 'print $Net::Daemon::VERSION; $d = new Net::Daemon { mode => "threads", configfile => "foo" };' 0.48 Can't locate object method "self" via package "Thread" at lib/Net/Daemon/Log.pm line 82. Notice how everything works fine once the post-configfile mode-setting has been done: $ perl -Ilib -MNet::Daemon -le 'print $Net::Daemon::VERSION; $d = new Net::Daemon { mode => "threads" }; $d->Fatal("ouch!")' 0.48 ouch! at -e line 1. at lib/Net/Daemon/Log.pm line 136. -- Keep the number of passes in a compiler to a minimum. -- D. Gries
From: m.nooning [...] comcast.net
Download (untitled) / with headers
text/plain 1.5k
I get the same error if foo does not exist. Does foo exist for you? C:\>perl -Ilib -MNet::Daemon -le "print $Net::Daemon::VERSION; $d = new Net::Daemon { mode => "threads", configfile => "foo" };" 0.48 C:\> C:\>del foo C:\>perl -Ilib -MNet::Daemon -le "print $Net::Daemon::VERSION; $d = new Net::Daemon { mode => "threads", configfile => "foo" };" 0.48 Can't locate object method "self" via package "Thread" at C:/Perl/site/lib/Net/Daemon/Log.pm line 82. I copied, pasted (um, and fixed the missing commas) the Config_File example from the Net-Daemon CPAN site, as pasted below. Note that this example will not actually work. It only shows that the error goes away if there is a valid config file. Notice that I changed the mode to threads in the config file. That will not matter since I did not intend to actually use the newly created daemon. ------- Paste # Load external modules; this is not required unless you use # the chroot() option. #require DBD::mysql; #require DBD::CSV; { # 'chroot' => '/var/dbiproxy', 'facility' => 'daemon', 'pidfile' => '/var/dbiproxy/dbiproxy.pid', 'user' => 'nobody', 'group' => 'nobody', 'localport' => '1003', 'mode' => 'threads', # Access control 'clients' => [ # Accept the local { 'mask' => '^192\.168\.1\.\d+$', 'accept' => 1 }, # Accept myhost.company.com { 'mask' => '^myhost\.company\.com$', 'accept' => 1 }, # Deny everything else { 'mask' => '.*', 'accept' => 0 } ] }
Subject: Re: [rt.cpan.org #67643] config file parsing errors may trigger incorrect threading
Date: Sat, 23 Apr 2011 11:31:34 -0400
To: Malcolm Nooning via RT <bug-Net-Daemon [...] rt.cpan.org>
From: Frédéric Brière <fbriere [...] fbriere.net>
Download (untitled) / with headers
text/plain 827b
On Fri, Apr 22, 2011 at 10:02:26AM -0400, Malcolm Nooning via RT wrote: Show quoted text
> I get the same error if foo does not exist. Does foo exist for you?
No, it does not. The idea was to trigger a parsing error. Show quoted text
> It only shows that the error goes away if there is a valid config file.
Yes, that is the point. If you look at the constructor, you'll see that it calls ReadConfigFile, and then performs some sanitation on the "mode" config value and loads the required modules accordingly. However, if ReadConfigFile() fails, it will call Fatal(), and thus Log(), which attempts to print some information about the current thread. This assumes that "mode" has been set and the appropriate modules loaded, which is not yet the case at that point. -- Eternal nothingness is fine if you happen to be dressed for it. -- Woody Allen
Subject: Re: [rt.cpan.org #67643] config file parsing errors may trigger incorrect threading
Date: Sat, 23 Apr 2011 12:33:11 -0400
To: bug-Net-Daemon [...] rt.cpan.org
From: Malcolm Nooning <m.nooning [...] comcast.net>
Download (untitled) / with headers
text/plain 1.6k
In site/lib/Net/daemon.pm, I will add the mode assignment shown, after the shown bless statement. bless($self, (ref($class) || $class)); $self->{'mode'} = 'single'; # Provide a default In the future, if someone forgets or misspells the config file name, a much more identifying error report will be printed. I now properly get the error report below. C:\>del foo C:\>perl -Ilib -MNet::Daemon -le "print $Net::Daemon::VERSION; $d = new Net::Daemon { mode => "threads", configfile => "foo" };" 0.48 No such config file: foo at C:/Perl/site/lib/Net/Daemon.pm line 201. at C:/Perl/site/lib/Net/Daemon/Log.pm line 136. I know how frustrating a misleading error report can be. When I get a little more time I will update the module, test it on my Linux and Windows machines, and then upload it. Thanks On 4/23/2011 11:31 AM, fbriere@fbriere.net via RT wrote: Show quoted text
> Queue: Net-Daemon > Ticket<URL: http://rt.cpan.org/Ticket/Display.html?id=67643> > > On Fri, Apr 22, 2011 at 10:02:26AM -0400, Malcolm Nooning via RT wrote:
>> I get the same error if foo does not exist. Does foo exist for you?
> No, it does not. The idea was to trigger a parsing error. >
>> It only shows that the error goes away if there is a valid config file.
> Yes, that is the point. > > If you look at the constructor, you'll see that it calls ReadConfigFile, > and then performs some sanitation on the "mode" config value and loads > the required modules accordingly. > > However, if ReadConfigFile() fails, it will call Fatal(), and thus > Log(), which attempts to print some information about the current > thread. This assumes that "mode" has been set and the appropriate > modules loaded, which is not yet the case at that point. > >


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.