From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#54501: Segfault on recursive structure Date: Fri, 25 Mar 2022 16:34:30 +0100 Message-ID: <87v8w2dp15.fsf@gnus.org> References: <87cziekpwk.fsf@gnus.org> <87y212do7y.fsf@igel.home> <874k3qkozw.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19251"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: 54501@debbugs.gnu.org To: Andy Gaynor Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Mar 25 16:35:19 2022 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 1nXly7-0004dj-4c for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 25 Mar 2022 16:35:15 +0100 Original-Received: from localhost ([::1]:53106 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nXly5-0006ms-TQ for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 25 Mar 2022 11:35:13 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:44982) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nXlxu-0006mS-LW for bug-gnu-emacs@gnu.org; Fri, 25 Mar 2022 11:35:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58313) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nXlxu-0001eE-Bi for bug-gnu-emacs@gnu.org; Fri, 25 Mar 2022 11:35:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nXlxu-0001Ek-9I for bug-gnu-emacs@gnu.org; Fri, 25 Mar 2022 11:35:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 25 Mar 2022 15:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54501 X-GNU-PR-Package: emacs Original-Received: via spool by 54501-submit@debbugs.gnu.org id=B54501.16482224804701 (code B ref 54501); Fri, 25 Mar 2022 15:35:02 +0000 Original-Received: (at 54501) by debbugs.gnu.org; 25 Mar 2022 15:34:40 +0000 Original-Received: from localhost ([127.0.0.1]:52205 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nXlxX-0001Dk-SF for submit@debbugs.gnu.org; Fri, 25 Mar 2022 11:34:40 -0400 Original-Received: from quimby.gnus.org ([95.216.78.240]:42728) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nXlxW-0001DX-EJ for 54501@debbugs.gnu.org; Fri, 25 Mar 2022 11:34:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=tuEzbgmQA5412LISLz446gyiWh4WFZeISbZysdvYTNg=; b=bwaRJm01nD5zl3mh4EbstcB9+Z WGKuFz6ywAGoxhDG27iSg6ceppPVqqz4TZh8lT7kX34YyJw0OK9++cLqF2W7mAVnZiswTFKUytBVK hS3ePxGn1xeK7/h0J/FqqdrvMw0WLlFuowZkDKEhDs8vFOjgKiq4ejlvjAUY3NqCSsNo=; Original-Received: from [84.212.220.105] (helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nXlxP-0004Nx-06; Fri, 25 Mar 2022 16:34:32 +0100 In-Reply-To: (Andy Gaynor's message of "Wed, 23 Mar 2022 16:24:05 +0100") 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:228947 Archived-At: (Re-sending for the bug tracker.) Andy Gaynor writes: >> #0=#0# = (nil) > > This error is intrinsic to the process, much like the first time Scheme > sees (define z z). It probably needs to be checked explicitly--when > first defining a label, its value cannot be a reference to that label. > If the label is already defined, dandy, nothing to check or initialize. > > That (nil) = (nil . nil) looks suspiciously stubby. (Nil nil nil, so > much nil in the world, the most distinguished value in the language, > tossed around so casually.) I wouldn't be surprised to learn that it's > an optimization, a speculative initialization favoring the common case of > defining a label to a pair. I could be wrong. Hmmm, (#0=3 #0=#0#) is > well-defined, and should be (3 3). Or prohibited for no good reason, > which seems to be the trend nowadays. Prohibiting this is consistent > with prohibiting assignments and restricting alists to only allow one > association per key. Stupid. (Oh, did I write that out loud?) > > In Emacs, (#0=3 #0=#0#) = (3 (nil)), ung, (nil . nil) again. Given that > [#0=3 #0=#0#] = [3 3] and #s(#0=Z #0=#0#) = #s(Z Z), I'm more inclined to > call this another pair-handling error. > >> Emacs segfaults on trying to gc a number of recursive objects, >> but #0=[#1=(#0# . #1#)] seems to actually segfault in the reader. >> Is it obvious to anybody why? > > Perhaps this instance is more... distilled. Both objects are labeled, > both labels are used, all components are labels, and one is self-cyclic. > Note that the expression crashes when either pair component is > self-cyclic, and doesn't crash when- Strike that, let's start with simple > and work our way up. > > #0=(#0# . #0#) = #1=(#1# . #1#) = ok > > #1=#0=[#0# #0#] = #1=[#1# #1#] = ok > #1=#0=(#0# . #0#) = (#1=(#1# . #1#) . #1#) = bad > > #2=#1=#0=[#0# #0#] = #1=[#1# #1#] = ok > #2=#1=#0=(#0# . #0#) -> (#1=(#1# . #1#) . #1#) = bad > > Another bug manifesting for pairs and not other stuff? I'm satisfied. > > I haven't looked inside Emacs yet, but usually, most types are treated > much the same, but pairs are augmented with optimizations for lists, > making them more complicated. Heck, in my still-skeletal fasl, arrays > are handled with 4 instructions, the model-to-be for most referential > types. However, pairs/lists have 11 instructions, handling list and > list* under various conditions (automatically selected, of course). I > added the list optimizations very early, in near isolation, because this > is subtle business. > > I just polled 24 Lisps. 9 didn't implement labels. 2 gave me guff > (dammit Racket and a no-name), so screw 'em. Of the 13 left, the same 5 > flubbed label-thyself and relabel-thyself. 4 flubbed #0=(#0# . #0#), and > 3 flubbed #0=[#1=(#0# . #1#)]. The point, oh yeah. These folks are > skilled programmers on familiar turf and still have problems. Being a > GNU venue, I'll mention that GCL failed to build (incorrectly setting > things up for signal.h?) and Guile flubbed all four tests. > > Other than the label issues and pairs/lists going to hell in a humv, do > things seem ok? I just fed emacs a lot of funk, but with no pairs/lists > or fringe label cases, and everything worked. I recommend running with > that, which seems safer than trying to debug something unfamiliar that > trips up everyone. Make a working copy of read. Completely remove any > handling for pairs/lists, label stubs, whatever. Make labels nice, work > the kinks out of the fringe cases. Add pairs back generically, coded > much like everything else--no label or list optimizations. When you've > got it right, commit to the copy. The snipped optimizations can be > snarfed from a trusted source (no guff or flubs from Bigloo, Chez, Clisp, > Gambit, Gauche, Kawa, SBCL) at your convenience. Kawa was the one that > retained label redefinitions, making it worth a peek. > > Regards, Andy