From owner-freebsd-threads@FreeBSD.ORG Sat Sep 27 08:36:28 2014 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 304089D4 for ; Sat, 27 Sep 2014 08:36:28 +0000 (UTC) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 97022F68 for ; Sat, 27 Sep 2014 08:36:27 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.9/8.14.9) with ESMTP id s8R8aLZq054030 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 27 Sep 2014 11:36:21 +0300 (EEST) (envelope-from kostik@tom.home) DKIM-Filter: OpenDKIM Filter v2.9.2 kib.kiev.ua s8R8aLZq054030 Received: (from kostik@localhost) by tom.home (8.14.9/8.14.9/Submit) id s8R8aL0b054029; Sat, 27 Sep 2014 11:36:21 +0300 (EEST) (envelope-from kostik) Date: Sat, 27 Sep 2014 11:36:21 +0300 From: Konstantin Belousov To: Guillaume Friloux Subject: Re: Segfault from libthr.so. Message-ID: <20140927083621.GJ8870@kib.kiev.ua> References: <20140926150001.GF7885@Jetdail> <20140926164306.GE8870@kib.kiev.ua> <20140927065556.GH7885@Jetdail> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20140927065556.GH7885@Jetdail> User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on tom.home Cc: freebsd-threads@freebsd.org X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Sep 2014 08:36:28 -0000 On Sat, Sep 27, 2014 at 08:55:56AM +0200, Guillaume Friloux wrote: > On 14/09/26, Konstantin Belousov wrote: > > So, what is the problem, from your PoV ? > > Linking libssp after libthr causes libssp constructors run before > > libthr initialization, which causes the behaviour you see. The libssp > > uses something which is interposed by libthr, but still not ready at > > the libssp init time. Your example of linking with different order > > demostrates you the right way to treat libthr. > > > > So again, what is the problem ? > > Sorry to disturb you again, but i would have more access to your knowledge. > I understand what you say, but in my case, it disturbs me a little. > > Lets take this project as example : https://github.com/gfriloux/botman > > As you can see, it uses an m4 macro that will force link to ssp (configure.ac:38). > Later on, deps will be declared (configure.ac:87). One of those deps is eina. > Eina will declare -lpthread from its .pc file. > > And this is how i get to the state of having -lssp -lpthread. So this is right order. > In my app, i dont directly start any thread, lower libs do. So it doesnt seem > logical to add -lpthread before declaring the deps. > So should i just remove this m4 macro that seems to be use on quite some projects, > so it works on BSD ? > > What is the best way to do it, in your opinion ? Just put -lpthread last in the command line (automake variable) for linker. This should work portable on all systems I know.