Seems I can not attach files to the bug tracker, so I am adding it here. The attached patch was originally authored by Chris Butler to solve the Debian bug at http://bugs.debian.org/579450
I added a unit test to cover the change and checked that the test suite for perl5 still passes on i386 and amd64.
I will include this patch in the next Debian upload and hope that it can be merged upstream as well.
Is there anything I can do to support acceptance of this patch?
I'm not sure whether there's an active perl maintainer for SWIG right now; that may explain the delay. I'll reiterate my previous comment here:
- Should remove the redundant 'v >= 0' check when v is of type UV.
For what it's worth, I would approve the patch.
Stefan
There are definitely problems in this area of the code (even in a 32 bit build), however the proposed patch does not address all of them. I am working on expanding the li_typemaps testcase to capture all the issues, and should have a comprehensive fix ready soon.
talby, does your commit fixing 1481958 also fix this one / replace this patch? Or torsten can you confirm 1481958 makes this patch redundant?
Yes, in my test environment, the fix for 1481958 also caused the testcase in this patch to succeed. I used this patch as a starting point, but found a family of related problems. I did not include the new testcase, but rolled it's functionality into the li_typemaps_runtime.pl test.
The patch by talby looks like it fixes some other problems as well. I did not really try to understand all the changes in there though.
What I am wondering is if those checks via SvUOK are really needed as I would the relevant cases to be catched by SvIOK already?!
I found that SvIOK() can return true for SVs that are UVs larger than IV_MAX, so the SvUOK() tests had to come earlier. Surprisingly, "if (SvIOK(x)) { IV v = SvIV(x); ... }" can overflow.