Hi,

I found a segmentation fault while running GNU Bison 3.8.2 on Ubuntu 22.04.

The crash occurs when I run Bison with the --trace=all option on the
attached grammar file.

Environment:

OS: Ubuntu 22.04
Bison version: GNU Bison 3.8.2
Build method: downloaded bison-3.8.2.tar.xz and ran ./configure and make

Command used:

./bison --trace=all example.yy

Expected behavior:

Bison should process the grammar file and print trace output without
crashing.

Actual behavior:

Bison crashes with a segmentation fault.

Here is the relevant part of the output:

$ ./bison --trace=all example.yy
bison (GNU Bison) 3.8.2
Starting parse
Entering state 0
Stack now 0
Reducing stack by rule 2 (line 319):
-> $$ = nterm prologue_declarations (example.yy:[email protected]:1.1@1: )
Entering state 2
Stack now 0 2
Reading a token
--(end of buffer or a NUL)
--accepting rule at line 219 ("/*")
--accepting rule at line 527 (" ")

...

Reducing stack by rule 24 (line 363):
   $1 = token %skeleton (example.yy:[email protected]:20.10@10: )
   $2 = token string (example.yy:[email protected]:20.21@21: "lalr1.cc")
-> $$ = nterm prologue_declaration (example.yy:[email protected]:20.21@21: )
Entering state 43
Stack now 0 2 43

...

--accepting rule at line 247 ("%define")
Next token is token %define (example.yy:[email protected]:24.8@8: )
LAC: initial context established for %define
LAC: checking lookahead %define: R55 G60 R8 G43 R3 G2 S16
Reducing stack by rule 55 (line 488):
-> $$ = nterm string.opt (example.yy:[email protected]:22.8@8:
Segmentation fault (core dumped)

I am attaching the example.yy file used to reproduce the crash.

Best regards,
Minjong Kim

Attachment: example.yy
Description: Binary data

Reply via email to