From patchwork Thu Jul 9 20:13:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Coplan X-Patchwork-Id: 1326210 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-armh-onmicrosoft-com header.b=rcGVPTcM; dkim=pass (1024-bit key) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-armh-onmicrosoft-com header.b=rcGVPTcM; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B2nRt1Ph8z9sRk for ; Fri, 10 Jul 2020 06:13:28 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1C88A3844031; Thu, 9 Jul 2020 20:13:25 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2086.outbound.protection.outlook.com [40.107.22.86]) by sourceware.org (Postfix) with ESMTPS id ABAAD3844029; Thu, 9 Jul 2020 20:13:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org ABAAD3844029 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Alex.Coplan@arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fiaPxR18NWdvoc0vTxqGhgbyv8f40a8pWHId65BZV10=; b=rcGVPTcMXj8KRzMb/vZ7QPc7UDH3SLteQzrgO8yCTvX7Xpy77N/FCOxlDi3IERGu8yCQEGCUpTJIl43g1kU5MX5yOyGG270hdvauVmRnmeW1qUaK14AVIbyldB9n8H/aagS0k6uI0/ZzpY4KvOGx8/IR1dLeXioOeuHXkgr3ASM= Received: from AM5PR0502CA0017.eurprd05.prod.outlook.com (2603:10a6:203:91::27) by VI1PR08MB4590.eurprd08.prod.outlook.com (2603:10a6:803:c3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.24; Thu, 9 Jul 2020 20:13:19 +0000 Received: from AM5EUR03FT030.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:91:cafe::41) by AM5PR0502CA0017.outlook.office365.com (2603:10a6:203:91::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Thu, 9 Jul 2020 20:13:19 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; gcc.gnu.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;gcc.gnu.org; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT030.mail.protection.outlook.com (10.152.16.117) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Thu, 9 Jul 2020 20:13:18 +0000 Received: ("Tessian outbound 1dc58800d5dd:v62"); Thu, 09 Jul 2020 20:13:18 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 041d0bdd1aaa25e5 X-CR-MTA-TID: 64aa7808 Received: from 8aee233dc5a8.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id D00AC363-709F-43EE-93ED-61FC82BF5571.1; Thu, 09 Jul 2020 20:13:13 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 8aee233dc5a8.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 09 Jul 2020 20:13:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KVaa226sLRDt4mehIBYfDM9XaUAVH/mXsqhjPCKKYDt53pnXNsl2sQQt1PgX7UT5+K+zuslhwMODT+s+KbYyhlwjKkqKXS9U3QjfrcTZimqheYELOauf3Fmm72KpiAJ/dWUSuZrzgq1aRfFUNpr8Kc6XQJz6KOpzF+fpdRNTb53crkyeA4GUrBlSGfPLQLusndHRetSlaJFr0jWYGNGFj/DtAWAGLCVNz0OQAgjk0Eskl72vl+VLt3whyJJ6CnXK1F0uXXaCnmq9QT9dr7qhlQyn/EDVQUYZbgwhah3sH+1ubrX771o3y3+QtiYGx1VgSg63tpSn3tzkgGMjdJIRHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fiaPxR18NWdvoc0vTxqGhgbyv8f40a8pWHId65BZV10=; b=RTfUNZ/nf1neXBB/TCCF6FrjvCtNu1nVD7j0a1//9xcfnk0rUgGa4lpto5d7JPbEpx9zpv9ngo9h4f7+x447LPlzgcT6kj/0FHRF4nNA7+ijVnY1mCPpHj0Or+QZtl5i94JPmCPFVqL2cEArFTYiSMVFyHGfafjJ+AA6yPe4h7ewJyjpqDuLa6mlndDGp2Tb71Tvn6CPacT4EwM5AABfHQsk7Y0AzM11CpzEbnzr1w1zxPH0pBTKQJA45E04isZYCWpvFRSL7GFr0Yp+4cgAb6lgDZyLa6dhq78tdwmH15HpNw0S1B+/oAdO9/PkJlNcq96sv4H6orkBTaOvb8spOg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fiaPxR18NWdvoc0vTxqGhgbyv8f40a8pWHId65BZV10=; b=rcGVPTcMXj8KRzMb/vZ7QPc7UDH3SLteQzrgO8yCTvX7Xpy77N/FCOxlDi3IERGu8yCQEGCUpTJIl43g1kU5MX5yOyGG270hdvauVmRnmeW1qUaK14AVIbyldB9n8H/aagS0k6uI0/ZzpY4KvOGx8/IR1dLeXioOeuHXkgr3ASM= Authentication-Results-Original: gcc.gnu.org; dkim=none (message not signed) header.d=none;gcc.gnu.org; dmarc=none action=none header.from=arm.com; Received: from VI1PR08MB4029.eurprd08.prod.outlook.com (2603:10a6:803:ec::14) by VI1PR08MB4223.eurprd08.prod.outlook.com (2603:10a6:803:b5::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21; Thu, 9 Jul 2020 20:13:12 +0000 Received: from VI1PR08MB4029.eurprd08.prod.outlook.com ([fe80::b8ed:5041:249f:6770]) by VI1PR08MB4029.eurprd08.prod.outlook.com ([fe80::b8ed:5041:249f:6770%2]) with mapi id 15.20.3174.022; Thu, 9 Jul 2020 20:13:12 +0000 Date: Thu, 9 Jul 2020 21:13:09 +0100 From: Alex Coplan To: gcc-patches@gcc.gnu.org, jit@gcc.gnu.org Subject: [PATCH] libgccjit: Fix several memory leaks in the driver Message-ID: <20200709201308.ngxjyakuxapc4yti@arm.com> Content-Disposition: inline User-Agent: NeoMutt/20171215 X-ClientProxiedBy: LO2P265CA0182.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a::26) To VI1PR08MB4029.eurprd08.prod.outlook.com (2603:10a6:803:ec::14) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from arm.com (217.140.106.49) by LO2P265CA0182.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.24 via Frontend Transport; Thu, 9 Jul 2020 20:13:11 +0000 X-Originating-IP: [217.140.106.49] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: db120f08-af4a-4496-f267-08d824448559 X-MS-TrafficTypeDiagnostic: VI1PR08MB4223:|VI1PR08MB4590: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:3383;OLM:3383; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 0TTzz4xGhDOmi18oeBMGD+k1Zlv6zO/WwgSO+XHhCh/IMs1AsThu8S7Jf0cHyigeeGhl3vEobSbLlPwtkfZMic3FdImLDHsgfGFTz+h7oVsIaEG6NmmEZtqrAbb6/cETS1WWk4RlBABhDZm6L8/wEoCwxHKmcdZBSQFj/vnT1K/dVtw7DTABfLUdJooJb8n2vgzI7EwSN/k6Xf71QN3EClBJrMgXKuZ4c3bBlqkJ2YQ5alNRdlm9mSG38Ae9RVs48WSwKqGohUBOwbAXdUwBlVnGcOQ/+CmsoI/Qk1auMKLdnJtZJ6SLmmIXYjoyRMYYhBojQzS2cPLnmdmpLrWjjOMS8EGNc3HeX00APhFKZWgdtJTdplMvV4SDGkR4Ry8e X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR08MB4029.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(366004)(39860400002)(346002)(396003)(136003)(376002)(7696005)(316002)(16526019)(186003)(235185007)(26005)(956004)(2616005)(2906002)(66616009)(55016002)(52116002)(83380400001)(86362001)(66476007)(478600001)(66946007)(66556008)(4326008)(8886007)(5660300002)(21480400003)(33964004)(44144004)(8936002)(36756003)(8676002)(1076003)(44832011)(2700100001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: y3YpzGLDDJ5IWyEh7E4aqElfb0UWwQcbwKlybSMdkEv57RT4BLxgJBCluhOXwKgwnzFJjACzF+usTixbVCBNIfg4As+e1nCjqgMQ9b6c1pfgmqIBegbwLhDMYr9ach2CgrhCPEuESIpuV4vDmyZjhpXwHC9lmrsZxymXzIEhjAj9kw0z0ARmPKIMDokCCuX1v3prKbdJFxwc7kMt3CkMUKD3dNh1QfJMkjfKlESMqTb1Q6xLFXJmS7/9j58o6xpU3psrzafnAFFMlAs8LzNfrJhlvqdWichVfd/5g573k8ipb7GFe8djUl0XoRrPGB1QMaSSHoyTnWqgWZ0XG00mOcpn5YNnu84c3ruT9YxKP6UrQtZkRT5ccUhQOn90iSbc0e6FDKknRy3rc0MOOKA7uBBKDDE4Zjx/zTW4EDb32QvEfGriPyZBbAsBaZPrPbMNcqptbVfbNSIli3GfJKrCHbljGGQW3SiK8SfZVaY9SlgrrlYwpv98XYg/pndxnHzO X-MS-Exchange-Transport-Forked: True X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB4223 Original-Authentication-Results: gcc.gnu.org; dkim=none (message not signed) header.d=none;gcc.gnu.org; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT030.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFTY:; SFS:(4636009)(136003)(376002)(39860400002)(346002)(396003)(46966005)(478600001)(44832011)(336012)(2616005)(55016002)(956004)(1076003)(8886007)(21480400003)(2906002)(26005)(8676002)(5660300002)(82740400003)(4326008)(235185007)(7696005)(16526019)(450100002)(83380400001)(70206006)(66616009)(186003)(47076004)(356005)(70586007)(86362001)(33964004)(82310400002)(44144004)(81166007)(36756003)(316002)(8936002)(2700100001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: e70bb3f6-5992-4a55-fb75-08d82444814a X-Forefront-PRVS: 04599F3534 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: H57Yzh7HjUcdqgMMY1nFJ968WDYoQypF74bKFGXgtlC4LYHhJkydo+f2I5jbkO90nNP7VbJpa29D2akhBVVHcEFpuZTlesvGxuZD+reC0ePFw4wex20k3aBD9BSEO7at8KKLkuYjGRDQkZipb3QpKHodIs1ilE/Kzii75kT9jTluvJmkVhyBZALcQcQxLzugxRpMmVUZKhon7fWTfFixCIi6+Lv5m2SB02uzpKMyrHUg527hzkYQx60Rmgq21nVGkAamKD492TMF12jzNO8FOnrqiBgA7ePsOfrA099xFx+wzqnNk5D07VBZVwTVOloDwdVdnlZA/oZiaMsfoVCxpWF+sclrNC6OwxbdKHIqzk6rpqnL7b6TKAgN9ezELNIQtqgcwWZ51WVPe8UdxZ/BeEUj7jSlULOOxpefR+aeJNA= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2020 20:13:18.5836 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: db120f08-af4a-4496-f267-08d824448559 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT030.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB4590 X-Spam-Status: No, score=-16.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: , Cc: nd@arm.com Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hello, This patch fixes several memory leaks in the driver, all of which relate to the handling of static specs. We introduce functions set_static_spec_{shared,owned}() which are used to enforce proper memory management when updating the strings in the static_specs table. This is achieved by making use of the alloc_p field in the table entries. Similarly to set_spec(), each time we update an entry, we check whether alloc_p is set, and free the old value if so. We then set alloc_p correctly based on whether we "own" this memory or whether we're just taking a pointer to a shared string which we shouldn't free. The following table shows the number of leaks found by AddressSanitizer when running a minimal libgccjit program on AArch64. The test program does the whole libgccjit compilation cycle in a loop (including acquiring and releasing the context), and the table below shows the number of leaks for different iterations of that loop. +--------------+-----+-----+------+---------------+ | # of runs > | 1 | 2 | 3 | Leaks per run | +--------------+-----+-----+------+---------------+ | Before patch | 463 | 940 | 1417 | 477 | +--------------+-----+-----+------+---------------+ | After patch | 416 | 846 | 1276 | 430 | +--------------+-----+-----+------+---------------+ Ensuring that we minimize "leaks per run" (ultimately eliminating all of them) is important in order for long-running applications to be able to make use of in-process libgccjit. Testing: * Bootstrap and regtest on aarch64-linxu-gnu, x86_64-linux-gnu. * Bootstrap and regtest on aarch64-linux-gnu with bootstrap-asan config. * Smoke test of libgccjit, ran regressions on a --disable-bootstrap build on aarch64-linux-gnu. OK for master? Thanks, Alex --- gcc/ChangeLog: 2020-07-09 Alex Coplan * gcc.c (set_static_spec): New. (set_static_spec_owned): New. (set_static_spec_shared): New. (driver::maybe_putenv_COLLECT_LTO_WRAPPER): Use set_static_spec_owned() to take ownership of lto_wrapper_file such that it gets freed in driver::finalize. (driver::maybe_run_linker): Use set_static_spec_shared() to ensure that we don't try and free() the static string "ld", also ensuring that any previously-allocated string in linker_name_spec is freed. Likewise with argv0. (driver::finalize): Use set_static_spec_shared() when resetting specs that previously had allocated strings; remove if(0) around call to free(). diff --git a/gcc/gcc.c b/gcc/gcc.c index c0eb3c10cfd..f839971d42d 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -1908,6 +1908,47 @@ init_spec (void) specs = sl; } + +static void +set_static_spec (const char **spec, const char *value, bool alloc_p) +{ + struct spec_list *sl = NULL; + + for (unsigned i = 0; i < ARRAY_SIZE (static_specs); i++) + { + if (static_specs[i].ptr_spec == spec) + { + sl = static_specs + i; + break; + } + } + + gcc_assert (sl); + + if (sl->alloc_p) + { + const char *old = *spec; + free (const_cast (old)); + } + + *spec = value; + sl->alloc_p = alloc_p; +} + +/* Update a static spec to a new string, taking ownership of that + string's memory. */ +static void set_static_spec_owned (const char **spec, const char *val) +{ + return set_static_spec (spec, val, true); +} + +/* Update a static spec to point to a new value, but don't take + ownership of (i.e. don't free) that string. */ +static void set_static_spec_shared (const char **spec, const char *val) +{ + return set_static_spec (spec, val, false); +} + /* Change the value of spec NAME to SPEC. If SPEC is empty, then the spec is removed; If the spec starts with a + then SPEC is added to the end of the @@ -8333,7 +8374,7 @@ driver::maybe_putenv_COLLECT_LTO_WRAPPER () const if (lto_wrapper_file) { lto_wrapper_file = convert_white_space (lto_wrapper_file); - lto_wrapper_spec = lto_wrapper_file; + set_static_spec_owned (<o_wrapper_spec, lto_wrapper_file); obstack_init (&collect_obstack); obstack_grow (&collect_obstack, "COLLECT_LTO_WRAPPER=", sizeof ("COLLECT_LTO_WRAPPER=") - 1); @@ -8840,7 +8881,7 @@ driver::maybe_run_linker (const char *argv0) const { char *s = find_a_file (&exec_prefixes, "collect2", X_OK, false); if (s == NULL) - linker_name_spec = "ld"; + set_static_spec_shared (&linker_name_spec, "ld"); } #if HAVE_LTO_PLUGIN > 0 @@ -8864,7 +8905,7 @@ driver::maybe_run_linker (const char *argv0) const linker_plugin_file_spec = convert_white_space (temp_spec); } #endif - lto_gcc_spec = argv0; + set_static_spec_shared (<o_gcc_spec, argv0); } /* Rebuild the COMPILER_PATH and LIBRARY_PATH environment variables @@ -10806,9 +10847,9 @@ driver::finalize () just_machine_suffix = 0; gcc_exec_prefix = 0; gcc_libexec_prefix = 0; - md_exec_prefix = MD_EXEC_PREFIX; - md_startfile_prefix = MD_STARTFILE_PREFIX; - md_startfile_prefix_1 = MD_STARTFILE_PREFIX_1; + set_static_spec_shared (&md_exec_prefix, MD_EXEC_PREFIX); + set_static_spec_shared (&md_startfile_prefix, MD_STARTFILE_PREFIX); + set_static_spec_shared (&md_startfile_prefix_1, MD_STARTFILE_PREFIX_1); multilib_dir = 0; multilib_os_dir = 0; multiarch_dir = 0; @@ -10832,8 +10873,7 @@ driver::finalize () spec_list *sl = &static_specs[i]; if (sl->alloc_p) { - if (0) - free (const_cast (*(sl->ptr_spec))); + free (const_cast (*(sl->ptr_spec))); sl->alloc_p = false; } *(sl->ptr_spec) = sl->default_ptr;