Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to investigate "Attempt to reload Readonly/XS.pm aborted"

10 views
Skip to first unread message

Normand

unread,
Apr 29, 2014, 12:56:02 PM4/29/14
to per...@perl.org
Hi there,
I have an error as detailed in the attached tst1.t perl script where the "use Readonly::XS;" line is failing.I tried to use perl -d debug mode but not working as use line is part of the compile section.
I do not know how to investigate such a problem, so I would appreciate any suggestion.

# ===============================================
# $perl tst1.t
# Attempt to reload Readonly/XS.pm aborted.
# Compilation failed in require at tst1.t line 26.
# BEGIN failed--compilation aborted at tst1.t line 26.
# ===============================================

--
Michel Normand
tst1.txt

Reini Urban

unread,
Apr 30, 2014, 1:23:20 PM4/30/14
to Normand, per...@perl.org
This has nothing to do with perl-xs, you'd need to read the module
documentation first.
perldoc Readonly
perldoc Readonly::XS

perl -MReadonly::XS -e0
Readonly::XS is not a standalone module. You should not use it
directly. at Readonly/XS.pm line 34.

Matthew Horsfall (alh)

unread,
May 2, 2014, 8:54:26 AM5/2/14
to Normand, per...@perl.org
On Tue, Apr 29, 2014 at 12:56 PM, Normand <nor...@linux.vnet.ibm.com> wrote:
> Hi there,
> I have an error as detailed in the attached tst1.t perl script where the
> "use Readonly::XS;" line is failing.I tried to use perl -d debug mode but
> not working as use line is part of the compile section.
> I do not know how to investigate such a problem, so I would appreciate any
> suggestion.

Normand,

One trick you can use here is to eval the "use Readonly; use
Readonly::XS" so that it happens at runtime rather than compile time.
Alternatively, you can use "require", so it now looks like this:

#!/usr/bin/perl

use strict;
use warnings;

require Readonly;
require Readonly::XS;

And if we run it with Devel::Trace, we now get some useful output
which pinpoints the real error:

$ perl -d:Trace tst1.txt
[ LOTS OF OUTPUT ]
...
>> /usr/local/lib/perl/5.14.2/Readonly/XS.pm:29: if
($MAGIC_COOKIE ne "Do NOT use or require Readonly::XS unless you're
me.")
>> /usr/local/lib/perl/5.14.2/Readonly/XS.pm:31: require Carp;
>> /usr/local/lib/perl/5.14.2/Readonly/XS.pm:32:
Carp::croak("Readonly::XS is not a standalone module. You should not
use it directly.");
---
[ LOTS MORE OUTPUT ]

So Readonly.pm is doing "eval 'use Readonly::XS';", which croaks, and
leaves things in a weird state so when tst1.txt comes along and says
"use Readonly::XS", you get the unhelpful error message. (Perhaps a
bug in Perl, I think I'll bring this up with Perl5 Porters).

Hope that helps.

-- Matthew Horsfall (alh)
0 new messages