Re: xmalloc string functions
- From: Yevgen Muntyan <muntyan@xxxxxxxxxxxxxxxxxxx>
- Date: Sun, 27 Jan 2008 23:48:15 GMT
William Ahern wrote:
Yevgen Muntyan <muntyan@xxxxxxxxxxxxxxxxxxx> wrote:William Ahern wrote:Yevgen Muntyan <muntyan@xxxxxxxxxxxxxxxxxxx> wrote:There are at least two desktop environments built on glib, andMalcolm McLean wrote:glib is where bad ideas go to die. Now, if somebody just had the nerve toHere 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
tell them....
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
.
- Follow-Ups:
- Re: xmalloc string functions
- From: William Ahern
- Re: xmalloc string functions
- References:
- xmalloc string functions
- From: Malcolm McLean
- Re: xmalloc string functions
- From: Yevgen Muntyan
- Re: xmalloc string functions
- From: William Ahern
- Re: xmalloc string functions
- From: Yevgen Muntyan
- Re: xmalloc string functions
- From: William Ahern
- xmalloc string functions
- Prev by Date: Re: Linux Kernel Source
- Next by Date: Re: xmalloc string functions
- Previous by thread: Re: xmalloc string functions
- Next by thread: Re: xmalloc string functions
- Index(es):
Relevant Pages
|