From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Pip Cet Newsgroups: gmane.emacs.bugs Subject: bug#39962: 27.0.90; Crash in Emacs 27.0.90 Date: Fri, 13 Mar 2020 13:56:07 +0000 Message-ID: References: <24162.58107.725366.668639@cochabamba.vanoostrum.org> <329e58b1-6255-311e-bdd8-b6f5b3d5208f@cs.ucla.edu> <22225b66-44f6-d132-3036-92181d53c28d@cs.ucla.edu> <89A83582-358F-43DC-B96E-04EE9D655D5F@vanoostrum.org> <63b88e2d-9888-f3ce-a4b0-fcf344e803e5@cs.ucla.edu> <83d09lbgk5.fsf@gnu.org> <837dzqaieq.fsf@gnu.org> <834kuuadod.fsf@gnu.org> <83blp1siku.fsf@gnu.org> <83o8t08ufp.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="45789"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 39962@debbugs.gnu.org, pieter-l@vanoostrum.org, eggert@cs.ucla.edu To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Mar 13 14:58:48 2020 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 1jCkpq-000Bln-Gx for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 13 Mar 2020 14:58:46 +0100 Original-Received: from localhost ([::1]:59250 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jCkpp-0001md-Jg for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 13 Mar 2020 09:58:45 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37288) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jCkoC-0003VP-3n for bug-gnu-emacs@gnu.org; Fri, 13 Mar 2020 09:57:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jCkoA-0001St-En for bug-gnu-emacs@gnu.org; Fri, 13 Mar 2020 09:57:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54119) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jCkoA-0001Rf-AX for bug-gnu-emacs@gnu.org; Fri, 13 Mar 2020 09:57:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jCkoA-00046M-AH for bug-gnu-emacs@gnu.org; Fri, 13 Mar 2020 09:57:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Pip Cet Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 13 Mar 2020 13:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 39962 X-GNU-PR-Package: emacs Original-Received: via spool by 39962-submit@debbugs.gnu.org id=B39962.158410781315750 (code B ref 39962); Fri, 13 Mar 2020 13:57:02 +0000 Original-Received: (at 39962) by debbugs.gnu.org; 13 Mar 2020 13:56:53 +0000 Original-Received: from localhost ([127.0.0.1]:60092 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jCko0-00045y-NS for submit@debbugs.gnu.org; Fri, 13 Mar 2020 09:56:53 -0400 Original-Received: from mail-ot1-f51.google.com ([209.85.210.51]:39252) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jCknx-00045l-Vn for 39962@debbugs.gnu.org; Fri, 13 Mar 2020 09:56:50 -0400 Original-Received: by mail-ot1-f51.google.com with SMTP id a9so10155798otl.6 for <39962@debbugs.gnu.org>; Fri, 13 Mar 2020 06:56:49 -0700 (PDT) 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=J/nY0mqXNID6NfakzrBH2UQapqhk3/n2/XjNsPY9j7A=; b=dBQEpEuI54wfNvOz0cpHZUe5j4WPqde97Nk0WifmcggFTM+cEvjDiJShd9Y9GHsQ4W eB8AaLJPyVEv5ZBcF+HZDRwRuJ5cuGY/p+cPUBTDN8VtUOSM01JsncPXdREBb2/pn8lU TAq+TrwUbjpdik511ndnGNsc3uL0ByK6/p7+VGavR2SXikKdB9DQ4tTvoqI7iiv10IB5 AU6PWanLSX1gdely807lwgZDAzeiTXQcBn7tF21fFDv3kTRsT82NndZMEdn/Ib6bIKs0 26j1WFDSn9uSYlr7AJyfOUW4U3YFLOKkmdt7810BMxp6dbSrpnvZbyzBSCUlDKhuU2Yq 9GyA== 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=J/nY0mqXNID6NfakzrBH2UQapqhk3/n2/XjNsPY9j7A=; b=VjyN6JlsLcjk4OOlQQ45/CfjVvqPoB1/ZjN6UW6hVRNRHJA/PrCAL93cIwNFq8GnKq UitBOxyuGkyisVjl9qv3QYqp2FUmyrNvRdRgkRrfL+3sy0oSKlb24wNxnNoLEEu8EXoC A7FOH7j+RuL8l+xnagNDA6nKI1VcVny1CbaN9wsM+WbUwpqz4NWxeWc84k2rnePUk7DC e0auSSFm2eogMvNjC5uXri6Y6sbx5Gk9fhJ603exivBiAWAMgEO0fVqQ/D0Le9dQBu/m +Ir30ja9/Bj/VyMLMDxiq07ru71XXj1NXJWOVNOiVGhCU5+IUUt0MYyQ8hwv04M645pE LF/A== X-Gm-Message-State: ANhLgQ3e/o2Q76pFHPRDF1IQbmmIcogKIZAPrAlpY7duGCRIM0oy3+du 79piFT24FHToD5kBAE16hMz8ls6LvSlIsCq4P9c= X-Google-Smtp-Source: ADFU+vvareakgmSGjOoDC24YZQtNAysScb5SvLMVW2XYlxS6nykeAnzPmbjrpRpecH6zYDHV1Nz4uLwsKrrpeBQDNU0= X-Received: by 2002:a05:6830:11:: with SMTP id c17mr10706139otp.292.1584107804093; Fri, 13 Mar 2020 06:56:44 -0700 (PDT) In-Reply-To: <83o8t08ufp.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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:177272 Archived-At: On Fri, Mar 13, 2020 at 9:40 AM Eli Zaretskii wrote: > > > > It doesn't affect visible behavior of any callers, except in the case > > > > where the previous behavior was buggy. > > > > > > I guess we have different notions of "visible" > > > > Please say something about your notion of "visible". It doesn't affect > > any of the existing C callers of valid_lisp_object_p. Are you talking > > about printing valid_lisp_object_p(x) in a debugger, and not getting > > the expected value? Or something else? > > I'm talking about the behavior documented in the commentary. You're right if your point is the comment should be adjusted to omit the unnecessary, and unused, special behavior on killed buffers. > > > and "buggy". > > > > It avoids segfaults or random memory corruption. How is that not "buggy"? > > That's not the issue here. You said the proposed change didn't change > the behavior "except where it was buggy"; I'm saying that it changes > the behavior unrelated to this bug, where previous behavior was not > buggy by any measure. How so? Can you describe a scenario in which Emacs would behave at all differently? valid_lisp_object_p returns a different value, sure; but none of its callers care about the difference, so Emacs behavior overall does not change. > So why does it not consider the buffer reachable in this case? The > call to live_buffer_p is just one attempt to identify it as reachable; > there are (or at least should be) others. I don't think there are, no. This is the one shot we get at protecting a stack slot that might contain the sole reference to a killed buffer. > > valid_lisp_object_p is currently documented to return 2 for a killed > > buffer and 1 for a live buffer, which is weird since they're both > > valid. It also returns 1 for some fake objects which aren't actually > > valid: > > > > (gdb) p current_thread->m_current_buffer > > $3 = (struct buffer *) 0x555556694b10 > > (gdb) p valid_lisp_object_p(0x555556694b15) > > $4 = 1 > > (gdb) p valid_lisp_object_p(0x555556694b25) > > $5 = 1 > > Why do you consider this incorrect? The Emacs GC is "conservative", > which means it doesn't collect anything that _might_ be a valid Lisp > object. In what ways does the above violate that contract? GC is conservative; valid_lisp_object_p is documented to be precise: a return value of 1 or 2 means that the object is valid, not that it's potentially valid and potentially nonsense. > > If a buffer has been killed but is reachable only through > > mark_maybe_object, we fail to mark it. > > > > We should mark it. In fact, whether a buffer object is marked should > > depend only on whether it's reachable, not whether it's "live" in some > > other sense. > > > > That's all my patch does. > > Your patch modifies the notion of whether a buffer is "live", No, it modifies a specific function (mis)named buffer_live_p. The dozens of places in which we check whether a buffer is "live", as opposed to "killed", are unaffected. Only GC is affected. > on the > assumption that this is the root cause of the failure to mark it. I'm not sure about the philosophical implications of "root cause", but this is a very obvious bug. > But do we have any evidence that this is the root cause? What kind of evidence do you want? A buffer should be marked iff it is reachable A buffer is marked iff it is reachable from the heap or it is reachable from the stack and buffer_live_p returns true Therefore, it is invalid for buffer_live_p to return false for a buffer which is reachable from the stack. > Moreover, by disregarding the indication of a killed buffer, doesn't > your patch cause us not to GC killed buffers even though they are > unreachable, or at least create a danger that we would? Only in the rare case that they appear to be reachable through a stack reference but actually aren't, but that's just the price we pay for conservative GC. > The way to understand what happened in your test case is to figure out > how come the buffer was not found to be reachable via any other > approach the GC makes. There is no other approach. > For example, shouldn't we have this buffer > somewhere on the stack? Precisely. > if so, how come stack marking didn't find it? Because we are talking about the stack marking! The stack marking calls buffer_live_p to check whether it should actually mark the buffer or not. > And if we don't have it on the stack, why not? We do. > > How about we put out the fire rather than waiting to see whether it > > causes any damage? > > The disagreement is whether there's fire, not whether we should put it > out if there is. You've shown that you can start a fire if you want, > but not that the fire is already out there, burning. E.g., I see no > reason for some Lisp program to do what your test case does, it simply > makes no sense. How does it not make sense? We kill a buffer and return it. > > And, if we can agree to do so, what would you like a patch which is > > actually meant for inclusion into the emacs-27 branch (my previous > > patch wasn't, obviously) to look like? > > If it isn't clear, I'm saying that your proposed patch is not > necessarily TRT for master, either. I'd like to see more analysis of > what exactly happens in that case, and why, along the above-mentioned > lines, before I make up my mind. It's certainly not the right thing for master! Using "live" in two different senses like that is way too confusing for a code base that is still being worked on. Again, I think we're being distracted from a very simple issue: stack marking relies on recognizing reachable objects. Reachable objects are called "live" in GC code, so the stack marking code that calls buffer_live_p clearly expects a return value indicating whether the pointer it passed in points into a buffer object; it doesn't, and shouldn't, care whether that buffer has been killed or not.