FORTRAN: double free or corruption


 
Thread Tools Search this Thread
Top Forums Programming FORTRAN: double free or corruption
# 1  
Old 05-14-2013
FORTRAN: double free or corruption

Hello.
I'm looking for a quite "interesting" bug I'm using fortran 90, compiler gfortran and the main idea is for every time step I build a bin structure for search contact between particles, for this at the begining
Code:
TYPE :: circle_index
			INTEGER(kind = 4) :: ind_p
			TYPE(circle_index), POINTER :: p
END TYPE
		
TYPE(circle_index), DIMENSION(:), POINTER :: Bins(:)
TYPE(circle_index), DIMENSION(:), POINTER :: Bins_Tail(:)
TYPE(circle_index),POINTER :: headB

And the next part it's called almost every time step.
I compute rows and colums variables for allocate memory

Code:
ALLOCATE(Bins(rows*columns),Bins_Tail(rows*columns))

Then I do the search for finally
Code:
DO pos = 1, rows*columns
	headB => Bins(pos)%p
	DO
		IF(.NOT. ASSOCIATED(headB)) EXIT
		ptr_index => headB%p
		DEALLOCATE(headB)
		headB => ptr_index
	END DO
END DO
DEALLOCATE(Bins, Bins_Tail)

The search is ok, but I get some of these errors
*** glibc detected *** double free or corruption (out)
*** glibc detected *** free(): invalid next size (normal)

And it's wierd for me because if I'm deallocating in the wrong way I expect the error at the beginig but it does not. The error just appear more after, am I doing it wrong?
I already use -fbounds-check but does not work and is really dificult debug step by step because the simulation is very long, so any ideas?

Does anybody have an idea what is happening here? Have you seen something similar yet? What could i still try?

Greetings & thank you,
Marce.
# 2  
Old 05-14-2013
Not deeply understanding this, but DEALLOCATE( headB ) has no corresponding ALLOCATE() . . . . You put Bins in headB, so are you double DEALLOCATING it? Maybe you need a soft delete flag in your row or make a new array with the deletes not added, or allocate and deallocate row by row.
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Programming

C++ glibc detected double free or corruption(!prev) using shared library

Currently I test a shared library vendor provided in linux , the following is the simple source : #include <iostream> using namespace std; extern int test1(); extern int test2(); int main() { cout << "hello world" << endl ; return 0 ; cout << "Test 1" << endl; ... (6 Replies)
Discussion started by: barfatchen
6 Replies

2. UNIX for Advanced & Expert Users

File System corruption

Hi, While a tar file was created, the file system got full and there was no message on the tar failure. Then the system was shut down and the administrator says because the file system was full the shut down procedure corrupted the file system. I'm wondering, unix should have given some... (2 Replies)
Discussion started by: manivanm
2 Replies

3. Solaris

MountPoint / is 8% with 899.49MB free crossing threshold of 10% free

Hi, I have a problem one of the server file system cross the limitation MountPoint / is 8% with 899.49MB free crossing threshold of 10% free out put please help how to resolve this dev/vx/dsk/bootdg/rootvol 9.8G 8.8G 956M 91% / /devices ... (3 Replies)
Discussion started by: sriniva0
3 Replies

4. Solaris

Data corruption

I have a solaris 5.6 on which oracle is installed. we have an alert file alert_net1.log now whenever any datacorruption happens we get the file id and block id in the above file. through this file and block id , we try to find out which table is corrupted and then try to... (1 Reply)
Discussion started by: asalman.qazi
1 Replies

5. Programming

Pointer to a struct (with pointers) *** glibc detected *** double free

I am using a structure defined as follows struct gene_square { double *x; double *y; };I have class, with a member function which is a pointer of this type: gene_square* m_Genes;I am allocating memory in the constructors like this: m_Genes = new gene_square; for (ii=0;... (1 Reply)
Discussion started by: jatoo
1 Replies

6. Programming

*** glibc detected *** double free or corruption: 0x40236ff4 ***

when i try to use the class i wrote, i either get this: *** glibc detected *** double free or corruption: 0x40236ff4 *** and the proccess exits with an error code of 0; or it segfaults. could someone look at my header file (with imp.) to give me some insight as to why its not working? ... (19 Replies)
Discussion started by: norsk hedensk
19 Replies

7. UNIX for Advanced & Expert Users

file corruption

Hi, All of a sudden I landed in a strange problem. I was working with my C source code in vi editor. I did a wq! and when reopened, the file is full of "data".. I mean the text contents are gone!!. I believe this is a file corruption. I have tried the -r option with vi, but no success. ... (5 Replies)
Discussion started by: shibz
5 Replies
Login or Register to Ask a Question