[lxc-devel] [PATCH] Link against pthread when not on bionic.

Stéphane Graber stgraber at ubuntu.com
Tue Feb 19 15:43:09 UTC 2013


On 02/19/2013 10:39 AM, Daniel Lezcano wrote:
> On 02/19/2013 04:28 PM, Dwight Engen wrote:
>> On Tue, 19 Feb 2013 10:02:37 -0500
>> Stéphane Graber <stgraber at ubuntu.com> wrote:
>>
>>> On 02/19/2013 09:19 AM, Serge Hallyn wrote:
>>>> Quoting Natanael Copa (ncopa at alpinelinux.org):
>>>>> On Mon, 18 Feb 2013 21:40:42 +0100
>>>>> Daniel Lezcano <daniel.lezcano at free.fr> wrote:
>>>>>
>>>>>> On 02/18/2013 06:23 PM, Stéphane Graber wrote:
>>>>>>> dpkg spotted that we're not explicitly linking against pthread
>>>>>>> even though we use some of its symbols (sem_*).
>>>>>> uh ? wait.
>>>>>>
>>>>>> We shouldn't link against the lib pthread.
>>>>>>
>>>>>> I don't think sem_* is a symbol coming from the pthread library.
>>>>> Seems to be with uClibc:
>>>>>
>>>>> ncopa-desktop:~$ nm -D /lib/libpthread.so.0.9.32 | grep sem_
>>>>> 000000000000d168 T __new_sem_destroy
>>>>> 000000000000a914 T __new_sem_getvalue
>>>>> 000000000000a414 T __new_sem_init
>>>>> 000000000000c219 T sem_close
>>>>> 000000000000d168 W sem_destroy
>>>>> 000000000000a914 W sem_getvalue
>>>>> 000000000000a414 W sem_init
>>>>> 000000000000c744 T sem_open
>>>>> 0000000000006db0 T sem_post
>>>>> 0000000000006e00 T sem_timedwait
>>>>> 0000000000006f80 T sem_trywait
>>>>> 00000000000095c8 T sem_unlink
>>>>> 0000000000006fb0 T sem_wait
>>>>>
>>>>> How about let autoconf detect what to link against?
>>>>>
>>>>> @@ -274,6 +274,9 @@ AC_CHECK_HEADERS([sys/signalfd.h pty.h
>>>>> sys/capability.h sys/ # Check for some syscalls functions
>>>>>  AC_CHECK_FUNCS([setns pivot_root sethostname unshare])
>>>>>  
>>>>> +# find library for sem_*
>>>>> +AC_SEARCH_LIBS(sem_open, [pthread rt])
>>>> I like it.  thanks.
>>> Won't that cause lxc to link against pthread on most distros which
>>> based on the previous e-mails is something we want to avoid?
>> If libpthread is where the symbols are, I don't think we have much
>> choice?
> 
> Yep :s
> 
>>  I think Daniel's concern is that by linking with pthread it may
>> cause users to think liblxc.so is thread safe, when it is not. A
>> question that pops to mind is "how far from thread safe is liblxc?"
> 
> There are few global variables but I am not sure all the glibc functions
> used in the code are threads safe. That should be checked ...
> 
> 
>> FWIW the sem_open man page on Fedora 18 only says "Link with -pthread".
> 
> -pthread is different from -lpthread
> 
> The former will define some env variables used by the glibc (eg. for
> getpid, errno, etc ...) and link with the libpthread. The latter will
> just link with libpthread.
> 
> Yes, but older version use librt.
> 
> IMO, Natanael's patch should do the trick.

Ok. I'll do some tests with his patch, just switching the order so that
if for any reason librt exports the symbol, this will be preferred to
pthread.

I'll then do a quick check to see how much of the hardcoded BIONIC stuff
can be replaced by similar autoconf checks.

>>> I guess we'd want [rt pthread], though as was discussed earlier, it's
>>> very likely that this will fail as for some reason the tools don't see
>>> that librt contains the sem_* symbols.
>>>
>>>>> +
>>>>>  # Check for some functions
>>>>>  AC_CHECK_LIB(util, openpty)
>>>>>  AC_CHECK_FUNCS([openpty hasmntopt setmntent endmntent])
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>> Everyone hates slow websites. So do we.
>>>>> Make your web apps faster with AppDynamics
>>>>> Download AppDynamics Lite for free today:
>>>>> http://p.sf.net/sfu/appdyn_d2d_feb
>>>>> _______________________________________________
>>>>> Lxc-devel mailing list
>>>>> Lxc-devel at lists.sourceforge.net
>>>>> https://lists.sourceforge.net/lists/listinfo/lxc-devel
>>>> ------------------------------------------------------------------------------
>>>> Everyone hates slow websites. So do we.
>>>> Make your web apps faster with AppDynamics
>>>> Download AppDynamics Lite for free today:
>>>> http://p.sf.net/sfu/appdyn_d2d_feb
>>>> _______________________________________________
>>>> Lxc-devel mailing list
>>>> Lxc-devel at lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/lxc-devel
>>>>
>>>
>>
>> ------------------------------------------------------------------------------
>> Everyone hates slow websites. So do we.
>> Make your web apps faster with AppDynamics
>> Download AppDynamics Lite for free today:
>> http://p.sf.net/sfu/appdyn_d2d_feb
>> _______________________________________________
>> Lxc-devel mailing list
>> Lxc-devel at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/lxc-devel
> 


-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 901 bytes
Desc: OpenPGP digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20130219/fd02dc5c/attachment.pgp>


More information about the lxc-devel mailing list