Skip Menu |

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

Report information
The Basics
Id: 81640
Status: resolved
Priority: 0/
Queue: Net-Daemon

People
Owner: Nobody in particular
Requestors: bozziebear [...] hotmail.com
Cc:
AdminCc:

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



Subject: Net::Daemon fails if 'use threads::shared' precedes use Net::Daemon
Net::Daemon seems to fail if threads::shared has been loaded prior to the "use Net::Daemon;" call. The attached file is your Net::Daemon/t/base.t test case plus: use threads; use threads::shared; Here's what happens on my system: ---------- perl NetDaemon-base.pl 1..1 Type of arg 1 to threads::shared::share must be one of [$@%] (not single ref constructor) at /usr/lib/perl5/vendor_perl/5.16.0/Net/Daemon.pm line 54, near "$Net::Daemon::RegExpLock) " BEGIN not safe after errors--compilation aborted at /usr/lib/perl5/vendor_perl/5.16.0/Net/Daemon.pm line 56. Compilation failed in require at NetDaemon-base.pl line 9. BEGIN failed--compilation aborted at NetDaemon-base.pl line 9. not ok 1 % uname -a Linux sr1650nx 3.4.11-2.16-desktop #1 SMP PREEMPT Wed Sep 26 17:05:00 UTC 2012 (259fc87) x86_64 x86_64 x86_64 GNU/Linux %pmvers Net::Daemon threads threads::shared Net::Daemon: 0.48 threads: 1.86 threads::shared: 1.4 % perl -v This is perl 5, version 16, subversion 0 (v5.16.0) built for x86_64-linux-thread-multi ---------- To get both original and modified base.t and my own application working in my particular Perl environment, I made the following edits to Daemon.pm: 41,44c41,42 < if ($this_is_510) { < eval { require threads; }; < eval { require threads::shared; }; < } --- Show quoted text
> use threads; > use threads::shared;
54c52 < threads::shared::share(\$Net::Daemon::RegExpLock) if $this_is_510; --- Show quoted text
> threads::shared::share($Net::Daemon::RegExpLock) if $this_is_510;
The threads::shared::share() call now matches its documentation, so that change seems right, but I don't understand the subtleties of the "this_is_510" test and its dummy share. Thanks for looking at this.
Subject: NetDaemon-base.pl
# $Id: base.t,v 1.2 1999/08/12 14:28:59 joe Exp $ # use threads; #use threads::shared; BEGIN { $| = 1; print "1..1\n"; } END {print "not ok 1\n" unless $loaded;} use Net::Daemon; $loaded = 1; print "ok 1\n";
From: bozziebear [...] hotmail.com
Corrected attachment. Sorry - I uploaded the test case with the key line commented out.
Subject: NetDaemon-base.pl
# $Id: base.t,v 1.2 1999/08/12 14:28:59 joe Exp $ # use threads; use threads::shared; BEGIN { $| = 1; print "1..1\n"; } END {print "not ok 1\n" unless $loaded;} use Net::Daemon; $loaded = 1; print "ok 1\n";
Subject: Re: [rt.cpan.org #81640] Net::Daemon fails if 'use threads::shared' precedes use Net::Daemon
Date: Mon, 03 Dec 2012 14:08:30 -0500
To: bug-Net-Daemon [...] rt.cpan.org
From: Malcolm Nooning <m.nooning [...] comcast.net>
Your change works on my Windows XP, Perl 5.16, too. I am going to test it on a Windows machine with an earlier Perl, and an Linux machine with an earlier Perl. If everything works I will incorporate the change. If not, but it works for 5.14, I will specify that 5.14 and above be used. 5.14 had some nice changes. Show quoted text
>but I don't understand the subtleties of the "this_is_510" test and
its dummy share. I do not, either. It was another contributor who came up with that. It caused Net::Daemon to work for everything at the time so I was quite happy with it. The original author Jochen Wiedmann passed his modules to me in 2007 and I have been maintaining them since. I have been successful mainly through the contributions of others, such as the one you just gave me. Thank you very, very much. It might be a week or so before I am finished. On 12/2/2012 6:03 AM, Tom via RT wrote:
Subject: Re: [rt.cpan.org #81640] Net::Daemon fails if 'use threads::shared' precedes use Net::Daemon
Date: Wed, 05 Dec 2012 11:51:15 -0500
To: bug-Net-Daemon [...] rt.cpan.org
From: Malcolm Nooning <m.nooning [...] comcast.net>
I cannot get this to work on Perl 5.14.2. I wonder what happened with 5.14.2? It works on my Perl 5.16!. They are both Windows XP machines. It is freeing memory to the wrong pool, so there is a threads problem. Both machines have their respective Perls compiled for threads. Hmmm. I am thinking of putting in your changes anyway. Perhaps this weekend.
Subject: RE: [rt.cpan.org #81640] Net::Daemon fails if 'use threads::shared' precedes use Net::Daemon
Date: Wed, 5 Dec 2012 14:53:41 -0800
To: <bug-Net-Daemon [...] rt.cpan.org>
From: Bozzie Bear <bozziebear [...] hotmail.com>
I will go back through my test cases when I started investigating this. At the time, I just assumed it was a bug in my code, so I may have overlooked some clue that will help us understand what is going on here. Also, I can reboot into an older distro that has perl 5.12 and see what results I get there. Show quoted text
-----Original Message----- From: Malcolm Nooning via RT [mailto:bug-Net-Daemon@rt.cpan.org] Sent: Wednesday, December 05, 2012 8:51 AM To: bozziebear@hotmail.com Subject: Re: [rt.cpan.org #81640] Net::Daemon fails if 'use threads::shared' precedes use Net::Daemon <URL: https://rt.cpan.org/Ticket/Display.html?id=81640 > I cannot get this to work on Perl 5.14.2. I wonder what happened with 5.14.2? It works on my Perl 5.16!. They are both Windows XP machines. It is freeing memory to the wrong pool, so there is a threads problem. Both machines have their respective Perls compiled for threads. Hmmm. I am thinking of putting in your changes anyway. Perhaps this weekend.
Subject: Re: [rt.cpan.org #81640] Net::Daemon fails if 'use threads::shared' precedes use Net::Daemon
Date: Thu, 06 Dec 2012 12:13:25 -0500
To: bug-Net-Daemon [...] rt.cpan.org
From: Malcolm Nooning <m.nooning [...] comcast.net>
That would be really great, Tom. On 12/5/2012 5:54 PM, Tom via RT wrote: Show quoted text
> time, I just assumed it was a bug in my c
Subject: RE: [rt.cpan.org #81640] Net::Daemon fails if 'use threads::shared' precedes use Net::Daemon
Date: Mon, 10 Dec 2012 16:25:53 -0800
To: <bug-Net-Daemon [...] rt.cpan.org>
From: Bozzie Bear <bozziebear [...] hotmail.com>
Hi Malcolm, This code passes base.t with and w/o the extra "use" statements and still uses conditional loading: package Net::Daemon; use Module::Load::Conditional qw(can_load); @Net::Daemon::ISA = qw(Net::Daemon::Log); $Net::Daemon::VERSION = '0.48'; $Net::Daemon::RegExpLock = 1; # Dummy share() in case we're >= 5.10. If we are, require/import of # threads::shared will replace it appropriately. if ($^V ge v5.10.0) { can_load(modules => {"threads::shared" => undef}) or die "Failed to load module 'threads::shared'"; # Regexps aren't thread safe, as of 5.00502? # (See the test script regexp-threads.): threads::shared::share($Net::Daemon::RegExpLock); } use vars qw($exit); etc ... Besides re-ordering the code for better readability, the only functional change I made is replacing the 2 "evals" with the Module::Load::Conditional::can_load() call. Thus I hope it will behave as before on pre-5.10 versions of Perl, but since you saw it fail on 5.14, I'm not making any predictions! I think all of Net::Daemon's other dependencies are part of the Perl core whereas Module::Load::Conditional is not, so that may be an objection. The can_load() method has existed since the earliest CPAN version of M::L::C (0.02 from 2003), making it more likely that pre-5.10 Perl/Net::Daemon installations can find a compatible version if they can't use the current release. Regards, Tom
Ticket migrated to github as https://github.com/toddr/Net-Daemon/issues/18