From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Andrea Corallo via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#46256: [feature/native-comp] AOT eln files ignored if run from build tree Date: Mon, 08 Mar 2021 15:02:58 +0000 Message-ID: References: <86wnutogrh.fsf@gmail.com> <86wnut8fb9.fsf@gmail.com> <861rd1tbpa.fsf@gmail.com> <83pn0km6y3.fsf@gnu.org> <86ft1f8ara.fsf@gmail.com> <83sg5cjdn8.fsf@gnu.org> <83r1kwjcy2.fsf@gnu.org> <8335x6u9o4.fsf@gnu.org> <83zgzesrku.fsf@gnu.org> <83tupms4mp.fsf@gnu.org> Reply-To: Andrea Corallo Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15477"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Eli Zaretskii , andrewjmoreton@gmail.com, 46256@debbugs.gnu.org To: Pip Cet Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Mar 08 16:04:13 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lJHQa-0003rv-FT for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 08 Mar 2021 16:04:12 +0100 Original-Received: from localhost ([::1]:36072 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJHQZ-0003Fs-Fg for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 08 Mar 2021 10:04:11 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45282) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJHQQ-0003DK-0X for bug-gnu-emacs@gnu.org; Mon, 08 Mar 2021 10:04:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:32970) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lJHQP-0008Rf-Pd for bug-gnu-emacs@gnu.org; Mon, 08 Mar 2021 10:04:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lJHQP-0004V5-Kx for bug-gnu-emacs@gnu.org; Mon, 08 Mar 2021 10:04:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Andrea Corallo Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 08 Mar 2021 15:04:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46256 X-GNU-PR-Package: emacs Original-Received: via spool by 46256-submit@debbugs.gnu.org id=B46256.161521578517218 (code B ref 46256); Mon, 08 Mar 2021 15:04:01 +0000 Original-Received: (at 46256) by debbugs.gnu.org; 8 Mar 2021 15:03:05 +0000 Original-Received: from localhost ([127.0.0.1]:44516 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lJHPV-0004Te-Km for submit@debbugs.gnu.org; Mon, 08 Mar 2021 10:03:05 -0500 Original-Received: from mx.sdf.org ([205.166.94.24]:58762) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lJHPQ-0004T8-BX for 46256@debbugs.gnu.org; Mon, 08 Mar 2021 10:03:04 -0500 Original-Received: from mab (ma.sdf.org [205.166.94.33]) by mx.sdf.org (8.15.2/8.14.5) with ESMTPS id 128F2wQi024246 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits) verified NO); Mon, 8 Mar 2021 15:02:59 GMT In-Reply-To: (Pip Cet's message of "Mon, 8 Mar 2021 10:45:49 +0000") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:201839 Archived-At: Pip Cet writes: > On Mon, Mar 8, 2021 at 10:14 AM Andrea Corallo wrote: >> Hi Pip, >> >> thanks for the analysis, I'm not sure I followed 100% so I'll repeat to >> make sure we are on the same page, please correct me in case. > > Thanks for that! > >> IIUC (and make sense to me) the issue is that we are leaving two pointer >> pointing to the same handle: One is in the CU_2 allocated by >> 'Fnative_elisp_load' and later discarded by 'load_comp_unit' when >> reloading the same filename. The other is the original CU_1 created the >> first time this filename was loaded. >> >> When CU_2 will be GC'ed because discarded we'll get the problem because >> we'll dlclose the handle. Is this correct? > > CU_1 is GC'ed first. CU_2, for whatever reason, isn't GC'ed in the same cycle. > >> In case isn't the attached curing the issue as well? > > I don't think so. The problem is that we have an invalid Lisp_Object > in the shared library, not that we're calling dlclose() too often.. > > Again, there's no real cost to fixing this: at best, we avoid a > catastrophic use-after-free. At worst, we nulled out a word of memory > only for it to be unmapped a moment later, no harm done. > >> PS I couldn't reproduce using the lisp reproducer both on my 64bit both >> on my 32bit system (I left it looping for a while), is that reproducer >> working for you? > > Have you modified dynlib_open() to leak the shared object? That's what > I think might be happening for Eli, so it makes sense to test with a > double dlopen() call, as I did. No, because I failed to understand why calling 'dlopen' two times in a row on the same filename should make any difference as I expect the second call to just return the same handle as the first. I'm sure I'm missing something here or I misunderstood your suggestion: > I can reproduce this issue by replacing the single call of dlopen() in > dynlib_open with two calls Thanks Andrea