Ok, then we're in agreement. I thought you were justifying a shared library function handling error checking by "on OOM, terminate", because that's what I was objecting to about pa_xmalloc's "error handling".
I do also agree with Wy that a shared lib function should not display any error messages (unless the app has given permission to do so). For one thing, if it's a GUI app, it may not even have stdout/stderr going anywhere (but nul or wherever -- but nowhere that it would be useful to an enduser using a GUI app). The app may prefer to display an error message to the enduser in a way that is applicable to the app. (For example, a GTK app may want to use gtk_message_dialog_new).
A shared lib function should return an error code to the app, and let the app decide how it wants to deal with the error.
What else does it do? Specifically, what does the PA_GCC_NORETURN define expand to? Is it a call to exit()? If so, is PA_GCC_NORETURN used in even more places?After reading the code xmalloc.c the author does write to stderr.
Edit: Nevermind, I finally traced it down. It defines to __attribute__((noreturn)) which in turn does indeed yield a call to exit(). (Actually, it may not write to stderr. What is does is call abort() and then exit(). abort() is applicable only if code is compiled with debugging turned on. abort() typically presents an error message. But in release code, abort() defines to nothing. And I imagine that only release code would appear in a release distro. So you don't even get an error message in the release code. It just terminates the app without notice nor explanation),
So, how many other Pulse Audio functions use PA_GCC_NORETURN themselves, and how many other Pulse Audio functions make their own calls to pa_xmalloc?
I really hope the Ubuntu devs are not considering using Pulse Audio as part of the default install. This has the potential to seriously affect system stability and usability as a running app can just randomly vanish into a puff of smoke, perhaps taking an enduser's work with it.
Bookmarks