tag 846731 patch
thanks

On Sun, Dec 04, 2016 at 05:52:10PM +0200, Niko Tyni wrote:
> On Sat, Dec 03, 2016 at 04:40:53PM +0100, gregor herrmann wrote:
> > On Wed, 26 Oct 2016 13:26:42 +0100, Iain Lane wrote:
> > 
> > > On Thu, Jan 15, 2015 at 05:17:10PM +0000, James Cowgill wrote:
> > 
> > > > libbio-scp-perl FTBFS on mips64el, ppc64el, and s390x with similar
> > > > testsuite failures:
> > 
> > > > Although I haven't investigated this, the build produces many pointer
> > > > casting warnings which seem likely to have caused these errors:
> > > > 
> > > > SCF.xs: In function 'XS_Bio__SCF_get_scf_pointer':
> > > > SCF.xs:57:20: warning: cast from pointer to integer of different size 
> > > > [-Wpointer-to-int-cast]
> > > >   ret_val = newSViv((int)scf_data);

> GCC started to default to PIE between the latest perl upload and the
> one before that. I think that made it use different memory locations,
> so the cast to int now overflows.

The attached patch fixes this for me on sid/amd64.

Eyeballs and/or testing would be welcome. Tagging just #846731 for now,
but I expect the bugs are about the same issue and should probably
be merged.
-- 
Niko Tyni   nt...@debian.org
>From 5e57fc339478e5204d0465b63ff5a5e927a565ad Mon Sep 17 00:00:00 2001
From: Niko Tyni <nt...@debian.org>
Date: Wed, 7 Dec 2016 00:02:25 +0200
Subject: [PATCH] Fix overflowing casts from pointer to integer

This fixes test failures on 64-bit platforms using memory addresses over
2**32, like those where Perl is built as PIE (position independent
executable).

Bug-Debian: https://bugs.debian.org/846731
---
 SCF.xs | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/SCF.xs b/SCF.xs
index a55879b..10a88bd 100644
--- a/SCF.xs
+++ b/SCF.xs
@@ -54,7 +54,7 @@ char *file_name
 	/* Reading SCF file, into internal structure */
 	if ( (scf_data = read_scf(file_name)) == NULL )
 		croak("get_scf_pointer(...) : failed on read_scf(%s)\n", file_name);
-	ret_val = newSViv((int)scf_data);
+	ret_val = newSViv(PTR2IV(scf_data));
 	RETVAL = ret_val;
 	OUTPUT:
 	RETVAL
@@ -77,20 +77,20 @@ FILE *file_handle
 	        croak("get_scf_fpointer(...) : failed on mfreopen(...)\n");
 	if ( (scf_data = mfread_scf(mf)) == NULL )
 		croak("get_scf_fpointer(...) : failed on fread_scf(...)\n");
-	ret_val = newSViv((int)scf_data);
+	ret_val = newSViv(PTR2IV(scf_data));
 	RETVAL = ret_val;
 	OUTPUT:
 	RETVAL
 
 void
 scf_free(scf_pointer)
-int scf_pointer
+long scf_pointer
 CODE:
 	scf_deallocate((Scf *)scf_pointer);
 
 SV *
 get_comments(scf_pointer)
-int scf_pointer
+long scf_pointer
 	CODE:
 	Scf *scf_data = (Scf *)scf_pointer;
 	SV *ret_val;
@@ -102,7 +102,7 @@ int scf_pointer
 
 void
 set_comments(scf_pointer, comments)
-int scf_pointer
+long scf_pointer
 char *comments
 	CODE:
 	Scf *scf_data = (Scf *)scf_pointer;
@@ -115,7 +115,7 @@ char *comments
 
 SV * 
 scf_write(scf_pointer, file_name)
-int scf_pointer
+long scf_pointer
 char *file_name
 	CODE:
 	Scf *scf_data = (Scf *)scf_pointer;
@@ -129,7 +129,7 @@ char *file_name
 	
 SV * 
 scf_fwrite(scf_pointer, file_handle)
-int scf_pointer
+long scf_pointer
 FILE *file_handle
 	CODE:
         mFILE *mf;
@@ -152,7 +152,7 @@ FILE *file_handle
 
 SV *
 get_from_header(scf_pointer, what)
-int scf_pointer
+long scf_pointer
 int what
 	CODE:
 	/* what = { 0 samples, 1 bases, 2 version, 3 sample size, 4 code_set } */
@@ -176,7 +176,7 @@ int what
 
 SV *
 get_at(scf_pointer, index, what)
-int scf_pointer
+long scf_pointer
 int index
 int what
 	CODE:
@@ -234,7 +234,7 @@ int what
 
 void 
 set_base_at(scf_pointer, index, what, value)
-int scf_pointer
+long scf_pointer
 int index
 int what
 char value
@@ -247,7 +247,7 @@ char value
 
 void
 set_at(scf_pointer, index, what, value)
-int scf_pointer
+long scf_pointer
 int index
 int what
 unsigned int value
-- 
2.10.2

Reply via email to