From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id AABCB383065A for ; Mon, 6 Jun 2022 23:01:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AABCB383065A Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-658-UQXd85Y4Mw2l1_QPlzLDWw-1; Mon, 06 Jun 2022 19:01:32 -0400 X-MC-Unique: UQXd85Y4Mw2l1_QPlzLDWw-1 Received: by mail-qk1-f199.google.com with SMTP id i5-20020a05620a404500b006a6d7a765d9so80153qko.7 for ; Mon, 06 Jun 2022 16:01:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=Aw7YBe5Vx9ynF2WHApb3kFhljImYufvgXuc5bz8hHss=; b=NMMpmBO4UQQY0R4/HgKTEpFtmSBHGc707uObx0tuZ7auggvDrHYyRLt+Yi1i8vu2u4 H1reuYlM1Kgc0jm54EojJhYWUi1JEXI7MugzyxrzBcOmzN052VLOOz5y5QMYsLelb/Oi yohdu2CjLEX6n9KxU0uy7GlZJO0v4lbeAEJgzG24OzPh+ITAn1Mj4RA0vgsaLXqADWvA lBKHRHkN6dNngE4szcwjTfTld8BqImuBhfYqPU1ZCphCnauD2snoNCkmeGnvggTQD4uc Nlb6p9mYvGKHsOsIPx9pyIkM3oOc6VzYdPkLJvjUQJuBkXomrozrKkf2r8E2htmKiC9O WBUw== X-Gm-Message-State: AOAM533oCq5QjctN8ce/kxehyLejeMP+9R2Ujftbi49+h3ZcFVPsZq9j qHVjiBtgumCu/eYVt08sEVeV0Yr6I3wfvxRyThryEYw93vuyNXFmwaHLz2uSIZyFRpvRxcUxob/ Zr1dtNwU= X-Received: by 2002:a05:622a:4c9:b0:304:b650:683d with SMTP id q9-20020a05622a04c900b00304b650683dmr20463788qtx.229.1654556491673; Mon, 06 Jun 2022 16:01:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywKxz4J1w/LYb1cIRK/5IYlacJL5306Fg7ecnHtjEVKTZT/8rKm/gar02KAVwNd+BVSL/ATA== X-Received: by 2002:a05:622a:4c9:b0:304:b650:683d with SMTP id q9-20020a05622a04c900b00304b650683dmr20463754qtx.229.1654556491240; Mon, 06 Jun 2022 16:01:31 -0700 (PDT) Received: from t14s.localdomain (c-73-69-212-193.hsd1.nh.comcast.net. [73.69.212.193]) by smtp.gmail.com with ESMTPSA id g16-20020ac85810000000b002f906fc8530sm2452160qtg.46.2022.06.06.16.01.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 16:01:30 -0700 (PDT) Message-ID: Subject: Re: [PATCH] libgccjit: Fix infinite recursion in gt_ggc_mx_lang_tree_node From: David Malcolm To: Antoni Boucher , gcc-patches@gcc.gnu.org, jit@gcc.gnu.org Date: Mon, 06 Jun 2022 19:01:29 -0400 In-Reply-To: <37a1856fc54aec475834fd6e7d07b8135e6c750c.camel@zoho.com> References: <74a73ea69738df3e4d277cd86b27f93b494dae77.camel@zoho.com> <37a1856fc54aec475834fd6e7d07b8135e6c750c.camel@zoho.com> User-Agent: Evolution 3.38.4 (3.38.4-1.fc33) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-14.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: jit@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Jit mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Jun 2022 23:01:35 -0000 On Thu, 2022-06-02 at 21:23 -0400, Antoni Boucher via Gcc-patches wrote: > Sorry, forgot to attach the patch. > > Here it is. > > On Thu, 2022-06-02 at 21:20 -0400, Antoni Boucher via Jit wrote: > > Hi. > > The attached patch fix bug 105827: > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105827 > > > > I'm not sure how to test this, so please share ideas. Do you have a reproducer for this? With garbage-collections issues in libgccjit, you can set: gcc_jit_context_set_bool_option (ctxt, GCC_JIT_BOOL_OPTION_SELFCHECK_GC, 1); which will force a full garbage collection at every opportunity that the collector considers doing one (rather than following heuristics) This really slows things down, but makes reproducing crashes much more deterministic, often turning "it crashes every now and then" to "it crashes every time" (and the test suite runs with this enabled). > > > > Thanks for the review. > > diff --git a/gcc/jit/dummy-frontend.cc b/gcc/jit/dummy-frontend.cc > index 84ff359bfe3..8bb5d03d630 100644 > --- a/gcc/jit/dummy-frontend.cc > +++ b/gcc/jit/dummy-frontend.cc > @@ -506,13 +506,14 @@ struct GTY(()) lang_identifier > > /* The resulting tree type. */ > > +/* See lang_tree_node in gcc/c/c-decl.cc. */ > union GTY((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE"), > - chain_next ("CODE_CONTAINS_STRUCT (TREE_CODE (&%h.generic), TS_COMMON) ? ((union lang_tree_node *) TREE_CHAIN (&%h.generic)) : NULL"))) > -lang_tree_node > -{ > - union tree_node GTY((tag ("0"), > - desc ("tree_node_structure (&%h)"))) generic; > - struct lang_identifier GTY((tag ("1"))) identifier; > + chain_next ("(union lang_tree_node *) jit_tree_chain_next (&%h.generic)"))) lang_tree_node > + { > + union tree_node GTY ((tag ("0"), > + desc ("tree_node_structure (&%h)"))) > + generic; > + struct lang_identifier GTY ((tag ("1"))) identifier; > }; Those GTY markings on gcc/jit/dummy-frontend.cc's lang_tree_node union have been like that since my initial proof-of-concept patch back in 2013: https://gcc.gnu.org/legacy-ml/gcc-patches/2013-10/msg00228.html so presumably I simply copied and pasted that from another frontend when I was initially prototyping libgccjit. There was an element of "cargo cult programming" as I was getting the project started. Jakub had changed the C and C++ frontends in June 2011 with 563007852e8d19b66ec8c1e42e431efaaa967dc6, which introduced the c_tree_chain_next that you're now copying in your patch, so presumably I copied from a different frontend. My notes say I created the first prototype in July 2013, so that's when I would have copied&pasted the code. Dave