From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 114285 invoked by alias); 19 Nov 2019 15:57:21 -0000 Mailing-List: contact elfutils-devel-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: elfutils-devel-owner@sourceware.org Received: (qmail 114248 invoked by uid 89); 19 Nov 2019 15:57:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.100.3 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-6.5 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.1 spammy= X-Spam-Status: No, score=-6.5 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on sourceware.org X-Spam-Level: X-HELO: gnu.wildebeest.org Received: from wildebeest.demon.nl (HELO gnu.wildebeest.org) (212.238.236.112) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 19 Nov 2019 15:57:18 +0000 Received: from tarox.wildebeest.org (tarox.wildebeest.org [172.31.17.39]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id 5866A302BBFD; Tue, 19 Nov 2019 16:57:15 +0100 (CET) Received: by tarox.wildebeest.org (Postfix, from userid 1000) id 6986E413CEAA; Tue, 19 Nov 2019 16:57:15 +0100 (CET) Message-ID: <7ca3cc662684459fe21801344f0899f5108a8a70.camel@klomp.org> Subject: Re: patch 1/2 debuginfod client From: Mark Wielaard To: "Frank Ch. Eigler" Cc: elfutils-devel@sourceware.org, amerey@redhat.com Date: Tue, 19 Nov 2019 15:57:00 -0000 In-Reply-To: <20191118203324.GD2880@redhat.com> References: <20191028190438.GC14349@redhat.com> <20191028190602.GD14349@redhat.com> <9bc154bce6389be9b07f2db9dcdcc605ad4f39e3.camel@klomp.org> <20191113232456.GA31583@redhat.com> <6d7430368a18c943f72bc3583efeafb2c192516f.camel@klomp.org> <20191116185256.GB19543@redhat.com> <356e88e4937ddb97a3e7cc93dbdfe29239ff960e.camel@klomp.org> <20191118203324.GD2880@redhat.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Evolution 3.28.5 (3.28.5-5.el7) Mime-Version: 1.0 X-Spam-Flag: NO X-IsSubscribed: yes X-SW-Source: 2019-q4/txt/msg00180.txt.bz2 Hi, On Mon, 2019-11-18 at 15:33 -0500, Frank Ch. Eigler wrote: > > > > Do you know how other libraries that use libcurl deal with this? > > >=20 > > > I looked over some other libcurl users in fedora. Some don't worry > > > about the issue at all, relying on implicit initialization, which is > > > only safe if single-threaded. Others (libvirtd) do an explicitly > > > invoked initialization function, which is also only safe if invoked > > > from a single-threaded context. > > >=20 > > > I think actually our way here, running the init function from the > > > shared library constructor, is about the best possible. As long as > > > the ld.so process is done as normal, it should be fine. Programs that > > > use the elfutils trick of manual dlopen'ing libdebuginfod.so should do > > > so only if they are single-threaded. > >=20 > > But they cannot really control that... Since they might not know (and > > really shouldn't care) that libdw lazily tries to dlopen > > libdebuginfod.so which then pulls in libcurl and calls that global init > > function... > >=20 > > Could we do try to do the dlopen and global curl initialization from > > libdw _init, or a ctor, to make sure it is done as early as possible?=20 >=20 > Doing a redundant initialization later is not a problem; there is a > counter in there. The problematic case would be > - a multithreaded application > - loading debuginfod.so multiply concurrently somehow > - and calling the solib ctor concurrently somehow > - and all of this concurrently enough to defeat libcurl's init-counter >=20 > IMHO, not worth worrying about. Someday libcurl will do the right > thing (tm) and plop this initialization into their solib ctor. I do worry about this because any multi-threaded app that uses libdw.so might cause trouble because we dlopen libdebuginfod.so lazily and then it will call curl_global_init () which explicitly says: This function is not thread safe. You must not call it when any other thread in the program (i.e. a thread sharing the same memory) is running. This doesn't just mean no other thread that is using libcurl. Because curl_global_init calls functions of other libraries that are similarly thread unsafe, it could conflict with any other thread that uses these other libraries. That is why I think doing the dlopen of libdebuginfod.so eagerly from a libdw.so constructor function or _init might be necessary to make sure no other threads are running yet. > > > > I was more thinking zero =3D=3D infinity (no timeout). > > >=20 > > > An unset environment variable should do that. > >=20 > > Are you sure? If DEBUGINFOD_TIMEOUT isn't set, then it seems it > > defaults to 5 seconds: > >=20 > > /* Timeout for debuginfods, in seconds. > > This env var must be set for debuginfod-client to run. */ > > static const char *server_timeout_envvar =3D > > DEBUGINFOD_TIMEOUT_ENV_VAR; > > static int server_timeout =3D 5; > > [...] > >=20 > > if (getenv(server_timeout_envvar)) > > server_timeout =3D atoi (getenv(server_timeout_envvar)); >=20 > OK, hm, we could make an -empty- but set environment variable mean > 'infinity'. Then again, a user can also say =3D99999. Yes. In this case even setting it to 600 probably feels like forever anyway since someone is waiting on the file... :) Cheers, Mark