comp.lang.ada
 help / color / mirror / Atom feed
From: "Robert I. Eachus" <rieachus@comcast.net>
Subject: Re: Is the Ada run-time required to detect out-of-memory conditions?
Date: Thu, 20 May 2004 23:29:40 -0400
Date: 2004-05-20T23:29:40-04:00	[thread overview]
Message-ID: <x_CdnbMfhpo56jDdRVn-hw@comcast.com> (raw)
In-Reply-To: <878yfmiuak.fsf@insalien.org>

Ludovic Brenta wrote:

> I have received a bug report [1] against GNAT 3.15p and reproduced the
> same behaviour with GCC 3.4.  I would like the advice of language
> lawyers on the issue.
> 
> [1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=250076
> 
> The program allocates memory in an infinite loop using "new" and the
> default storage pool, and of course exhausts all available storage.
> The issue is whether or not Storage_Error should be raised.  With
> GNAT, no exception is raised; instead the program receives SIGKILL
> (not even SIGSEGV) from Linux.
> 
> My first impression is that the program exhausts physical memory (RAM
> + swap) before exhausting the default storage pool, the size of which
> is defined to be the total size of the virtual address space.  As a
> result, the kernel detects the out-of-memory condition before the Ada
> run-time library does, and sends SIGKILL to the program.  Of course,
> the program has no chance to turn SIGKILL into an exception.
> 
> Is my assessment correct?  Is this a bug in the GNAT library?
> 
> Thanks for any insight.
> 
> PS. The original reported says that the program receives SIGSEGV.  He
> uses Linux 2.4.22.  I use 2.4.26 and the program receives SIGKILL
> instead.  I don't know if this is a known change in the kernel's
> behaviour.

Unfortunately you are going to have to determine this for yourself.  Let 
me suggest a program and you can determine what should happen.  But the 
bug as such is not a GNAT library bug, it is an interaction between GNAT 
and Debian.

Write a program that exhausts memory but prints the amount of memory 
allocated and the bounds with each allocation.  You can be smart about 
this, but eventually you may have to have an allocate, write, delay loop 
in the critical area.

My guess is that you will find that what happens is that Debian 
allocates pages but only populates them on write.  So the amount of 
memory allocated eventually exceeds 2**31, even if you don't have 2 Gig 
of paging space.  Now all of a sudden you have a segment of memory 
allocated across the 2 Gig point.  And somewhere along the line some 
code is computing the size of the space allocated by address(Last) - 
address(First).  If this is in fact the case, yes there is a bug, but I 
don't know where.

If you can catch it in the debugger great.  But it sounds like you are 
going to have to figure out from the chunk that is getting allocated 
when the bomb goes off what broke.

Dave Emery used to call Storage_Error a parachute that opens on impact, 
and this is part of why.  Often there is nothing sensible that you can 
do in an local Ada exception handler, you have to try to catch it 
partway down the call stack, if possible.  But usually you are lucky if 
you can catch it inside the program.

-- 

                                           Robert I. Eachus

"The terrorists rejoice in the killing of the innocent, and have 
promised similar violence against Americans, against all free peoples, 
and against any Muslims who reject their ideology of murder. Their 
barbarism cannot be appeased, and their hatred cannot be satisfied. 
There's only one way to deal with terror: We must confront the enemy and 
stay on the offensive until these killers are defeated." -- George W. Bush




  parent reply	other threads:[~2004-05-21  3:29 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-20 22:54 Is the Ada run-time required to detect out-of-memory conditions? Ludovic Brenta
2004-05-21  0:44 ` Georg Bauhaus
2004-05-21  0:47 ` Stephen Leake
2004-05-21  0:54   ` Georg Bauhaus
2004-05-21  1:00     ` Stephen Leake
2004-05-21  3:29 ` Robert I. Eachus [this message]
2004-05-21  8:04 ` Vinzent 'Gadget' Hoefler
2004-05-21  9:34   ` Martin Krischik
2004-05-21 11:13 ` Wojtek Narczynski
2004-05-21 12:55   ` Martin Krischik
2004-05-21 16:00     ` Robert I. Eachus
2004-05-21 17:13       ` Ludovic Brenta
2004-05-21 23:41         ` Wojtek Narczynski
2004-05-23  8:20       ` Martin Krischik
2004-05-21 19:58   ` Randy Brukardt
2004-05-21 16:56 ` Mark H Johnson
2004-05-21 17:19   ` Ludovic Brenta
2004-05-21 21:39 ` user
2004-05-21 22:04   ` Ludovic Brenta
2004-05-21 22:11     ` Ludovic Brenta
2004-05-22 11:40       ` Simon Wright
2004-05-25 20:43     ` Is the Ada run-time required to detect out-of-memory Robert I. Eachus
2004-05-25 20:58       ` Duncan Sands
2004-05-25 21:19       ` Ludovic Brenta
2004-05-25 21:31         ` Duncan Sands
2004-05-26  7:09       ` Martin Krischik
2004-05-26  7:38         ` Duncan Sands
2004-05-26  8:16           ` Martin Krischik
2004-05-26  8:34             ` Duncan Sands
2004-05-26 16:20               ` Martin Krischik
2004-05-22 13:40   ` Is the Ada run-time required to detect out-of-memory conditions? Duncan Sands
2004-05-22 14:09     ` Martin Krischik
replies disabled

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