Bug 42020 - Please, don't use hash_* namespace/prefix, it is too generic
Summary: Please, don't use hash_* namespace/prefix, it is too generic
Status: RESOLVED FIXED
Alias: None
Product: p11-glue
Classification: Unclassified
Component: p11-kit (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Stef Walter
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-19 15:16 UTC by Andrew W. Nosenko
Modified: 2011-10-24 04:28 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Result of "objdump -T /usr/local/lib/libp11-kit.so" for p11-kit-0.7 on FreeBSD-8.0 (13.30 KB, text/plain)
2011-10-20 03:07 UTC, Andrew W. Nosenko
Details
Result of "nm -BD /usr/local/lib/libp11-kit.so" for p11-kit-0.7 on FreeBSD-8.0 (5.37 KB, text/plain)
2011-10-20 03:13 UTC, Andrew W. Nosenko
Details

Description Andrew W. Nosenko 2011-10-19 15:16:07 UTC
p11-kit uses hash_* namespace for hash related functions.
But it is
1. too generic
2. may clash (and clashes indeed) with other libraries that also don't use library specific namespaces/prefixes.

In my case, the application that uses gnutls and mysql-5.0 crashes at startup.  Just because gnutls uses p11-kit now.  p11-kit defines and exports hash_free(), gnutls calls it by the way.  Mysql-5.0 also defines and exports a bunch of hash_* functions including hash_free().  Now, it's a matter of ls.so implementation how to deal with this collision.  And in my cases mysql won.  Therefore, attempt to initialize gnutls finishes with gnutls' try to call p11-kit's hash_free(), but because of name collision it calls hash_free() from mysql.  Result: SIGSEGV and core dump (if enabled).
Comment 1 Stef Walter 2011-10-19 23:09:06 UTC
None of those functions should be exported by the library. Could you run the following, and post the output?

$ objdump -T /usr/lib/libp11-kit.so
Comment 2 Andrew W. Nosenko 2011-10-20 03:07:12 UTC
Created attachment 52575 [details]
Result of "objdump -T /usr/local/lib/libp11-kit.so" for p11-kit-0.7 on FreeBSD-8.0

Attached.  p11-kit-0.7.  OS: FreeBSD-8.0 (if it has matter).
Comment 3 Andrew W. Nosenko 2011-10-20 03:13:03 UTC
Created attachment 52576 [details]
Result of "nm -BD /usr/local/lib/libp11-kit.so" for p11-kit-0.7 on FreeBSD-8.0

Result of "nm -BD /usr/local/lib/libp11-kit.so" attached also, just for any case.
Comment 4 Stef Walter 2011-10-20 05:14:53 UTC
p11-kit is explicitly built so the following symbols are exported:

 * Functions beginning in p11_kit_
 * the C_FunctionGetList symbol

FreeBSD doesn't seem to be respecting our -export-symbols-regex build options. See http://cgit.freedesktop.org/p11-glue/p11-kit/tree/p11-kit/Makefile.am#n42

Are you the p11-kit freebsd port maintainer? It would be worth working with him to try and get this to build correctly.
Comment 5 Andrew W. Nosenko 2011-10-20 06:41:39 UTC
: Are you the p11-kit freebsd port maintainer?

No.  I'm just a user.  Maintainer is novel@FreeBSD.org

: It would be worth working with him to try and get this to build correctly.

Thanks!
Comment 6 Stef Walter 2011-10-20 06:56:14 UTC
(In reply to comment #5)
> : Are you the p11-kit freebsd port maintainer?
> 
> No.  I'm just a user.  Maintainer is novel@FreeBSD.org
> 
> : It would be worth working with him to try and get this to build correctly.
> 
> Thanks!

Thanks. If you or the maintainer have figured out how I can adjust the build so that only the correct symbols are exported on FreeBSD, then please send me patches to include.

And if there really is no way fix the build easily, then I'll go through and rename things.
Comment 7 Andrew W. Nosenko 2011-10-20 08:36:41 UTC
Use GCC __attribute__((visibility ("hidden"))) ?
Or, what is essencially the same, turn on the "hidden" visibility by default and show selected symbols through __attribute__((visibility ("default"))) ?
Comment 8 Stef Walter 2011-10-20 10:38:31 UTC
That's a GCC specific solution, and p11-kit is the sort of thing that should work with other compilers as well. I'll think about this some more...
Comment 9 Stef Walter 2011-10-23 23:07:50 UTC
Should be fixed now with this commit.

commit 5507dc4946f0a68cece5ec9e7096e0f9b8c55984
Author: Stef Walter <stefw@collabora.co.uk>
Date:   Mon Oct 24 08:05:43 2011 +0200

    Rename non-static functions to have a _p11_xxx prefix.
    
     * Work around issues with brain-dead linkers not respecting
       the libtool -export-symbol-regex argument
    
    https://bugs.freedesktop.org/show_bug.cgi?id=42020
Comment 10 Andrew W. Nosenko 2011-10-24 04:28:49 UTC
Thanks!


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.