From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 17393 invoked from network); 24 Oct 2020 19:29:16 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 24 Oct 2020 19:29:16 -0000 Received: (qmail 5264 invoked by uid 550); 24 Oct 2020 19:29:14 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 5240 invoked from network); 24 Oct 2020 19:29:13 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rcombs.me; s=google; h=from:content-transfer-encoding:mime-version:subject:date:references :to:in-reply-to:message-id; bh=HjbZ8hZyxX1/ff6rgQ1gsWPcE+SaeCqOrgclun4qJ6Q=; b=q9zfKDmw343ZvJJ5BXnh514Kz1GiBBo6BgcY+dJqgwSjWEMthwfXl6Q5FMdeqVk9vl 8Vl/9mQ2totFLntFPlUOdbUnY6J7UkUcqGGUigwYOvNbbcDB0TFOjYsK5KVVHVMhl/gy lMKOtoSx4BIt96mofadjbGzORKnbIx4SudMwMWo8NGpxZfpa1lzOp3yWrQgK51bYeH/B wsKeghYN6m857F9b+H8ZY8xvflnXdy10O+9XOGJv7mgEA/Cj5Xfj8SmIJdkZxvTTfIZ6 W/PltDgTnI7Hy/tToJct4F4afRj5cQQsh2VmlK3e0ag4QY5+VwsrTiFBrlzlzjim6IxK YnrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:date:references:to:in-reply-to:message-id; bh=HjbZ8hZyxX1/ff6rgQ1gsWPcE+SaeCqOrgclun4qJ6Q=; b=kK6iDWJjRC8v+aksh26/FogZvGvsDUVgCjp5euZCpOY9MKQ77OSlXw+JeJORY1gV1/ e4ACalfJ30XkcePhcHYp9anzYoE5FITi5GDqbqml95xSWK/VJS7thde/IHfmsuCjq9g6 y9oM/PU2bRXIWtoIoU0H2qHAmrJBh3e9skcnwnF0FguZg/vvaEK/2ui5nWT9TjxP13Rp +4cQ0RqFIXxhuRXf/Jf7Lz3JOsPR4Dr28Oat5LGcFM3usc2qkzI3/HcXVH4Z35mk3TAZ YySFdjCCidmasEny7P+BGG3AQBPUeitDNc6jmNbx8pJtzKMRxOV7/2kOlq8W79nYYPl4 IknA== X-Gm-Message-State: AOAM530J92NMcHECpowSlUGKMDRxIrPuruy0R/i07LLD5OYcwO59EEBI YJm0ofhpmnxGskB1RWnT9qHlhcfKyq1V13k= X-Google-Smtp-Source: ABdhPJzBWUqbe8kPjtDwNxn5CbxQC0f0/Cq/oUnDx16mLlJ6aL0dRBXdXIsXf1u6Ug6GW7nigE+hpw== X-Received: by 2002:a92:dcc7:: with SMTP id b7mr5737913ilr.210.1603567741099; Sat, 24 Oct 2020 12:29:01 -0700 (PDT) From: Ridley Combs Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Date: Sat, 24 Oct 2020 14:28:59 -0500 References: <20201024053156.32053-1-rcombs@rcombs.me> <20201024154128.GE534@brightrain.aerifal.cx> To: musl@lists.openwall.com In-Reply-To: <20201024154128.GE534@brightrain.aerifal.cx> Message-Id: X-Mailer: Apple Mail (2.3608.120.23.2.4) Subject: Re: [musl] [PATCH] ldso: notify the debugger when we're doing a dlopen > On Oct 24, 2020, at 10:41, Rich Felker wrote: >=20 > On Sat, Oct 24, 2020 at 12:31:56AM -0500, rcombs wrote: >> Otherwise lldb doesn't notice the new library and stack traces = containing it >> get cut off unhelpfully. >> --- >> ldso/dynlink.c | 9 +++++++-- >> 1 file changed, 7 insertions(+), 2 deletions(-) >>=20 >> diff --git a/ldso/dynlink.c b/ldso/dynlink.c >> index fcc8f6a6..1ab9bf5b 100644 >> --- a/ldso/dynlink.c >> +++ b/ldso/dynlink.c >> @@ -1963,7 +1963,7 @@ void __dls3(size_t *sp, size_t *auxv) >> debug.bp =3D dl_debug_state; >> debug.head =3D head; >> debug.base =3D ldso.base; >> - debug.state =3D 0; >> + debug.state =3D RT_CONSISTENT; >> _dl_debug_state(); >>=20 >> if (replace_argv0) argv[0] =3D replace_argv0; >> @@ -2012,6 +2012,10 @@ void *dlopen(const char *file, int mode) >> pthread_rwlock_wrlock(&lock); >> __inhibit_ptc(); >>=20 >> + int oldstate =3D debug.state; >> + debug.state =3D RT_ADD; >> + _dl_debug_state(); >> + >> p =3D 0; >> if (shutting_down) { >> error("Cannot dlopen while program is exiting."); >> @@ -2104,9 +2108,10 @@ void *dlopen(const char *file, int mode) >> update_tls_size(); >> if (tls_cnt !=3D orig_tls_cnt) >> install_new_tls(); >> - _dl_debug_state(); >> orig_tail =3D tail; >> end: >> + debug.state =3D oldstate; >> + _dl_debug_state(); >> __release_ptc(); >> if (p) gencnt++; >> pthread_rwlock_unlock(&lock); >> --=20 >> 2.17.1 >=20 > This looks good, but saving/restoring oldstate isn't necessary and > doesn't make sense logically. The code here is taking place under an > exclusive lock on the state. The initial state being consistent is a > logical precondition to it, and a requirement for releasing the lock > again when finished. >=20 > Rich Ah, I'd been thinking that dlopen might get called from within a ctor, = but now that I look closer I see those are run after we set the state = back anyway, so yeah this isn't needed.=