public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug jit/63854] Fix memory leaks seen in JIT Date: Fri, 21 Aug 2020 13:26:55 +0000 [thread overview] Message-ID: <bug-63854-4-pWTFeDUg4i@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-63854-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63854 --- Comment #33 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Alex Coplan <acoplan@gcc.gnu.org>: https://gcc.gnu.org/g:b46584d7836bee011facdf946fd7241c748d66f0 commit r11-2799-gb46584d7836bee011facdf946fd7241c748d66f0 Author: Alex Coplan <alex.coplan@arm.com> Date: Fri Aug 21 14:26:11 2020 +0100 driver: Fix several memory leaks [PR63854] 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 | +--------------+-----+-----+------+---------------+ gcc/ChangeLog: PR jit/63854 * 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().
next prev parent reply other threads:[~2020-08-21 13:26 UTC|newest] Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-11-13 17:58 [Bug jit/63854] New: " dmalcolm at gcc dot gnu.org 2014-11-13 18:00 ` [Bug jit/63854] " dmalcolm at gcc dot gnu.org 2014-11-17 17:49 ` dmalcolm at gcc dot gnu.org 2014-11-19 19:09 ` dmalcolm at gcc dot gnu.org 2014-11-19 19:12 ` dmalcolm at gcc dot gnu.org 2014-11-19 19:23 ` dmalcolm at gcc dot gnu.org 2014-11-19 19:34 ` dmalcolm at gcc dot gnu.org 2014-11-19 19:43 ` dmalcolm at gcc dot gnu.org 2014-11-19 19:46 ` dmalcolm at gcc dot gnu.org 2014-11-19 19:50 ` dmalcolm at gcc dot gnu.org 2014-11-19 19:57 ` dmalcolm at gcc dot gnu.org 2014-11-19 20:10 ` dmalcolm at gcc dot gnu.org 2014-11-19 20:14 ` dmalcolm at gcc dot gnu.org 2014-11-19 20:18 ` dmalcolm at gcc dot gnu.org 2014-11-19 20:21 ` dmalcolm at gcc dot gnu.org 2014-11-19 20:27 ` dmalcolm at gcc dot gnu.org 2014-11-19 20:32 ` dmalcolm at gcc dot gnu.org 2014-11-19 20:43 ` dmalcolm at gcc dot gnu.org 2014-11-19 20:45 ` dmalcolm at gcc dot gnu.org 2014-12-01 16:14 ` dmalcolm at gcc dot gnu.org 2014-12-01 17:16 ` dmalcolm at gcc dot gnu.org 2014-12-01 17:29 ` dmalcolm at gcc dot gnu.org 2014-12-01 17:40 ` dmalcolm at gcc dot gnu.org 2014-12-04 21:11 ` dmalcolm at gcc dot gnu.org 2014-12-04 21:24 ` dmalcolm at gcc dot gnu.org 2014-12-09 20:47 ` dmalcolm at gcc dot gnu.org 2014-12-10 19:16 ` dmalcolm at gcc dot gnu.org 2014-12-11 15:07 ` dcb314 at hotmail dot com 2015-01-12 19:59 ` dmalcolm at gcc dot gnu.org 2015-04-16 14:08 ` ienkovich at gcc dot gnu.org 2020-08-21 13:26 ` cvs-commit at gcc dot gnu.org [this message] 2022-03-19 17:43 ` cvs-commit at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-63854-4-pWTFeDUg4i@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).