bin/140309: bad syntax cause yacc segfault

Philippe Pepiot ksh at
Thu Nov 5 12:50:03 UTC 2009

>Number:         140309
>Category:       bin
>Synopsis:       bad syntax cause yacc segfault
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Nov 05 12:50:02 UTC 2009
>Originator:     Philippe Pepiot
>Release:        9.0 CURRENT
FreeBSD 9.0-CURRENT FreeBSD 9.0-CURRENT #0: Wed Nov  4 19:56:02 CET 2009     root at  i386
Sometimes yacc segfault when declare typed rule and you don't set a value to $$ in the grammar rule.

The expected behavior of yacc in this case is to print an error message like
"the value of typed rule hasn't been set".

Here's backtrace :

#0  0x08053811 in end_rule () at /usr/src/usr.bin/yacc/reader.c:1260
1260            if (pitem[i+1] == 0 || pitem[i+1]->tag != plhs[nrules]->tag)

#0  0x08053811 in end_rule () at /usr/src/usr.bin/yacc/reader.c:1260
#1  0x0805486d in read_grammar () at /usr/src/usr.bin/yacc/reader.c:1632
#2  0x08055591 in reader () at /usr/src/usr.bin/yacc/reader.c:1926
#3  0x0804c4b4 in main (argc=2, argv=0xbfbfeb48) at /usr/src/usr.bin/yacc/main.c:434
Just yacc this file :

%type <int> rule

$ yacc file.y
segmentation fault (core dumped) /usr/bin/yacc


More information about the freebsd-bugs mailing list