From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ab4f67f984ef04f9 X-Google-Attributes: gid103376,public Path: controlnews3.google.com!news1.google.com!news.glorb.com!newsfeed1.ip.tiscali.net!tiscali!transit1.news.tiscali.nl!dreader2.news.tiscali.nl!not-for-mail Newsgroups: comp.lang.ada Subject: Re: Is the Ada run-time required to detect out-of-memory References: <878yfmiuak.fsf@insalien.org> <2h7b84Fa2aefU1@uni-berlin.de> <87n041l9mv.fsf@insalien.org> From: Ludovic Brenta Date: Tue, 25 May 2004 23:19:21 +0200 Message-ID: <87pt8sfbmu.fsf@insalien.org> User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) Cancel-Lock: sha1:SLwfEXokCS/8+w+R3p/2L2htAOY= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Organization: Tiscali bv NNTP-Posting-Date: 25 May 2004 23:18:32 CEST NNTP-Posting-Host: 83.134.237.254 X-Trace: 1085519912 dreader2.news.tiscali.nl 41764 83.134.237.254:36014 X-Complaints-To: abuse@tiscali.nl Xref: controlnews3.google.com comp.lang.ada:828 Date: 2004-05-25T23:18:32+02:00 List-Id: "Robert I. Eachus" writes: > Ludovic Brenta wrote: > >> I just closed your bug report after determining that the issue was not >> in libgnat but in the kernel. Basically, Linux sends SIGKILL to >> programs that exhaust physical RAM; as you know, SIGKILL cannot be >> caught so libgnat has no chance to raise an exception. If the virtual >> memory is exhausted before physical memory is, then libgnat does raise >> Storage_Error. > > Did you refile the bug against the kernel? No, I didn't. As explained above, I leave this to the OP to decide whether or not the current behaviour is a problem. > As I understand it now, the problem is not that the kernel raises > SIGKILL if physical RAM is exhausted, but that malloc doesn't check > that the allocation can succeed before making it. > > Having said that, I suspect that this should be a low priority bug, > and it will be pretty hard to fix. It may take adding a version of > malloc that does the check, and leaving the decision as to which one > to call to the compiler run-time. (GNAT should then use the new call > when allocating storage pools, and probably continue using the current > version for allocations in the default storage pool. As Duncan pointed out, a version of malloc that does the check would be very difficult to write indeed. It would have to hook directly into the kernel's memory manager in order to know which pages are swapped out, which ones are dirty, and so on. Note that it would have to switch paradigms in the process, from arbitrary-sized chunks to pages and from user space to kernel space. This also would break the whole purpose of some important design decisions made in Linux. Personally, I would just leave it at that. If someone needs more deterministic behaviour than Linux provides, they should be using a real-time kernel without any virtual memory. -- Ludovic Brenta.