Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

"Segmentation fault" after getting the results

4 views
Skip to first unread message

Fatemeh

unread,
Apr 24, 2009, 8:16:23 AM4/24/09
to
Dear all ;

My code can be executed and I extract the desired results, but after
printing the results , that gives me "Segmentation fault" error and it
is very strange for me why I get this message although I checked all
of the arrays and didn't find any mistake and also can get the correct
result.

Is there anyone can give me a hint to find the bug?

Thanks in advance,
F.M

viper-2

unread,
Apr 24, 2009, 9:31:46 AM4/24/09
to

It's usually not possible to find a bug without seeing the code.
Where's the code?

After doing the calculations correctly you might be trying to print an
array outside of its bounds. That would certainly trigger your seg
fault.

agt


--
Freedom - no pane, all gaiGN!

Code Art Now
http://codeartnow.com
Email: a...@codeartnow.com

Gordon Sande

unread,
Apr 24, 2009, 10:25:53 AM4/24/09
to
On 2009-04-24 09:16:23 -0300, Fatemeh <fateme....@gmail.com> said:

> Dear all ;
>
> My code can be executed and I extract the desired results, but after
> printing the results , that gives me "Segmentation fault" error and it
> is very strange for me why I get this message although


> I checked all of the arrays

Three points:

1. Show the problem. Since you have a problem it is self evident that
your description is surely going to be wrong (as in - if you could
give a correct description then you would have solved the problem!).

2. "I checked" is not of any use unless it means that you used the
compilers subscript checking to do it for you. See 1 above. But
the subscript checking is easily fooled by "(*)" declarations so
those need to be avoided. See 3 below and use assumed shape "(:)"
declarations in all subroutines and functions.

3. Using the full F90 (ie. F90/95/2003/200x) safety checking of every
subroutine or function in a module to have its call checked against
the definition will catch the other standard causes of this type of
error.

glen herrmannsfeldt

unread,
Apr 24, 2009, 1:44:30 PM4/24/09
to
Fatemeh <fateme....@gmail.com> wrote:

> My code can be executed and I extract the desired results, but after
> printing the results , that gives me "Segmentation fault" error and it
> is very strange for me why I get this message although I checked all
> of the arrays and didn't find any mistake and also can get the correct
> result.

It is possible that you can go outside the array early
in the program, get the right answer, and the
Segmentation Fault comes later. Specifically, it can
come when memory allocation/deallocation is done, often
much later than the cause.

Turn on bounds checking throughout.

-- glen

robin

unread,
Apr 24, 2009, 9:40:19 PM4/24/09
to
"Fatemeh" <fateme....@gmail.com> wrote in message
news:4859425e-2a3a-4ee1...@x5g2000yqk.googlegroups.com...

Try turning on subscript bounds checking.
Also, turn on string bounds checking.


0 new messages