keybuk / libnih

NIH Utility Library
GNU General Public License v2.0
90 stars 28 forks source link

nih/logging.c: use our own __nih_abort_msg rather than the (e)glibc symbol #3

Closed xnox closed 1 year ago

xnox commented 11 years ago

1) abort_msg is not available in all libc's 2) when it is available, it creates a tight dependancy between libnih and (e)glibc, requiring libnih to be recompiled against each (e)glibc upload 3) equivalent functionality can be provided by our own implementation on abort_msg. 4) apport in ubuntu has been modifyied to look up crash message from nih_abort_msg in additional to __abort_msg, thus decoupling (e)glibc from libnih

This patch creates our own nih_abort_msg. There are other alternatives that could be implemented (e.g. add a conditional to offer using abort_msg (if available) and select/fallback to __nih_abort_msg. Let me know your thoughts on this.

Bug-Ubuntu: https://bugs.launchpad.net/bugs/997359

keybuk commented 11 years ago

Since the symbol is tagged attribute ((weak)), please give a rationale for why this creates "a tight dependency between libnih and (e)glibc"

adconrad commented 11 years ago

It's potentially a misfeature of dpkg-shlibdeps that it adds a dependency when it can resolve a weak symbol (and skips them when it can't), but I'm not sure I want to think about what deps might break if I "fix" that case to always skip weak references and assume that maintainers will track ABI changes some other way.

Sure, in the case of glibc, that symbol hasn't changed since it was introduced, and probably never will change, but that wouldn't be true of all weakly-referenced symbols in the distro, so I'm not sure fixing it globally wouldn't actually cause more harm than good.

As to why it's an exact dep, it's just sane and good to require an exact dep for private symbols, because we (glibc upstream in this case, yay hat switching) provide no guarantee of ABI stability on private symbols. So, if there's going to be a dep at all, it needs to be fairly tight.

Worth noting that, apparently, RPM doesn't allow linking to GLIBC_PRIVATE symbols at all (weakly or otherwise, AFAIK), which is what led to glib having glib_assert_msg instead of using abort_msg, so there's some precedence for this whole "the path of least resistance is just to use your own symbol and carry on with life", philosophical perfection arguments aside.

keybuk commented 11 years ago

But in this case API stability doesn't matter, because if glibc changes that symbol then the code handles that gracefully.

Worth nothing that Gentoo handles this situation perfectly