public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Martin Liska <marxin@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/marxin/heads/PR-fix-lto-wrapper-memory-corruption)] lto-wrapper: fix memory corruption. Date: Wed, 10 Nov 2021 10:08:50 +0000 (GMT) [thread overview] Message-ID: <20211110100850.73A793857C4E@sourceware.org> (raw) https://gcc.gnu.org/g:51c09d86974ba85997db5a86c15fb6a0d8df2bd0 commit 51c09d86974ba85997db5a86c15fb6a0d8df2bd0 Author: Martin Liska <mliska@suse.cz> Date: Wed Nov 10 11:07:15 2021 +0100 lto-wrapper: fix memory corruption. The first argument of merge_and_complain is actually vector where we merge options and it should be propagated to caller properly. Fixes: ==6656== Invalid read of size 8 ==6656== at 0x408056: merge_and_complain (lto-wrapper.c:335) ==6656== by 0x408056: find_and_merge_options(int, long, char const*, vec<cl_decoded_option, va_heap, vl_ptr>, vec<cl_decoded_option, va_heap, vl_ptr>*, char const*) (lto-wrapper.c:1139) ==6656== by 0x408AFC: run_gcc(unsigned int, char**) (lto-wrapper.c:1505) ==6656== by 0x4061A2: main (lto-wrapper.c:2138) ==6656== Address 0x4e69b18 is 344 bytes inside a block of size 1,768 free'd ==6656== at 0x484339F: realloc (vg_replace_malloc.c:1192) ==6656== by 0x4993C0: xrealloc (xmalloc.c:181) ==6656== by 0x406A82: reserve<cl_decoded_option> (vec.h:290) ==6656== by 0x406A82: reserve (vec.h:1858) ==6656== by 0x406A82: vec<cl_decoded_option, va_heap, vl_ptr>::safe_push(cl_decoded_option const&) [clone .isra.0] (vec.h:1967) ==6656== by 0x4077E0: merge_and_complain (lto-wrapper.c:457) ==6656== by 0x4077E0: find_and_merge_options(int, long, char const*, vec<cl_decoded_option, va_heap, vl_ptr>, vec<cl_decoded_option, va_heap, vl_ptr>*, char const*) (lto-wrapper.c:1139) ==6656== by 0x408AFC: run_gcc(unsigned int, char**) (lto-wrapper.c:1505) ==6656== by 0x4061A2: main (lto-wrapper.c:2138) ==6656== Block was alloc'd at ==6656== at 0x483E70F: malloc (vg_replace_malloc.c:380) ==6656== by 0x4993D7: xrealloc (xmalloc.c:179) ==6656== by 0x407476: reserve<cl_decoded_option> (vec.h:290) ==6656== by 0x407476: reserve (vec.h:1858) ==6656== by 0x407476: reserve_exact (vec.h:1878) ==6656== by 0x407476: create (vec.h:1893) ==6656== by 0x407476: get_options_from_collect_gcc_options(char const*, char const*) (lto-wrapper.c:163) ==6656== by 0x407674: find_and_merge_options(int, long, char const*, vec<cl_decoded_option, va_heap, vl_ptr>, vec<cl_decoded_option, va_heap, vl_ptr>*, char const*) (lto-wrapper.c:1132) ==6656== by 0x408AFC: run_gcc(unsigned int, char**) (lto-wrapper.c:1505) ==6656== by 0x4061A2: main (lto-wrapper.c:2138) gcc/ChangeLog: * lto-wrapper.c (merge_and_complain): Make the first argument a reference type. Diff: --- gcc/lto-wrapper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/lto-wrapper.c b/gcc/lto-wrapper.c index 7b9e4883f38..54f642d7692 100644 --- a/gcc/lto-wrapper.c +++ b/gcc/lto-wrapper.c @@ -224,7 +224,7 @@ merge_flto_options (vec<cl_decoded_option> &decoded_options, ontop of DECODED_OPTIONS. */ static void -merge_and_complain (vec<cl_decoded_option> decoded_options, +merge_and_complain (vec<cl_decoded_option> &decoded_options, vec<cl_decoded_option> fdecoded_options, vec<cl_decoded_option> decoded_cl_options) {
reply other threads:[~2021-11-10 10:08 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20211110100850.73A793857C4E@sourceware.org \ --to=marxin@gcc.gnu.org \ --cc=gcc-cvs@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).