From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mo4-p00-ob.smtp.rzone.de (mo4-p00-ob.smtp.rzone.de [85.215.255.21]) by sourceware.org (Postfix) with ESMTPS id 21BCC3858420; Sat, 8 Jan 2022 10:08:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 21BCC3858420 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=nieper-wisskirchen.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=nieper-wisskirchen.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1641636483; s=strato-dkim-0002; d=nieper-wisskirchen.de; h=Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References:Cc:Date: From:Subject:Sender; bh=G8/hn1kCbeSdgaqkIK/HUwqUiCew4BZQTtLBbSwsdXw=; b=iJKwK/TtCl95Yan0vkqquoNaOOrJXvHRXChpg03eYaxcANEjekadfjnigDkijKY4sE Uu5W6/nQAQSxNy7he09Z/Ylq/RCyTyup2npj0qj5FjIUbD9nP273t44MRiNhuBFnLqob e8eQXOfsXTw+v82OkR2eXX+PrmqSvBhDw74xvUQRzivpYk5MsFlK5dulywTzw8F2ysGF rV1k7i9qnenkrSeyUVHWLNNZlirNEMx65GCphjU2xS5HQBraxAvhM2YPdFfg/8owpfxP 3rpcBI0neNcifeddaDBIx234xQ+9c7CIrH0vfeJcOIc6IYAuNOH4r5lza8P6UxPKV9fs 015w== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":IW0WdmCmcvpIrP2+VJuPtIhjJvc4Ig+QdhX22iZVwSDOx4Kp3cYsBVGy6CZgmO/guIaKV8N565JBDQ==" X-RZG-CLASS-ID: mo00 Received: from mail-yb1-f172.google.com by smtp.strato.de (RZmta 47.37.6 AUTH) with ESMTPSA id k693bey08A838xB (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Sat, 8 Jan 2022 11:08:03 +0100 (CET) Received: by mail-yb1-f172.google.com with SMTP id m6so13522005ybc.9; Sat, 08 Jan 2022 02:08:03 -0800 (PST) X-Gm-Message-State: AOAM530/dUdKeAtNlNqnJ+VzrNjiA0CqGVTOEoVmY7gtVnITK+e5COl+ bz4m0wlImWztZyevK9xlS2ppcG6/c1FPlPNYdn8= X-Google-Smtp-Source: ABdhPJz15mRzMBHKuT3MaSXXdYlDQ74mBdRhUJzUJJSVgnUVnn/cmC1q/z2sNUtgzq+CAu3UvgSrniI23cQJNW0EkGY= X-Received: by 2002:a05:6902:110b:: with SMTP id o11mr56612321ybu.559.1641636482817; Sat, 08 Jan 2022 02:08:02 -0800 (PST) MIME-Version: 1.0 References: <20211219213010.17113-1-marc@nieper-wisskirchen.de> <2a54fac9b37d87afb009b8eb339d5ad6927454dd.camel@redhat.com> In-Reply-To: <2a54fac9b37d87afb009b8eb339d5ad6927454dd.camel@redhat.com> From: =?UTF-8?Q?Marc_Nieper=2DWi=C3=9Fkirchen?= Date: Sat, 8 Jan 2022 11:07:51 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] gcc: pass-manager: Fix memory leak. [PR jit/63854] To: David Malcolm Cc: gcc-patches@gcc.gnu.org, =?UTF-8?Q?Marc_Nieper=2DWi=C3=9Fkirchen_via_Jit?= Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Sat, 08 Jan 2022 10:08:06 -0000 Thanks for replying so quickly! Am Do., 6. Jan. 2022 um 14:53 Uhr schrieb David Malcolm : [...] > Thanks for the patch. > > It looks correct to me, given that pass_manager::register_pass_name > does an xstrdup and puts the result in the map. > > That said: > - I'm not officially a reviewer for this part of gcc (though I probably > touched this code last) I am a newcomer to the codebase of GCC and haven't yet been able to figure out whom to contact. I bothered you because the patch is mostly relevant for the libgccjit frontend. > - is it cleaner to instead change m_name_to_pass_map's key type from > const char * to char *, to convey that the map "owns" the name? That > way we probably wouldn't need struct typed_const_free_remove, and (I > hope) works better with the type system. The problem with that approach is that we would then need a new version of string_hash in hash-traits.h, say owned_string_hash, which derives from pointer_hash and not pointer_hash . This would add roughly as much code as struct typed_const_free_remove. Using the hypothetical owned_string_hash in the definition of m_name_to_pass_map in passes.c would then produce a map taking "char *" strings instead of "const char *" strings. This, however, would then lead to problems in pass_manager::register_pass_name where name is a "const char *" string (coming from outside) but m_name_to_pass_map->get would take a "char *" string. I don't see how to resolve this without bigger refactoring, so I think my struct typed_const_free_remove approach is less intrusive. This conveys at least that the key isn't changed by the hashmap operations and that it is yet owned (because this is something that typed_const_free_remove presupposes. Thanks, Marc [...]