gcc/perl/XS

Patrick Dupre pd520 at york.ac.uk
Sun Aug 2 01:41:32 UTC 2009


Hello,

In a c subroutine I have the following code:
for (i = 0 ; i < 5 ; i++) {
   floatMatrix new_lines = (floatMatrix) realloc (lines, (nb_lines) * sizeof (lineArray)) ;
   lines=new_lines ;
   nb_lines++ ;
   }

which is called from a perl call through an XS interface.

It work fine with gcc.4.3.2 (32 but arch) machine.
With gcc 4.4.0 on a x86_64 arch it fails (segmentation fault) at the 
second reallocation for nb_lines high (10000). 
However,
it is OK if nb_lines = 1000, and it is also OK if the same shared
library is linked to a c program calling the same subroutine

I also noticed that the values of the pointer is identical after and
before the realloc call (if not NULLÂ).


-- 
---
==========================================================================
  Patrick DUPRÉ                      |   |
  Department of Chemistry            |   |    Phone: (44)-(0)-1904-434384
  The University of York             |   |    Fax:   (44)-(0)-1904-432516
  Heslington                         |   |
  York YO10 5DD  United Kingdom      |   |    email: pd520 at york.ac.uk
==========================================================================


More information about the fedora-list mailing list