Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Kelsey admits Linux SW is fatally flawed

Reply
Thread Tools

Kelsey admits Linux SW is fatally flawed

 
 
Malcolm McLean
Guest
Posts: n/a
 
      02-02-2008

"Ulrich Eckhardt" <> wrote in message
> Stop. There is no handler. I guess you are referring to your own
> implementation that contains a callback which allows the user some control
> of what happens, but that is irrelevant.
>

Fair enough.
>
> AFAICT, the only agreed-on
> semantic of xmalloc() is that it either not returns or returns the
> requested memory, because only with that guarantee you can sensibly
> remove all allocation checks from the calling code.
>

It is relevant because, although the guarantee must necessarily mean that it
is possible for xmalloc() to terminate, this doesn't always imply a sudden
termination with loss of data for each failed call to malloc().

Typically an interactive program runs on a desktop with other programs which
compete with it for memory. So if a small, legitimate request is not
honoured, it is perfectly reasonable to terminate a less-important
competitor.

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

 
Reply With Quote
 
 
 
 
Kelsey Bjarnason
Guest
Posts: n/a
 
      02-03-2008
[snips]

On Fri, 01 Feb 2008 07:46:05 +0100, Ulrich Eckhardt wrote:

> Now, glib offers both allocation functions that return NULL on OOM (the
> 'try' ones) and functions that never return NULL but instead abort, so
> the competent programmer can choose which one is appropriate for his
> job. Where is the problem with that?


Suppose I use glib to develop an application. Glib itself regularly
fails to even document the return of an allocation failure - see almost
any library routine which requires or uses allocations.

As a developer of such an app, I become used to the glib way of doing
things: allocation works, or the app dies.

However, there's now a "don't die, report" allocator. Is it used by the
library itself? If so, there's now problems:

a) The library cannot be relied upon because the documentation, which
assumes "die on failure", does not describe behaviour with the new
allocator, or

b) The library _does_ document functions using the new allocator, but
suddenly the size of the library has doubled (assuming every function now
uses the new allocator) or

c) The library has _not_ doubled, but claims to use the new allocator,
meaning you can expect "silent" changes to at least some of the existing
functions to use the new behaviour, despite all the code written against
the library relying on the old behaviour


In the first case, the library simply becomes unusable - you can't trust
it.

In the second case, the library becomes unwieldy, more prone to bugs
(twice the functions to maintain) and you're never quite sure whether
they actually _did_ use the new allocator everywhere (eg that
glib_function_x() does not, seven call levels down, call the terminate on
failure allocator).

In the third case, all the code you wrote against the library is suspect
and must be re-done - and you don't even know what cases it needs to be
redone for.

Without the report-on-failure allocator, you had a bad design decision,
but it was at least consistently bad.

 
Reply With Quote
 
 
 
 
Kelsey Bjarnason
Guest
Posts: n/a
 
      02-04-2008
On Mon, 04 Feb 2008 19:00:17 +0100, Ulrich Eckhardt wrote:

> Kelsey Bjarnason wrote:
>> [snips]
>>
>> On Fri, 01 Feb 2008 07:46:05 +0100, Ulrich Eckhardt wrote:
>>
>>> Now, glib offers both allocation functions that return NULL on OOM
>>> (the 'try' ones) and functions that never return NULL but instead
>>> abort, so the competent programmer can choose which one is appropriate
>>> for his job. Where is the problem with that?

>>
>> Suppose I use glib to develop an application. Glib itself regularly
>> fails to even document the return of an allocation failure - see almost
>> any library routine which requires or uses allocations.

>
> An example would have been nice,


How about string completion? There are several functions there which
allocate memory, yet fail to document behaviour on allocation failure.
For example:

<quote>
GCompletion *g_completion_new (GCompletionFunc func);

Creates a new GCompletion.

func : the function to be called to return the string representing an
item in the GCompletion, or NULL if strings are going to be used as the
GCompletion items.

Returns : the new GCompletion.
</quote>

No mention of what happens on allocation failure. None. Doesn't happen,
ever, apparently.

> I think I get the idea of what some people consider bad about glib now.
> However, I didn't find it in the link the OP was giving.


Not enough? Here's another, g_base64_encode. Here is the total
documentation of the function, on its reference page:

<quote>
g_base64_encode ()

gchar *g_base64_encode(const guchar *data, gsize len);

Encode a sequence of binary data into its Base-64 stringified
representation.

data : the binary data to encode
len : the length of data

Returns : a newly allocated, zero-terminated Base-64 encoded string
representing data. The returned string must be freed with g_free().
</quote>

Returns a newly allocated...string. And it returns _what_ on allocation
failure? Nothing, apparently.


Elsewhere, we discover the nifty concept of GError, which is a mechanism
for handling errors, something akin to an exception. Sounds good.
Here's a comment from the documentation of it:

"Functions that can fail take a return location for a GError as their
last argument."

Oh? g_completion_new doesn't take such a parameter, yet allocates
memory. This means, of course, that every machine g_completion_new will
be used on has infinite memory available - the only way to ensure it
won't fail. Of course, it can, meaning it _is_ a function which can
fail, thus takes a GError as its last parameter. Except it doesn't.
Therefore it cannot fail. Except it can. Error, error, does not
compute...

High comedy at its finest.

 
Reply With Quote
 
Ulrich Eckhardt
Guest
Posts: n/a
 
      02-04-2008
Kelsey Bjarnason wrote:
> [snips]
>
> On Fri, 01 Feb 2008 07:46:05 +0100, Ulrich Eckhardt wrote:
>
>> Now, glib offers both allocation functions that return NULL on OOM (the
>> 'try' ones) and functions that never return NULL but instead abort, so
>> the competent programmer can choose which one is appropriate for his
>> job. Where is the problem with that?

>
> Suppose I use glib to develop an application. Glib itself regularly
> fails to even document the return of an allocation failure - see almost
> any library routine which requires or uses allocations.


An example would have been nice, I guess g_error_new would serve as one.
That said, there is no g_error_try_new which would explicitly report OOM by
returning NULL, so assuming a certain consistency I would expect this to
abort. Aborting without a choice is a bad idea though, as is lack of
consistency.

I think I get the idea of what some people consider bad about glib now.
However, I didn't find it in the link the OP was giving.

cheers

Uli

 
Reply With Quote
 
Ulrich Eckhardt
Guest
Posts: n/a
 
      02-08-2008
Kelsey Bjarnason wrote:
> On Mon, 04 Feb 2008 19:00:17 +0100, Ulrich Eckhardt wrote:
>> I think I get the idea of what some people consider bad about glib now.
>> However, I didn't find it in the link the OP was giving.

>
> Not enough? Here's another, g_base64_encode.


....which is not documented on the page that the OP's link points to.

Uli

 
Reply With Quote
 
Kelsey Bjarnason
Guest
Posts: n/a
 
      02-09-2008
On Fri, 08 Feb 2008 07:43:21 +0100, Ulrich Eckhardt wrote:

> Kelsey Bjarnason wrote:
>> On Mon, 04 Feb 2008 19:00:17 +0100, Ulrich Eckhardt wrote:
>>> I think I get the idea of what some people consider bad about glib
>>> now. However, I didn't find it in the link the OP was giving.

>>
>> Not enough? Here's another, g_base64_encode.

>
> ...which is not documented on the page that the OP's link points to.


It's part of glib, which is the library under discussion, you know, the
library with the design flaw in it.

If browsing the other function references on the site is too difficult,
try google.

 
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
LDO admits that linux will never make it as a desktop OS Squiggle NZ Computing 3 10-23-2010 08:12 PM
Olympus admits their micro 4/3rds focusing system is flawed RichA Digital Photography 10 03-29-2010 08:23 AM
Linux Torvalds admits he is not father of Linux steve NZ Computing 0 05-18-2004 03:04 AM
Linux Torvalds admits he is not father of Linux steve NZ Computing 0 05-18-2004 03:01 AM
MSDN Examples flawed Stamen Gortchev ASP .Net 11 09-29-2003 08:34 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