fortran: segmentation fault when deallocating


 
Thread Tools Search this Thread
Top Forums Programming fortran: segmentation fault when deallocating
# 1  
Old 06-23-2010
Data fortran: segmentation fault when deallocating

Hi,
I'm looking for a quite "interesting" bug at the moment - any idea could help! (o;
Language is fortran 90, compiler gfortran (sry, dont find which version it is). As I suppose you dont want to read like 10k lines of code here, I won't post the entire thing ^^
The problem is that I get segmentation faults when deallocating four of my arrays while running the program. The output is depending on which of the arrays i deallocate first.. I always get one of those:

*** glibc detected *** double free or corruption (out)
*** glibc detected *** free(): invalid next size (normal)
*** glibc detected *** double free or corruption (!prev)
segmentation fault

This happens only when a variable - which has NOTHING to do with the arrays i'm trying to deallocate - has a certain value.
My problem is that the cause isn't one of the normal stuff - the arrays are totally well defined, i'm not trying to write values outside the boundaries, ect.
Also, I can deallocate the arrays directly after changing them the last time.

I do suppose that at some other point of the program something is going terribly wrong and sort of overwriting my arrays (But nooo, the values as well as size(), ubound() and lbound() are what they should be, and allocated() is true.)

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

Greetings & thank you,
Giogio
# 2  
Old 06-23-2010
Hi, Giogio.

Welcome to the forum.

1) Did your program ever work correctly? If so, what was the most recent change you made? If not, have you compiled and run with -fbounds-check ?

2) Are you using any c / c++ code?

The short code at Double free or corruption error produces the "glibc ... out' message.

cheers, drl
# 3  
Old 06-24-2010
Hi drl,
Thank you very much for your reply (-:
The -fbounds-check totally did the trick.
The problem was a line of the form
Code:
array1(x,:)=Loong formula of array2(:,y)

where the dimensions of the arrays didnt match - please dont ask me why that one worked all the other times ^^.
Thanks and bye,
Giogio

Last edited by pludi; 06-24-2010 at 09:07 AM.. Reason: code tags, please...
# 4  
Old 06-24-2010
Hi, Giogio.

Glad to hear it pointed you in the right direction.

There is always a balance between desired speed and risk. I think Niklaus Wirth recommended bounds checking on arrays particularly for a production code. The idea is that one's results are worthless, even dangerous, if they are produced quickly but incorrectly.

At a place I once worked specializing in big iron: Big iron - Wikipedia, the free encyclopedia , we often said that if you don't care about the reliability of the answers, we can make the computation arbitrarily fast Smilie

In any event, -fbounds-check is a useful debugging feature.

Best wishes ... cheers, drl
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

C. To segmentation fault or not to segmentation fault, that is the question.

Oddities with gcc, 2.95.3 for the AMIGA and 4.2.1 for MY current OSX 10.14.1... I am creating a basic calculator for the AMIGA ADE *NIX emulator in C as it does not have one. Below are two very condensed snippets of which I have added the results inside the each code section. IMPORTANT!... (11 Replies)
Discussion started by: wisecracker
11 Replies

2. Programming

Segmentation fault

I keep getting this fault on a lot of the codes I write, I'm not exactly sure why so I'd really appreciate it if someone could explain the idea to me. For example this code #include <stdio.h> main() { unsigned long a=0; unsigned long b=0; int z; { printf("Enter two... (2 Replies)
Discussion started by: sizzler786
2 Replies

3. Solaris

Segmentation fault

Hi Guys, I just installed and booted a zone called testzone. When I logged in remotely and tried changing to root user I get this error: "Segmentation fault" Can someone please help me resolve this? Thanks alot (2 Replies)
Discussion started by: cjashu
2 Replies

4. Programming

Using gdb, ignore beginning segmentation fault until reproduce environment segmentation fault

I use a binary name (ie polo) it gets some parameter , so for debugging normally i do this : i wrote script for watchdog my app (polo) and check every second if it's not running then start it , the problem is , if my app , remain in state of segmentation fault for a while (ie 15 ... (6 Replies)
Discussion started by: pooyair
6 Replies

5. Programming

segmentation fault

Hi, I am having this segmentation fault not in the following program, bt. in my lab program . My lab program is horrible long so cannot post it here bt. I am using the following logic in my program which is giving the segmentation fault. Bt. if I run this sample program as it is it dosen't give... (3 Replies)
Discussion started by: mind@work
3 Replies

6. Programming

segmentation fault

If I do this. Assume struct life { char *nolife; } struct life **life; // malloc initialization & everything if(life->nolife == 0) Would I get error at life->nolife if it is equal to 0. wrong accession? (3 Replies)
Discussion started by: joey
3 Replies

7. UNIX for Dummies Questions & Answers

Segmentation Fault

Hi, While comparing primary key data of two tables thr bteq script I am getting this Error. This script is a shell script. *** Error: The following error was encountered on the output file. Script.sh: 3043492 Segmentation fault(coredump) Please let me know how to get through it. ... (5 Replies)
Discussion started by: monika
5 Replies

8. Linux

Segmentation fault

Hi, on a linux Red HAT(with Oracle DB 9.2.0.7) I have following error : RMAN> delete obsolete; RMAN retention policy will be applied to the command RMAN retention policy is set to redundancy 2 using channel ORA_DISK_1 Segmentation fault What does it mean ? And the solution ? Many thanks. (0 Replies)
Discussion started by: big123456
0 Replies

9. AIX

Segmentation fault

Hi , During execution a backup binary i get following error "Program error 11 (Segmentation fault), saving core file in '/usr/datatools" Riyaz (2 Replies)
Discussion started by: rshaikh
2 Replies

10. UNIX for Dummies Questions & Answers

Segmentation Fault

hello all, I tried a program on an array to intialise array elements from the standard input device.it is an integer array of 5 elements.but after entering the 4th element it throws a message called "Segmentation Fault" and returns to the command prompt without asking for the 5th element. ... (3 Replies)
Discussion started by: compbug
3 Replies
Login or Register to Ask a Question