From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Pip Cet Newsgroups: gmane.emacs.bugs Subject: bug#46256: [feature/native-comp] AOT eln files ignored if run from build tree Date: Mon, 8 Mar 2021 10:45:49 +0000 Message-ID: References: <83h7m84h9g.fsf@gnu.org> <86v9ao5czu.fsf@gmail.com> <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> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34667"; mail-complaints-to="usenet@ciao.gmane.io" Cc: andrewjmoreton@gmail.com, 46256@debbugs.gnu.org To: Andrea Corallo Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Mar 08 11:47:11 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 1lJDPp-0008t6-V1 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 08 Mar 2021 11:47:09 +0100 Original-Received: from localhost ([::1]:43026 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJDPp-0002g6-1N for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 08 Mar 2021 05:47:09 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42836) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJDPh-0002ed-W1 for bug-gnu-emacs@gnu.org; Mon, 08 Mar 2021 05:47:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58904) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lJDPh-0005CF-OC for bug-gnu-emacs@gnu.org; Mon, 08 Mar 2021 05:47:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lJDPh-0003mM-Jk for bug-gnu-emacs@gnu.org; Mon, 08 Mar 2021 05:47:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Pip Cet Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 08 Mar 2021 10:47: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.161520039314489 (code B ref 46256); Mon, 08 Mar 2021 10:47:01 +0000 Original-Received: (at 46256) by debbugs.gnu.org; 8 Mar 2021 10:46:33 +0000 Original-Received: from localhost ([127.0.0.1]:42217 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lJDPF-0003ld-GL for submit@debbugs.gnu.org; Mon, 08 Mar 2021 05:46:33 -0500 Original-Received: from mail-ot1-f54.google.com ([209.85.210.54]:40254) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lJDPE-0003lP-5h for 46256@debbugs.gnu.org; Mon, 08 Mar 2021 05:46:32 -0500 Original-Received: by mail-ot1-f54.google.com with SMTP id b8so8710879oti.7 for <46256@debbugs.gnu.org>; Mon, 08 Mar 2021 02:46:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=IqIGNIyahE4o3NRt+ifZmyU9MWdiamly1qR+yd8d/EU=; b=fzDMjWxmHt7/nUWQLSYkjcZrvOXNSjdHnu86Oc37V0KgTGvztiLenaYd8gS2nhcgWS AelRFMYoSiV+YMB4x0w+rtqwSc7gWWdPdyBe+F8XYMblBQFol2Tfm3ZVzRPMXgcHJuWv nNaTb4Swqfta5so4o5b3P9oTzD8cYQnEhxRyBZmkfGFTgljG870dsjNdN1qm56yoP+In zcL+5UOcE10wputcZWcKPqg+ofKRu6XZ2Jt+doNvTIKwdOXAtKChpccoQuZLyfzaD7VJ VOajzDY3SGVJbaD2P5YyzbkUxpfmRxwBDHeulkbql5W31ljOZxyf/HqH05GKDd9nPc1D SMZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=IqIGNIyahE4o3NRt+ifZmyU9MWdiamly1qR+yd8d/EU=; b=EzHR5VfKOr5XOZqqClTOjwq9DrTTLbMEiBcU5nrn1hphYNFEkODRZMZlCUjb4Wl5w3 XAXZyQuF2Ayq+QMnUXCbn8PNigJISAfyDeQm2jGx20RGay9xju3I0Rc9+TO5vAxdBUjk rLJj8kYeFCEc+PINBVxlDyyX2uk4rIAXQtsLJ7S4LEQlYjeiH2ZgGuwSPuE2xcSXxZUk UvJyG0OHbsy62mxfMqwSNd08oYLz2KeHnOvNR/5MsNiSKZf53DB1G/a7eqlQcV0znp1s MgWQNZvhJPLJiVQuYhbCA6j4MS7JyYcTlryvN9c7QWjXBIIVW5FQpbnXFveth+m7MkH4 vP+A== X-Gm-Message-State: AOAM531T5eUCkb6Htf+HxBdJ3KqwNl6UDLIKGhfA9ukkMSiIXbge0v0t S+1zTBezR4SuaHspnz7TptuvLaYHDsnzhs1B3mQ= X-Google-Smtp-Source: ABdhPJyv1OH5OygfOfxtKn6g9E6UkbGB2VTsRPHFOd+13l9Bw0YGdhI+gfM13d1uuQBOYFJ9mo2gH7aP2d9X0JWAGD8= X-Received: by 2002:a9d:6e8d:: with SMTP id a13mr3981870otr.287.1615200386494; Mon, 08 Mar 2021 02:46:26 -0800 (PST) In-Reply-To: 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:201819 Archived-At: 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. FWIW, I suspect the reproducer should crash with your patch applied, but I can't test right now :-) Thanks Pip