Bug#579450: libdevice-cdio-perl: FTBFS with perl 5.12.0-1: 64-bit integers

Chris Butler chrisb at debian.org
Sun May 1 19:10:32 UTC 2011


On Wed, Apr 20, 2011 at 10:37:40PM +0100, Dominic Hargreaves wrote:
> On Tue, Apr 27, 2010 at 09:53:47PM +0300, Niko Tyni wrote:
> > This package fails to build on i386 with perl 5.12.0-1 from experimental:
> > 
> >   t/05.ops.t ........... 1/6 OverflowError in method 'get_devices_with_cap', argument 1 of type 'unsigned int'
> >   # Looks like you planned 6 tests but ran 1.
> >   # Looks like your test exited with 2 just after 1.
> >   t/05.ops.t ........... Dubious, test returned 2 (wstat 512, 0x200)
> >   Failed 5/6 subtests 
> >  
> > This very probably happens because 5.12.0-1 is configured with -Duse64bitint.

Having a quick look at this, I don't think this problem is specific to
libdevice-cdio-perl, I think it may be an issue with SWIG. From the looks of
it, SWIG doesn't handle -Duse64bitint correctly when presented with
integer arguments > 2^31. The value from perl is a 64-bit IV; this confuses
SWIG's argument handling code, which seems to be expecting that
sizeof(perl IV) == sizeof(C int).

Basically, the SWIG wrapper code that errors is:

ecode1 = SWIG_AsVal_unsigned_SS_int SWIG_PERL_CALL_ARGS_2(ST(0), &val1);
if (!SWIG_IsOK(ecode1)) {
    SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "get_devices_with_cap" "', argument " "1"" of type '" "unsigned int""'");
} 

The test that fails is passing in CDIO_FS_MATCH_ALL, which is 0xfffffff0.

SWIG_AsVal_unsigned_SS_int calls SWIG_AsVal_unsigned_SS_long, which contains
this code:

if (SvUOK(obj)) {
    if (val) *val = SvUV(obj);
    return SWIG_OK;
} else  if (SvIOK(obj)) {
    long v = SvIV(obj);
    if (v >= 0) {
        if (val) *val = v;
        return SWIG_OK;
    } else {
        return SWIG_OverflowError;
    }
}

Running this in gdb, I can see that SvUOK returns false (as obj is an IV),
and SvIOK returns true. SvIV correctly returns 0xffffffff0, which is -16
when put into a signed variable. This obviously makes the (v >= 0) test
fail, causing the OverflowError.

Anyway, I'd say this is a SWIG bug and not a bug in libdevice-cdio-perl.
FWIW, I tested it with the version of swig2.0 in unstable and it has the
same problem. Think this upstream SWIG bug is relevant:

http://sourceforge.net/tracker/?func=detail&aid=1481958&group_id=1645&atid=101645

No activity in 4 years though :(

-- 
Chris Butler <chrisb at debian.org>
  GnuPG Key ID: 4096R/49E3ACD3





More information about the pkg-perl-maintainers mailing list