Re: xmalloc string functions



William Ahern wrote:
Yevgen Muntyan <muntyan@xxxxxxxxxxxxxxxxxxx> wrote:
William Ahern wrote:
Yevgen Muntyan <muntyan@xxxxxxxxxxxxxxxxxxx> wrote:
Malcolm McLean wrote:
Here are six functions implemented on top of xmalloc(). No C programmer should have any triouble providing the implemetations, though replace and getquote are non-trivial.
[snip]
I've think we've got something quite powerful here, purely because none of these functions can ever return null for out of memory conditions. It massively simplifies string handling.
Take a look at glib,
http://library.gnome.org/devel/glib/2.14/glib-Memory-Allocation.html
glib is where bad ideas go to die. Now, if somebody just had the nerve to
tell them....
There are at least two desktop environments built on glib, and
bunch of independent applications, and they actually work. Have
you got something more substantial than "bad ideas"?

I only brought it up because glib uses an xmalloc() wrapper which dies on
allocation failure, and Evolution and similar glib-based applications loved
to crash when, for instance, I would [try to] open a message with an
especially long marked-up diff. Of course, it was worse (as in more
frequent) before I disabled the Linux OOM killer. Never infrequent enough,
however.

I'd think evolution crashed because it crashed. You can look at
its list of bugs to see what I mean. If it was abort() inside
g_malloc(), then it probably leaked so much that it indeed has
eaten everything and asked for more. In which case you can't
really blame glib ;)
(Here I'd be actually grateful if such applications were killed
immediately, because they first freeze X, and I've got to wait
for ten minutes to switch to console and kill the application.
They just don't die themselves.)


In my experience, glib-based applications "mostly" work. Not sure whether
that has more to do w/ the xmalloc() wrapper, or other issues.

There is no xmalloc() wrapper in glib. Anyway, have you never
seen "mostly working" application which do not use glib? Bugs
are everywhere, on all platforms. Do you have a real base for
saying that g_malloc() is somehow responsible for crashes you
have seen? Something other than "evolution crashed", that is,
or "similar applications" (similar glib-based applications
which open messages, huh?).

You know, I have heard things like you are saying only from
people who talk about xmalloc() and related things. Never from
users. Why is that? Perhaps because buggy applications are
buggy applications, not some poor creatures crashing because
glib memory handling is broken?

I'll grant
you that the organization and design of glib source interfaces is... a
matter of taste.

Yes it is, certainly. And it's irrelevant.


One of my rules of thumb is that if a network daemon uses glib, I
automatically exclude it from consideration. I can deal when an application
crashes and destroys my work. I don't want to be responsible for installing
an application which crashes and destroys or interrupts _other_ people's
work.

It's fine, nobody promiced glib will work for any program. It certainly
won't; but nevertheless it doesn't make abort-on-failing-malloc less
sensible strategy for a whole class of applications.

Besides, a glib application can set up some sort of emergency memory
pool or something, so that failed malloc doesn't necessarily lead to
immediate abort(). Same sort of science fiction as "graceful exit with
saving data on *any* failed malloc() call in any possible application
in any possible situation" which seems to be so popular here ;)

Best regards,
Yevgen
.



Relevant Pages

  • Re: [SLE] Error running -some- gnome apps
    ... applications. ... Such an error is always a bug (or misuse of glib) in the application. ... does not support "true" object-oriented programming. ...
    (SuSE)
  • Re: [SLE] Error running -some- gnome apps
    ... applications. ... Such an error is always a bug (or misuse of glib) in the application. ...
    (SuSE)
  • Re: maximum number of controls on a form
    ... Thanks for your insight to the stability of Access (I actually, ... The crashes that I have are solely related to forms, ... I had customers running applications with my all day ... phone call in 9 years that it every hung up. ...
    (microsoft.public.access.forms)
  • Re: xmalloc string functions
    ... its list of bugs to see what I mean. ... I'd much rather that Evolution fail to open a message than to exit entirely. ... In my experience, glib-based applications "mostly" work. ... crashes and destroys my work. ...
    (comp.lang.c)
  • F9 - Weird GTK behavior
    ... save-as or even open documents with applications that ... use the GTK file picker dialog the application crashes. ... dialogs") I was able to resolve the problem for OpenOffice. ...
    (Fedora)