Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Linux's approaching Achilles' heal

Reply
Thread Tools

Linux's approaching Achilles' heal

 
 
$)CHarald van D)&k
Guest
Posts: n/a
 
      11-20-2007
On Mon, 19 Nov 2007 22:50:12 +0000, Malcolm McLean wrote:
> "Richard Heathfield" <> wrote in message
>> Unless of course some brain-damaged library designer has arranged that
>> malloc never, ever returns NULL, so that even properly-written
>> applications can't tell whether a request succeeded or not. If ever
>> there was a decision that favoured the mediocre over the competent,
>> that's the one.
>>

> That's me.
> Check out xmalloc(), a malloc that never returnsNULL, on my website.


Your xmalloc aborts (by default) when no memory is available. I believe
Mr. Heathfield was referring to a particular malloc implementation that
returns a non-null pointer even when no memory is available, causing
either that program, or some semi-random other program to crash at some
later time when the memory gets used, without any way for the program to
handle the error.
 
Reply With Quote
 
 
 
 
CBFalconer
Guest
Posts: n/a
 
      11-20-2007
$)CHarald van D)&k wrote:
> Malcolm McLean wrote:
>> "Richard Heathfield" <> wrote in message
>>
>>> Unless of course some brain-damaged library designer has arranged
>>> that malloc never, ever returns NULL, so that even properly-written
>>> applications can't tell whether a request succeeded or not. If ever
>>> there was a decision that favoured the mediocre over the competent,
>>> that's the one.

>>
>> That's me.
>> Check out xmalloc(), a malloc that never returnsNULL, on my website.

>
> Your xmalloc aborts (by default) when no memory is available. I believe
> Mr. Heathfield was referring to a particular malloc implementation that
> returns a non-null pointer even when no memory is available, causing
> either that program, or some semi-random other program to crash at some
> later time when the memory gets used, without any way for the program to
> handle the error.


I doubt it. He is probably referring to just what Mr. McLean has
apparently done, i.e. automatic program abort. Now the program has
no way of detecting that memory is no longer available, and cannot
take remedial steps.

--
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home.att.net>
Try the download section.



--
Posted via a free Usenet account from http://www.teranews.com

 
Reply With Quote
 
 
 
 
Richard Heathfield
Guest
Posts: n/a
 
      11-20-2007
??Harald van D??k said:

<snip>

> I believe
> Mr. Heathfield was referring to a particular malloc implementation that
> returns a non-null pointer even when no memory is available [...]


Mr van Dijk believes correctly.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
 
Reply With Quote
 
Richard Heathfield
Guest
Posts: n/a
 
      11-20-2007
CBFalconer said:

> $)CHarald van D)&k wrote:
>> Malcolm McLean wrote:
>>> "Richard Heathfield" <> wrote in message
>>>
>>>> Unless of course some brain-damaged library designer has arranged
>>>> that malloc never, ever returns NULL, so that even properly-written
>>>> applications can't tell whether a request succeeded or not. If ever
>>>> there was a decision that favoured the mediocre over the competent,
>>>> that's the one.
>>>
>>> That's me.
>>> Check out xmalloc(), a malloc that never returnsNULL, on my website.

>>
>> Your xmalloc aborts (by default) when no memory is available. I believe
>> Mr. Heathfield was referring to a particular malloc implementation that
>> returns a non-null pointer even when no memory is available, causing
>> either that program, or some semi-random other program to crash at some
>> later time when the memory gets used, without any way for the program to
>> handle the error.

>
> I doubt it.


You doubt wrong.

> He is probably referring to just what Mr. McLean has
> apparently done, i.e. automatic program abort. Now the program has
> no way of detecting that memory is no longer available, and cannot
> take remedial steps.


No, it is easy to solve the problems caused by Mr McLean's function, by the
simple expedient of not using it.

It's a lot harder to avoid malloc.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
 
Reply With Quote
 
Keith Kanios
Guest
Posts: n/a
 
      11-20-2007
On Nov 19, 3:34 pm, Evenbit <nbaker2...@charter.net> wrote:
> On Nov 18, 12:46 am, Keith Kanios <ke...@kanios.net> wrote:
>
>
>
> > Ah... theory. Leaves a nice warm feeling, doesn't it?

>
> ... and leads to my trade-mark trait of "going off half-cocked!"


There's nothing to prove around here, only knowledge to gain and
eventually give back.

>
>
> > Three potential solutions to fix your unsound comments.

>
> > 1) Re-read those books.
> > 2) Get more modern/informative books.
> > 3) Try a little practical implementation so you can see why it is so
> > foolish to back such inconsistent theories or potential
> > misunderstandings.

>
> Luckily, just re-reading them was enough to convince me of my error.
> My confusion was due to putting too much emphasis on the fact that
> blocks always contain pages that are assigned to contiguous regions of
> a process' address space. It is true that it is possible to fragment
> (make a mess of) the process' address space, but this should only
> happen due to extremely bad code or via intentional effort on the part
> of the programmer. Even then, I suspect that any "fragmentation wall"
> is purely theoretical because your process would be stopped long
> before it could be hit.
>
> Also, if you write an application that is extremely memory-hungry, you
> need to scrap everything and go back to the flow-charts for an
> entirely different design.
>
> Nathan.


There you go
 
Reply With Quote
 
Richard Bos
Guest
Posts: n/a
 
      11-20-2007
"Malcolm McLean" <> wrote:

> "Richard Heathfield" <> wrote in message
> >
> > Unless of course some brain-damaged library designer has arranged that
> > malloc never, ever returns NULL, so that even properly-written
> > applications can't tell whether a request succeeded or not. If ever there
> > was a decision that favoured the mediocre over the competent, that's the
> > one.

>
> That's me.


To a tee.

> Check out xmalloc(), a malloc that never returnsNULL, on my website.


A malloc() replacement that never returns a null pointer must eventually
resort to doing something much worse.

Richard
 
Reply With Quote
 
Malcolm McLean
Guest
Posts: n/a
 
      11-20-2007
"Richard Bos" <> wrote in message
> "Malcolm McLean" <> wrote:
>
>> Check out xmalloc(), a malloc that never returnsNULL, on my website.

>
> A malloc() replacement that never returns a null pointer must eventually
> resort to doing something much worse.
>

It's good for medium-critical applications.
If you request a small amount of memory then it is unlikely that the user
cannot close down some other application to release it. Alternatively the
callback could release an emergency store. However then it would have to
post a quit message, because of the danger that user might simply continue.

If you request a massive amount of memory that's probably because of a bug
or malicious input, so it is unclear what to do in that situation anyway.

In very critical applications, you will want to recover gracefully from a
memory allocation failure. This adds very substantially to the costs of
writing the code, and is also difficult to test. However if the program must
under no circumstances terminate, this is what you must do. xmalloc()
supposes that termination can be used as a last / first resort, depending on
the program.

--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm


 
Reply With Quote
 
Richard Bos
Guest
Posts: n/a
 
      11-23-2007
"Malcolm McLean" <> wrote:

> "Richard Bos" <> wrote in message
> > "Malcolm McLean" <> wrote:
> >
> >> Check out xmalloc(), a malloc that never returnsNULL, on my website.

> >
> > A malloc() replacement that never returns a null pointer must eventually
> > resort to doing something much worse.
> >

> It's good for medium-critical applications.
> If you request a small amount of memory then it is unlikely that the user
> cannot close down some other application to release it. Alternatively the
> callback could release an emergency store. However then it would have to
> post a quit message, because of the danger that user might simply continue.
>
> If you request a massive amount of memory that's probably because of a bug
> or malicious input, so it is unclear what to do in that situation anyway.
>
> In very critical applications, you will want to recover gracefully from a
> memory allocation failure. This adds very substantially to the costs of
> writing the code, and is also difficult to test. However if the program must
> under no circumstances terminate, this is what you must do. xmalloc()
> supposes that termination can be used as a last / first resort, depending on
> the program.


Tell me, have you ever pasted a large graphic into a report?

Richard
 
Reply With Quote
 
Malcolm McLean
Guest
Posts: n/a
 
      11-23-2007

"Richard Bos" <> wrote in message
> "Malcolm McLean" <> wrote:
>
>> In very critical applications, you will want to recover gracefully from a
>> memory allocation failure. This adds very substantially to the costs of
>> writing the code, and is also difficult to test. However if the program
>> must
>> under no circumstances terminate, this is what you must do. xmalloc()
>> supposes that termination can be used as a last / first resort, depending
>> on
>> the program.

>
> Tell me, have you ever pasted a large graphic into a report?
>

You shouldn't use the xmalloc() handler as part of the "normal" flow control
of the program.
Let's say we are allocating an image of 1 million bytes. At the same time we
allocate a hundred byte string to hold the image name. Let's also say that
the user experiences one allocation failure per day of using the program, on
average.
A simple calculation will show that, assuming 50 working weeks of 5 days
each, he can expect the failure to be in the hundred byte allocation about
once every 40 years. For the vast majority of "lose a day's work" type
critical applications, that sort of failure rate is acceptable. it is much
lower than the chance of a hardware failure in the same time. On the other
hand one failure a day isn't acceptable, so we've got to handle it rather
better. But the failure-handling routines tend to add considerable
complexity to code, and it's hard to test.
The point of xmalloc() is that even if the allocation does fail, we can
choose to give the user a chance to get some more memory. However we don't
have special error-handling recovery code. It's simply not worth coding and
testing - and they tend to be hard to test - custom error handlers for such
rare problems, unless the future of the business is at stake if we have to
crash. It's a misallocation of scare programming resources.

Note that even if the once in forty years problem does come up, we can still
give the user the chance to close down some applications. If he can't get a
hundred bytes from the system, anywhere, it is likely that he'll have to
reboot anyway.

--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Physician, heal thyself Aardvark Computer Support 0 12-08-2010 04:46 PM
work to heal Robin C++ 0 12-02-2010 11:10 PM
Hospital software vendor mckesson uses Linux to heal IT budgets Au79 Computer Support 2 12-15-2007 04:31 AM
Threat Found, Heal, Now computer reboots on startup 4deadcrowsstudio@gmail.com Computer Support 19 12-11-2006 07:46 PM
approaching my idea with a new perspective Richard HTML 1 12-24-2004 05:09 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57