"graph" (v0.6.1-rc2) segfaults on top-level asm

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

The "graph" binary segfaults on this input:

asm("");

This is what gdb says:

(gdb) run
Starting program: /home/vegard/git/sparse/graph asm.c
digraph call_graph {

Program received signal SIGSEGV, Segmentation fault.
0x0000000000401505 in graph_ep (ep=0x7ffff7f62010) at graph.c:52
52              sname = stream_name(ep->entry->bb->pos.stream);
(gdb) bt
#0  0x0000000000401505 in graph_ep (ep=0x7ffff7f62010) at graph.c:52
#1  main (argc=<optimized out>, argv=<optimized out>) at graph.c:191
(gdb) p ep->entry
$1 = (struct instruction *) 0x0

I've attached a tentative patch that fixes my segfault, but maybe this
is not the correct solution or maybe other binaries are impacted.

Bisected to:

commit 15fa4d60ebba3025495bb34f0718764336d3dfe0
Author: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
Date:   Mon May 29 04:25:56 2017 +0200

    topasm: top-level asm is special

Thanks,


Vegard
diff --git a/graph.c b/graph.c
index be4cf282..63e6e063 100644
--- a/graph.c
+++ b/graph.c
@@ -187,7 +187,7 @@ int main(int argc, char **argv)
 		} END_FOR_EACH_PTR(sym);
 
 		FOR_EACH_PTR(fsyms, sym) {
-			if (sym->ep) {
+			if (sym->ep && sym->ep->entry) {
 				graph_ep(sym->ep);
 				graph_calls(sym->ep, 1);
 			}
@@ -197,7 +197,7 @@ int main(int argc, char **argv)
 
 	/* Graph inter-file calls */
 	FOR_EACH_PTR(all_syms, sym) {
-		if (sym->ep)
+		if (sym->ep && sym->ep->entry)
 			graph_calls(sym->ep, 0);
 	} END_FOR_EACH_PTR(sym);
 

[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux