Skip Menu |

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

Report information
The Basics
Id: 127115
Status: resolved
Priority: 0/
Queue: Socket-MsgHdr

People
Owner: mjp [...] cpan.org
Requestors: felipe [...] felipegasper.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in:
  • 0.01
  • 0.02
  • 0.03
  • 0.04
  • 0.04_01
  • 0.04_02
Fixed in: (no value)



Subject: Socket::MsgHdr breaks when loaded dynamically
Date: Sat, 15 Sep 2018 16:41:46 -0400
To: bug-Socket-MsgHdr [...] rt.cpan.org
From: Felipe Gasper <felipe [...] felipegasper.com>
Hello, The latest Socket::MsgHdr fails to run for me when loaded dynamically: perl -MModule::Load -e'require Socket::MsgHdr; my $m = Socket::MsgHdr->new( buf => "\0" );' Can't locate object method "buf" via package "Socket::MsgHdr" at /usr/local/lib/x86_64-linux-gnu/perl/5.26.1/Socket/MsgHdr.pm line 87. These are the contents of %Socket::MsgHdr:: when loaded dynamically: $VAR1 = { 'flags' => *Socket::MsgHdr::flags, 'bootstrap' => *Socket::MsgHdr::bootstrap, 'unpack_cmsghdr' => *Socket::MsgHdr::unpack_cmsghdr, '__ANON__' => *Socket::MsgHdr::__ANON__, 'VERSION' => *Socket::MsgHdr::VERSION, 'EXPORT_OK' => *Socket::MsgHdr::EXPORT_OK, 'INIT' => *Socket::MsgHdr::INIT, 'recvmsg' => *Socket::MsgHdr::recvmsg, 'pack_cmsghdr' => *Socket::MsgHdr::pack_cmsghdr, 'BEGIN' => *Socket::MsgHdr::BEGIN, 'EXPORT' => *Socket::MsgHdr::EXPORT, 'cmsghdr' => *Socket::MsgHdr::cmsghdr, 'import' => *Socket::MsgHdr::import, 'new' => *Socket::MsgHdr::new, 'sendmsg' => *Socket::MsgHdr::sendmsg }; … and here is what it looks like when loaded at compile time: $VAR1 = { 'buf' => *Socket::MsgHdr::buf, 'bootstrap' => *Socket::MsgHdr::bootstrap, '__ANON__' => *Socket::MsgHdr::__ANON__, 'buflen' => *Socket::MsgHdr::buflen, 'cmsghdr' => *Socket::MsgHdr::cmsghdr, 'unpack_cmsghdr' => *Socket::MsgHdr::unpack_cmsghdr, 'controllen' => *Socket::MsgHdr::controllen, 'INIT' => *Socket::MsgHdr::INIT, 'flags' => *Socket::MsgHdr::flags, 'name' => *Socket::MsgHdr::name, 'VERSION' => *Socket::MsgHdr::VERSION, 'new' => *Socket::MsgHdr::new, 'EXPORT' => *Socket::MsgHdr::EXPORT, 'EXPORT_OK' => *Socket::MsgHdr::EXPORT_OK, 'import' => *Socket::MsgHdr::import, 'recvmsg' => *Socket::MsgHdr::recvmsg, 'pack_cmsghdr' => *Socket::MsgHdr::pack_cmsghdr, 'BEGIN' => *Socket::MsgHdr::BEGIN, 'namelen' => *Socket::MsgHdr::namelen, 'control' => *Socket::MsgHdr::control, 'sendmsg' => *Socket::MsgHdr::sendmsg };
What appears to be happening is that the INIT blocks aren’t being run on runtime load. Would it work just as well for those blocks to be BEGIN instead? That would appear to fix this problem.
On Thu Sep 27 00:34:11 2018, felipe@felipegasper.com wrote: Show quoted text
> What appears to be happening is that the INIT blocks aren’t being run > on runtime load.
That's correct. According to ... INIT blocks aren't run when included by "require": Show quoted text
> INIT blocks are run just before the Perl runtime begins execution, in "first in, first out" (FIFO) order.
further being detailed by Show quoted text
> The CHECK and INIT blocks in code compiled by require, string do, or string eval will not be executed if they occur after the end of the main compilation phase;
Sorry, the dots are meant to contain this reference: http://perldoc.perl.org/perlmod.html#BEGIN%2c-UNITCHECK%2c-CHECK%2c-INIT-and-END
Acknowledged.
Fixed in 0.05