mhulden / foma

Automatically exported from code.google.com/p/foma

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unescaped reserved symbols in some expressions cause segfault

dhdaines opened this issue · comments

This will cause foma to segfault:

define foo_bar u -> oo;
define baz a -> e;
define grammar foo_bar .o. baz;
regex grammar;

Fair enough, _ is a reserved symbol, so it needs to be escaped. Better not to use underscores in network names :) but it probably shouldn't cause a segmentation fault. Backtrace looks like this:

Program received signal SIGSEGV, Segmentation fault.
0x000055555558c65a in fsm_isempty (net=0x0) at /home/dhd/work/flair/src/foma/foma/structures.c:330
330         struct fsm_state *fsm = minimal->states;
(gdb) bt
#0  0x000055555558c65a in fsm_isempty (net=0x0) at /home/dhd/work/flair/src/foma/foma/structures.c:330
#1  0x000055555556ea24 in fsm_compose (net1=0x0, net2=0x555556e14ec0) at /home/dhd/work/flair/src/foma/foma/constructions.c:558
#2  0x00005555555a0261 in yyparse (scanner=0x555556e0bc10, defined_nets=0x555556e052e0, defined_funcs=0x555556e05300) at /home/dhd/work/flair/src/foma/foma/regex.y:261
#3  0x000055555558ff59 in my_yyparse (my_string=0x555556e05549 " foo_bar .o. baz;", lineno=3, defined_nets=0x555556e052e0, defined_funcs=0x555556e05300)
    at /home/dhd/work/flair/src/foma/foma/regex.l:130
#4  0x0000555555564ab1 in interfacelex () at /home/dhd/work/flair/src/foma/foma/interface.l:356
#5  0x0000555555560606 in my_interfaceparse (my_string=0x555556e06520 "define foo_bar u -> oo;\ndefine baz a -> e;\ndefine grammar foo_bar .o. baz;\nregex grammar;")
    at /home/dhd/work/flair/src/foma/foma/interface.l:109
#6  0x000055555555ab12 in main (argc=3, argv=0x7fffffffdfc8) at /home/dhd/work/flair/src/foma/foma/foma.c:129