gremio has asked for the wisdom of the Perl Monks concerning the following question:

Humble Greetings, dear Monks,

I've gotten XML-Writer.pm to test correctly under perl 5.6!

Also, I have *some* idea where the problem lies, but I'd really like a decent explanation as to what's actually going on behind the scenes.

The original problem follows, then the solution:

> I've just upgraded to RH7.1, well behind the boat, including a perl version jump from 5.005-03 to 5.6.0 and noticed that my XML::Writer module was no
> longer happy about its make-time tests.
>
> Not just mine, but the latest from cpan, or for example the credible
> http://www.rpmfind.net/linux/RPM/PLD//PLD-1.0/SRPMS/SRPMS//perl-XML-Writer-0.4-3.src.html
>
> On make test, I get
PERL_DL_NONLAZY=1 /usr/bin/perl -Iblib/arch -Iblib/lib -I/usr/lib/perl +5/5.6.0/i386-linux -I/usr/lib/perl5/5.6.0 test.pl 1..43 ok 1 ... ok 39 Attempt to free unreferenced scalar at test.pl line 513. make: *** [test_dynamic] Segmentation fault (core dumped) Exit 2

>
> The compile and test are perfectly happy on a machine that still has 5.005-03.
>
> Now I'm pretty familiar with the module itself, have made some code changes and such (this is a virgin test tho), and dug around in it a bit, but I'm not exactly
> sure what kind of objectionable material to be looking for w.r.t. this error.
>
> I'm not averse to putting some time into this, but I'm not clear where to start. Any pointers (at least those with a positive ref count when trying to get freed :-)
> would be greatly appreciated.

While diligently commenting out possible sections of code to try and sniff out what the problem was, I noticed the following error during test:
ok 35 ok 36 ok 37 Expected error did not occur! not ok 38 ok 39 Expected error did not occur! not ok 40 ok 41 Not an ARRAY reference at blib/lib/XML/Writer.pm line 905. not ok 42 make: *** [test_dynamic] Segmentation fault (core dumped) Exit 2
So it wasn't the same test as the error, but it got me thinking... Line 905 says:
899: # 900: # Check names. 901: # 902: sub _checkNSNames { 903: my $names = $_[0]; 904: my $i = 1; 905: my $name = $names->[0];
Now there are a lot of things that are supposed to be arrayrefs, but the thing getting passed in was
801: _checkNSNames(\@_); and 813: _checkNSNames(\@_);
So on a whim I tried changing these to
_checkNSNames([ @_ ]);
to induce an explicit copy instead of passing on the arguments ref. I was going to maybe examine the contents during test here next. Baby steps.

Well what do you know, I just didn't get any errors anymore! Nor when I put everything else back. So It seems the segmentation fault happened because the reference to the subroutine args wasn't handled right?

Any ideas or insight?

BTW, I *will* actually go let the author know now...

Thanks,
Gremio

Replies are listed 'Best First'.
Re: SOLVED: XML-Writer not 5.6 compatible -- but why?
by runrig (Abbot) on Jul 21, 2001 at 01:36 UTC
    Upgrade to perl 5.6.1. XML::Writer passes 'make test' fine for me. BTW, if you look at all the results of CPAN testing here you'll see that it does fail testing, but all the perl versions are 5.6.0. Maybe it should be retested with 5.6.1. 5.6.0 is not a good version to be on anyway.

    Just for kicks you could see if it works on 5.7.2...

    Update:Found this in the Changes file for 5.6.1:

    # Hmm, this is from before 5.6.0 maybe it got fixed # and broke again and was fixed again [ 4195] By: gsar on 1999/09/19 21:30:18 Log: avoid clearing @_ at all for faster subroutine calls; fix bugs in passing around references to @_, eg C<sub foo { \@_ }>; add tests for the same Branch: perl