comp.lang.ada
 help / color / mirror / Atom feed
* reasons for segmentation faults on linux
@ 2001-11-28 12:03 Tony
  2001-11-28 12:49 ` Marc A. Criley
  0 siblings, 1 reply; 10+ messages in thread
From: Tony @ 2001-11-28 12:03 UTC (permalink / raw)


I'm getting a segmentation fault in linux,

I 've wapped up the storage size and this has no effect, 

I'm using three AVL trees in a task if thats any help

Does anyone know the common reasons for segmentation faults in
Gnat on Linux ?


************************************************************
Everybody is given the same amount of hormones, at birth, and
if you want to use yours for growing hair, that's fine with me.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: reasons for segmentation faults on linux
  2001-11-28 12:03 reasons for segmentation faults on linux Tony
@ 2001-11-28 12:49 ` Marc A. Criley
  2001-11-28 15:59   ` Preben Randhol
  0 siblings, 1 reply; 10+ messages in thread
From: Marc A. Criley @ 2001-11-28 12:49 UTC (permalink / raw)


Tony wrote:
> 
> I'm getting a segmentation fault in linux,
> 
> I 've wapped up the storage size and this has no effect,
> 
> I'm using three AVL trees in a task if thats any help
> 
> Does anyone know the common reasons for segmentation faults in
> Gnat on Linux ?

Misaligned data...  Dereferencing dangling pointers...  Stack overflows
(if stack checking is disabled)...

Marc



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: reasons for segmentation faults on linux
  2001-11-28 12:49 ` Marc A. Criley
@ 2001-11-28 15:59   ` Preben Randhol
  2001-11-28 18:04     ` Mark Johnson
                       ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Preben Randhol @ 2001-11-28 15:59 UTC (permalink / raw)


On Wed, 28 Nov 2001 12:49:54 GMT, Marc A. Criley wrote:
> Tony wrote:
>> 
>> I'm getting a segmentation fault in linux,
>> 
>> I 've wapped up the storage size and this has no effect,
>> 
>> I'm using three AVL trees in a task if thats any help
>> 
>> Does anyone know the common reasons for segmentation faults in
>> Gnat on Linux ?
> 
> Misaligned data...  Dereferencing dangling pointers...  Stack overflows
> (if stack checking is disabled)...

Infinite recursion:

procedure A is
begin
   A;
end A;

% gnatmake a.adb 
gnatgcc -c a.adb
a.adb:3:04: warning: possible infinite aursion
a.adb:3:04: warning: Storage_Error may be raised at run time
gnatbind -x a.ali
gnatlink a.ali

% ./a
Segmentation fault

Why isn't Storage_Error raised? GNAT 3.13p on GNU/Debian Linux.

Preben
-- 
 ()   Join the worldwide campaign to protect fundamental human rights.
'||}
{||'                                           http://www.amnesty.org/



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: reasons for segmentation faults on linux
  2001-11-28 15:59   ` Preben Randhol
@ 2001-11-28 18:04     ` Mark Johnson
  2001-11-28 22:31     ` David Starner
  2001-11-29  3:36     ` Robert Dewar
  2 siblings, 0 replies; 10+ messages in thread
From: Mark Johnson @ 2001-11-28 18:04 UTC (permalink / raw)


Preben Randhol wrote:

> [snip]

> Infinite recursion:
>
> procedure A is
> begin
>    A;
> end A;
>
> % gnatmake a.adb
> gnatgcc -c a.adb
> a.adb:3:04: warning: possible infinite aursion
> a.adb:3:04: warning: Storage_Error may be raised at run time
> gnatbind -x a.ali
> gnatlink a.ali
>
> % ./a
> Segmentation fault
>
> Why isn't Storage_Error raised? GNAT 3.13p on GNU/Debian Linux.
>

RTFM :-). Add -fstack-check to the gnatmake command line to get stack
checking turned on.

As a suggestion, define an environment name w/ the "desired" command line
options & use it instead. At our site...
  GNAT_TESTING="-g -gnata -funwind-tables -gnatO -j3 -gnatn -O2 -gnatwa
-gnatf -fstack-check -gnato -gnatq -gnatU"
and it properly issues the error...

raised STORAGE_ERROR : stack overflow detected

Though perhaps I should submit a bug report to ACT about the warning being in
error if stack checking is suppressed.
  --Mark





^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: reasons for segmentation faults on linux
  2001-11-28 15:59   ` Preben Randhol
  2001-11-28 18:04     ` Mark Johnson
@ 2001-11-28 22:31     ` David Starner
  2001-11-29  3:39       ` Robert Dewar
  2001-11-29  3:36     ` Robert Dewar
  2 siblings, 1 reply; 10+ messages in thread
From: David Starner @ 2001-11-28 22:31 UTC (permalink / raw)


On Wed, 28 Nov 2001 15:59:45 +0000 (UTC), Preben Randhol <randhol+abuse@pvv.org> wrote:
> procedure A is
> begin
>    A;
> end A;
> 
> % gnatmake a.adb 
> gnatgcc -c a.adb
> a.adb:3:04: warning: possible infinite aursion
> a.adb:3:04: warning: Storage_Error may be raised at run time
> gnatbind -x a.ali
> gnatlink a.ali
> 
> % ./a
> Segmentation fault
> 
> Why isn't Storage_Error raised? GNAT 3.13p on GNU/Debian Linux.

If I remember the GNAT RM/UG right, trapping stack overflow is
infeasable on Linux system, so by default it doesn't attempt it. There
are switchs you can add to make an attempt at it.

-- 
David Starner - starner@okstate.edu
Pointless website: http://dvdeug.dhis.org
"I saw a daemon stare into my face, and an angel touch my breast; each 
one softly calls my name . . . the daemon scares me less."
- "Disciple", Stuart Davis



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: reasons for segmentation faults on linux
  2001-11-28 15:59   ` Preben Randhol
  2001-11-28 18:04     ` Mark Johnson
  2001-11-28 22:31     ` David Starner
@ 2001-11-29  3:36     ` Robert Dewar
  2001-11-29 10:36       ` Preben Randhol
  2 siblings, 1 reply; 10+ messages in thread
From: Robert Dewar @ 2001-11-29  3:36 UTC (permalink / raw)


Preben Randhol <randhol+abuse@pvv.org> wrote in message news:<slrna0a2ch.3dp.randhol+abuse@kiuk0156.chembio.ntnu.no>...
> % gnatmake a.adb 
> gnatgcc -c a.adb
> a.adb:3:04: warning: possible infinite aursion
> a.adb:3:04: warning: Storage_Error may be raised at run time
> gnatbind -x a.ali
> gnatlink a.ali
> 
> % ./a
> Segmentation fault
> 
> Why isn't Storage_Error raised? GNAT 3.13p on GNU/Debian 
> Linux.


Because you chose to run with stack checking disabled,
and GNAT followed your directions!



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: reasons for segmentation faults on linux
  2001-11-28 22:31     ` David Starner
@ 2001-11-29  3:39       ` Robert Dewar
  2001-11-29 18:42         ` David Starner
  0 siblings, 1 reply; 10+ messages in thread
From: Robert Dewar @ 2001-11-29  3:39 UTC (permalink / raw)


David Starner <dvdeug@x8b4e53cd.dhcp.okstate.edu> wrote in message news:<9u3okd$9ic2@news.cis.okstate.edu>...


> If I remember the GNAT RM/UG right, trapping stack 
> overflow is
> infeasable on Linux system, so by default it doesn't
> attempt it. There
> are switchs you can add to make an attempt at it.

This is misleading. Stack checking is off in gcc by default
(and gnat always follows general gcc decisions on defaults
for gcc switches, since it would get very confusing if the
defaults were language dependent. If you turn on the switch, you get
stack checking, nothing "infeasible"
about it.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: reasons for segmentation faults on linux
  2001-11-29  3:36     ` Robert Dewar
@ 2001-11-29 10:36       ` Preben Randhol
  2001-11-29 11:01         ` Preben Randhol
  0 siblings, 1 reply; 10+ messages in thread
From: Preben Randhol @ 2001-11-29 10:36 UTC (permalink / raw)


On 28 Nov 2001 19:36:56 -0800, Robert Dewar wrote:
> Because you chose to run with stack checking disabled,
> and GNAT followed your directions!

% set GNAT_STACK_LIMIT=1600

% gnatmake -fstack-check A
gnatgcc -c -fstack-check A.adb
A.adb:3:04: warning: possible infinite Aursion
A.adb:3:04: warning: Storage_Error may be raised at run time
gnatbind -x A.ali
gnatlink A.ali

% ./A 
Segmentation fault

Preben
-- 
 ()   Join the worldwide campaign to protect fundamental human rights.
'||}
{||'                                           http://www.amnesty.org/



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: reasons for segmentation faults on linux
  2001-11-29 10:36       ` Preben Randhol
@ 2001-11-29 11:01         ` Preben Randhol
  0 siblings, 0 replies; 10+ messages in thread
From: Preben Randhol @ 2001-11-29 11:01 UTC (permalink / raw)


On Thu, 29 Nov 2001 10:36:27 +0000 (UTC), Preben Randhol wrote:
> On 28 Nov 2001 19:36:56 -0800, Robert Dewar wrote:
>> Because you chose to run with stack checking disabled,
>> and GNAT followed your directions!
> 
> % set GNAT_STACK_LIMIT=1600
> 
> % gnatmake -fstack-check A
> gnatgcc -c -fstack-check A.adb
> A.adb:3:04: warning: possible infinite Aursion
> A.adb:3:04: warning: Storage_Error may be raised at run time
> gnatbind -x A.ali
> gnatlink A.ali
> 
> % ./A 
> Segmentation fault

ARG! *Bonking my head on the keyboard* 

Forget the above I made the mistake of writing :

   set GNAT_STACK_LIMIT=1600

but in bash shell it is :

   export GNAT_STACK_LIMIT=1600

when I now recompile and run I get.

% ./A

raised STORAGE_ERROR : stack overflow detected

Preben
-- 
 ()   Join the worldwide campaign to protect fundamental human rights.
'||}
{||'                                           http://www.amnesty.org/



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: reasons for segmentation faults on linux
  2001-11-29  3:39       ` Robert Dewar
@ 2001-11-29 18:42         ` David Starner
  0 siblings, 0 replies; 10+ messages in thread
From: David Starner @ 2001-11-29 18:42 UTC (permalink / raw)


On 28 Nov 2001 19:39:01 -0800, Robert Dewar <dewar@gnat.com> wrote:
> This is misleading. Stack checking is off in gcc by default
> (and gnat always follows general gcc decisions on defaults
> for gcc switches, since it would get very confusing if the
> defaults were language dependent. If you turn on the switch, you get
> stack checking, nothing "infeasible"
> about it.

GCC didn't check array accesses by default when GNAT was created. (It
now can do so for Fortran, but doesn't by default, and does for Java.)
Why does GNAT check for array accesses? Stack checking seems more of a
language thing than a general gcc decision.

Why is there GNAT_STACK_LIMIT? If it were feasible to do it cleanly,
then why doesn't GNAT do it that way instead of requiring an additional
enivromental variable?

-- 
David Starner - starner@okstate.edu
Pointless website: http://dvdeug.dhis.org
"I saw a daemon stare into my face, and an angel touch my breast; each 
one softly calls my name . . . the daemon scares me less."
- "Disciple", Stuart Davis



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2001-11-29 18:42 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-28 12:03 reasons for segmentation faults on linux Tony
2001-11-28 12:49 ` Marc A. Criley
2001-11-28 15:59   ` Preben Randhol
2001-11-28 18:04     ` Mark Johnson
2001-11-28 22:31     ` David Starner
2001-11-29  3:39       ` Robert Dewar
2001-11-29 18:42         ` David Starner
2001-11-29  3:36     ` Robert Dewar
2001-11-29 10:36       ` Preben Randhol
2001-11-29 11:01         ` Preben Randhol

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox