summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2019-10-09 02:25:40 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2019-10-09 23:29:41 +0200
commit6837969854ad688dec4801c0af5831cf4f9a2de0 (patch)
treef950b40c5bf5bebf83a11aa7aa6658725e3b8874
parent84bf658e2bedde92f3bd3f2285e6350f8cf60339 (diff)
downloadsparse-6837969854ad688dec4801c0af5831cf4f9a2de0.tar.gz
"graph" segfaults on top-level asm
The "graph" binary segfaults on this input: asm(""); with gdb saying (edited for clarity): Program received signal SIGSEGV, Segmentation fault. in graph_ep (ep=0x7ffff7f62010) at graph.c:52 (gdb) p ep->entry $1 = (struct instruction *) 0x0 Sadly, the commit that introduced this crash: 15fa4d60e ("topasm: top-level asm is special") was (part of a bigger series) meant to fix crashes because of such toplevel asm statements. Toplevel ASM statements are quite abnormal: * they are toplevel but anonymous symbols * they should be limited to basic ASM syntax but are not * they are given the type SYM_FN but are not functions * there is nothing to evaluate or expand about it. These cause quite a few problems including crashes, even before the above commit. So, before handling them more correctly and instead of adding a bunch of special cases here and there, temporarily take the more radical approach of stopping to add them to the list of toplevel symbols. Fixes: 15fa4d60ebba3025495bb34f0718764336d3dfe0 Reported-by: Vegard Nossum <vegard.nossum@gmail.com> Analyzed-by: Vegard Nossum <vegard.nossum@gmail.com> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--parse.c2
-rw-r--r--validation/linear/asm-toplevel.c1
2 files changed, 2 insertions, 1 deletions
diff --git a/parse.c b/parse.c
index ac795bd7..48a63f22 100644
--- a/parse.c
+++ b/parse.c
@@ -2890,7 +2890,7 @@ static struct token *toplevel_asm_declaration(struct token *token, struct symbol
token = parse_asm_statement(token, stmt);
- add_symbol(list, anon);
+ // FIXME: add_symbol(list, anon);
return token;
}
diff --git a/validation/linear/asm-toplevel.c b/validation/linear/asm-toplevel.c
index 8bdd7fc1..bd3b58a6 100644
--- a/validation/linear/asm-toplevel.c
+++ b/validation/linear/asm-toplevel.c
@@ -2,6 +2,7 @@ __asm__("/* nothing */");
/*
* check-name: asm-toplevel.c
* check-command: test-linearize $file
+ * check-known-to-fail
* check-output-ignore
* check-output-contains: asm *".. nothing .."
*/