#1024 [perl] SWIG_croak_null not mapped properly

perl (97)

For Perl version 10 (i.e. PERL_VERSION equal to 10) the compiler (g++) complains about
# define SWIG_croak_null() croak(Nullch)

To fix it, I modified /usr/share/swig1.3/perl5/perlrun.swg
and replaced the line with
# define SWIG_croak_null() croak("Croak at line %d\n", __LINE__)

This resolves the warning, and as far as I have tested resolves the issue.


  • Robert Stone

    Robert Stone - 2009-06-18

    I have been looking into the "null argument where non-null required" compiler warnings generated by calls to croak(NULL). As best I can tell, the warning is harmless. The croak implementation is documented in perlapi to expect a NULL when $@ already has the desired error value, and I've tested that at runtime it handles NULL as documented. I will try to find out more, but for the moment I believe perlrun.swg's use of croak() is correct.

  • Olly Betts

    Olly Betts - 2009-07-03

    The code SWIG generates is valid, for Perl >= 5.7.0 at least - support for croak(Nullch) was added in 5.7.0 it seems. 5.7 was a development series, so in terms of stable releases that means >= 5.8.0.

    The warning is bogus - Perl's header has a GCC __attribute__ saying that the format is printf-like, but I think a newer GCC version added a warning for a NULL format string passed to such a function, since printf doesn't allow that. So the bug here is really in Perl's header in the context of recent versions of GCC.

    I don't know what Perl versions SWIG really supports, though the manual says "For the best results, it is recommended that SWIG be used with Perl5.003 or later. Earlier versions are problematic and SWIG generated extensions may not compile or run correctly." so perhaps we need a fallback case here for older versions of Perl, or to update the manual. Perl 5.6.2 seems to be the last 5.6 release and was November 16 2003, while 5.8.0 was released July 18 2002. So with no releases in 5.5 years it seems 5.6 is probably unsupported upstream, but I don't know how many people are still actually using it - 5.005 seemed to have a very long life. Separate from this issue, we should decide what versions we can and want to support - it doesn't seem useful to continue to say ">= 5.003" if we haven't tested with a version that old for years.

  • Olly Betts

    Olly Betts - 2009-07-30
    • assigned_to: nobody --> olly
    • summary: SWIG_croak_null not mapped properly --> [perl] SWIG_croak_null not mapped properly
  • Olly Betts

    Olly Betts - 2009-07-30

    Assigning to myself to stop this getting forgotten - I need to talk to people to get a view on what minimum Perl version we want to support.

  • William Fulton

    William Fulton - 2011-05-21

    Which version of g++, which operating system what compiler flags are you using? I don't see this using perl 5.10.1 and g++ 4.4.3.

    I don't think we should stop supporting older versions of Perl that are already working because of a compiler warning. The code in perlrun.swg for SWIG_croak_null currently differentiates between version < 8 and later so I don't think we would break old versions anyway if this code was changed.

  • Olly Betts

    Olly Betts - 2011-05-21

    I'm not suggesting we drop support just because of a compiler warning - dropping support for older versions wouldn't actually fix this warning for newer ones anyway, so that would be a particularly stupid argument. I'm not really even proposing we drop support - rather that we more accurately document the minimum version we do actually support. The manual still states that 5.003 is the recommended minimum version, which is about 15 years old now, and I think it's unlikely this version has actually worked with any recent SWIG version.

    As a general policy, I'd suggest we shouldn't expend effort to support versions of a target language (or other software like tools and operating systems) which the upstream developers themselves have long ago stopped supporting, unless there are particular reasons to do otherwise. This warning issue just made me notice the age of the versions concerned, prompting me to raise the issue.

    As of May 14th 2011, the oldest supported version of Perl is 5.12:


    The detailed policy is here:


    So upstream support for 5.6.x would have ended with the release of 5.10, which was 2007-Dec-18:


    The 3 years from the .0 release for critical fixes ran out long before that, so the versions we're talking about have been completely unsupported upstream for about 3.5 years now.

    It has reached the point where to test with them we'd have to specially compile ancient versions of Perl just for that purpose (e.g. even Debian oldstable has Perl 5.10). Given the limited development resources we have, except in cases where we have somebody volunteering to regularly test with older versions and fix any issues which crop up, that doesn't make a lot of sense, especially if you multiply it by all the old versions of all the supported languages. If anybody really needs to support systems with such ancient versions of Perl then they can just continue to use older versions of SWIG.

    As for your actual question, I believe the warning flag is -Wformat. Looking at Perl 5.10.1's headers, it appears they've addressed this issue there by disabling the attribute which marks this as a format in this case. So this warning probably only happens with Perl 5.8.x (and perhaps 5.10.0 - I don't have that to hand to check).

  • Olly Betts

    Olly Betts - 2011-05-23

    I just tested current trunk with the final Perl 5.005 release, 5.005_5 (which I had to hack about to even build with GCC 4.3.2, which is pretty old itself now).

    The testsuite fails to pass because it uses 'use warnings;', which is new in Perl 5.6. These appear to have been added in r10403 by talby on 2008-04-30, it seems nobody has tested with Perl < 5.6 for at least 3 years.

    Stripping out 'use warnings;' for Examples/perl5/*.pl, it looks like pretty much everything still fails, so it's not a simple matter of changing these to -w on the #! line.

    Clearly nobody is actually testing modern SWIG releases with these ancient Perl versions, and they don't happen to work by lucky accident, so I think we should update the documentation to state a minimum requirement of Perl 5.6 (on the perhaps slightly optimistic assumption that 5.6 actually works...)

  • Olly Betts

    Olly Betts - 2011-05-23

    Sorry, make that Perl 5.005_04 which i tested with.

  • Olly Betts

    Olly Betts - 2011-05-23

    OK, with Perl 5.6.2, 6 tests in the testsuite fail, so that's rather closer to working, and could probably sanely be fixed up if anybody wanted to put the effort in.

    However, it's worth noting that Perl 5.6.2 also failed to build without hacking the build system and source, and I was using debian oldstable, which is getting on a bit itself now.

  • Olly Betts

    Olly Betts - 2011-06-18

    In the interests of not misleading our users, I've updated the Perl chapter to say:

    For the best results, it is recommended that SWIG be used with Perl 5.8 or
    later. We're no longer testing regularly with older versions, but
    Perl 5.6 seems to mostly work, while older versions don't.

    Personally I feel we should go a little further, but William seems to disagree, so I've stuck to documenting reality.

    As for the actual issue in this ticket, it's been fixed in Perl 5.10.1, and I don't see a plausible way for us to work around it for older versions, so I think it's probably time to close this ticket. "Won't Fix" isn't entirely accurate, but it seems the best of the available resolutions.

  • Olly Betts

    Olly Betts - 2011-06-18
    • status: open --> closed-wont-fix

Log in to post a comment.