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 72D9D3830646 for ; Mon, 6 Jun 2022 23:01:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 72D9D3830646 Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-644-vQdzETvLPaq3LMyy1_6xRg-1; Mon, 06 Jun 2022 19:01:32 -0400 X-MC-Unique: vQdzETvLPaq3LMyy1_6xRg-1 Received: by mail-qk1-f198.google.com with SMTP id bj2-20020a05620a190200b005084968bb24so12713063qkb.23 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=UjCTsYK3z2Vpykdhvs32tj501E1R7ro2VK7vrKXH+/4G53aPG75onfgsu2t512dJN4 q+VaxvPOuK6dUC6+37T14q2UyIiNwIBw2EwmiK+PdqSBR8VtTs/Uc1j8BVncnkrhyXf2 yv2fCLGl3Ic3dSqAsx2D5B4Ul0q/h1Qeb4gWXQoybl9IohJLNStPQakXH8DgKumPasP3 1zWKIcmtaIl2LvSOKYGkWppsQ0SECwKGditgx3OjMhUKdl456GhmDouYubF8Ln2x2ttP aebgPHhDjWQwNKP013PdIGCwE4O8edWYqVhWO0LVWleElFI5InLBaabfzU/GL5mjGCuv 9fzw== X-Gm-Message-State: AOAM532XbS3gWAk0wd+aAU3QyUJEee9fowh8+61HIbcWc10DlC5RJS0O FUTQooLPLTljo67MDFHF2Ia1d7G4UQND2oMXGmjoDagb3Br5THD2vm+l8QuHUdZmShstKR0qDyt QNiJIBdFBcH9LWXwHYQ== X-Received: by 2002:a05:622a:4c9:b0:304:b650:683d with SMTP id q9-20020a05622a04c900b00304b650683dmr20463787qtx.229.1654556491672; 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=-12.4 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: 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