git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 2/2] Fix stack-use-after-scope error reported by ASAN by GCC 7.

From
MLMartin Liška <mliska@suse.cz>
Date
Apr 6, 2017, 10:23 UTC
Message-ID
<28c22c5e-677b-1554-6156-4e31cc0f0913@suse.cz>
In-Reply-To
<alpine.DEB.2.20.1704061051130.4268@virtualbox>
On 04/06/2017 10:55 AM, Johannes Schindelin wrote:
Show 8 quoted lines
> Hi Martin,
> 
> On Thu, 6 Apr 2017, Martin Liška wrote:
> 
>> Following patch fixes issues that can be seen with -fsanitize=address on
>> GCC 7.
> 
> Good catch.

Yep, actually it was me who wrote the new use-after-scope support in GCC 7. And I was bit pessimistic about real examples of such errors, but one popped up very soon.

Show 16 quoted lines
> 
> However, it may make more sense to switch to using the "args" field
> instead of the "argv" field: it is of type "struct argv_array" and is
> released automagically by finish_command().
> 
> In other words, you would use something like
> 
> @@ -600,7 +601,8 @@ static struct cmd2process
> *start_multi_file_filter(struct hashmap *hashmap, cons
>         process = &entry->process;
> 
>         child_process_init(process);
> -       process->argv = argv;
> +	argv_array_push(&process->args, cmd);
> 
> instead, making even for a nice LOC reduction.
Done that way, survives tests.
Martin
> 
> Ciao,
> Johannes
> 
From 4e80f9bddff3c29fefb3628e0e920ca265d55e65 Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Thu, 6 Apr 2017 11:40:24 +0200
Subject: [PATCH 2/2] Fix stack-use-after-scope error reported by ASAN by GCC
 7.
The use-after-scope is triggered here:
READ of size 8 at 0x7ffc4f674e20 thread T0
    #0 0x6f0b69 in finish_command /home/marxin/Programming/git/run-command.c:570
    #1 0x5b6101 in kill_multi_file_filter /home/marxin/Programming/git/convert.c:570
    #2 0x5b798a in kill_multi_file_filter /home/marxin/Programming/git/convert.c:770
---
 convert.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/convert.c b/convert.c
index 8d652bf27..73eb28eb8 100644
--- a/convert.c
+++ b/convert.c
@@ -589,7 +589,6 @@ static struct cmd2process *start_multi_file_filter(struct hashmap *hashmap, cons
 	int err;
 	struct cmd2process *entry;
 	struct child_process *process;
-	const char *argv[] = { cmd, NULL };
 	struct string_list cap_list = STRING_LIST_INIT_NODUP;
 	char *cap_buf;
 	const char *cap_name;
@@ -600,7 +599,7 @@ static struct cmd2process *start_multi_file_filter(struct hashmap *hashmap, cons
 	process = &entry->process;
 
 	child_process_init(process);
-	process->argv = argv;
+	argv_array_push(&process->args, cmd);
 	process->use_shell = 1;
 	process->in = -1;
 	process->out = -1;
-- 
2.12.2
Previous: Johannes Schindelin
Message 4 of 4 in “Fix stack-use-after-scope error reported by ASAN by GCC 7.”
  1. 2/2 Fix stack-use-after-scope error reported by ASAN by GCC 7.Martin Liška, Apr 6, 2017
  2. Jeff KingApr 6, 2017
  3. Johannes SchindelinApr 6, 2017
  4. Martin LiškaApr 6, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.