Re: gcc/perl/XS

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Patrick Dupre writes:

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

Insufficient information. The definition of the floatMatrix type is missing. The original allocation of 'lines' is missing.

Generally, run your code through valgrind. An earlier memory corruption, that only manifests itself at this point, is also a possibility. valgrind should help in catching memory corruption earlier.

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

Correct. This is possible, if there is an unallocated memory block that immediately follows the one being resized, in which case the C library can merely adjust its internal data structures to reflect the updated memory map.


Attachment: pgpvYPXbP1jQ2.pgp
Description: PGP signature

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux