linux/scripts/genksyms
Richard Yao 1c722503fa genksyms: Duplicate function pointer type definitions segfault
I noticed that genksyms will segfault when it sees duplicate function
pointer type declaration when I placed the same function pointer
definition in two separate headers in a local branch as an intermediate
step of some refactoring. This can be reproduced by piping the following
minimal test case into `genksyms -r /dev/null` or alternatively, putting
it into a C file attempting a build:

typedef int (*f)();
typedef int (*f)();

Attaching gdb to genksyms to understand this failure is useless without
changing CFLAGS to emit debuginfo. Once you have debuginfo, you will
find that the failure is that `char *s` was NULL and the program
executed `while(*s)`. At which point, further debugging requires
familiarity with compiler front end / parser development.

What happens is that flex identifies the first instance of the token "f"
as IDENT and the yacc parser adds it to the symbol table. On the second
instance, flex will identify "f" as TYPE, which triggers an error case
in the yacc parser. Given that TYPE would have been IDENT had it not
been in the symbol table, the the segmentaion fault could be avoided by
treating TYPE as IDENT in the affected rule.

Some might consider placing identical function pointer type declarations
in different headers to be poor style might consider a failure to be
beneficial. However, failing through a segmentation fault makes the
cause non-obvious and can waste the time of anyone who encounters it.

Signed-off-by: Richard Yao <richard.yao@clusterhq.com>
Acked-by: Madhuri Yechuri <madhuriyechuri@clusterhq.com>
Signed-off-by: Michal Marek <mmarek@suse.com>
2015-08-20 14:55:55 +02:00
..
.gitignore genksyms: migrate parser to implicit rules 2011-06-09 14:04:41 -04:00
genksyms.c genksyms: pass symbol-prefix instead of arch 2013-03-20 11:27:27 +10:30
genksyms.h genksyms: Do not expand internal types 2011-10-11 12:00:39 +02:00
keywords.gperf genksyms: fix typeof() handling 2014-04-03 16:20:52 -07:00
keywords.hash.c_shipped genksyms: fix typeof() handling 2014-04-03 16:20:52 -07:00
lex.l genksyms: fix typeof() handling 2014-04-03 16:20:52 -07:00
lex.lex.c_shipped genksyms: fix typeof() handling 2014-04-03 16:20:52 -07:00
Makefile scripts/genksyms: clean lex/yacc generated files 2012-01-08 14:48:15 +01:00
parse.tab.c_shipped genksyms: fix typeof() handling 2014-04-03 16:20:52 -07:00
parse.tab.h_shipped genksyms: fix typeof() handling 2014-04-03 16:20:52 -07:00
parse.y genksyms: Duplicate function pointer type definitions segfault 2015-08-20 14:55:55 +02:00