akimd / bison

GNU Bison
GNU General Public License v3.0
332 stars 89 forks source link

[NonFetal Error]: use-of-uninitialized-value in bison(version 3.8.2.45, commit 25b3d0e1) #94

Open benehalo opened 2 years ago

benehalo commented 2 years ago

Crash Inputs

Here are the files that trigger the bug - muscle-tab.c_186_3-in-muscle_grow.zip

Bug Description

I apply MSan (Memory Sanitizer) to check for errors and report the detected errors as follows.

MemorySanitizer: use-of-uninitialized-value
    #0 0x54f335 in muscle_grow /data/code/bison/src/muscle-tab.c:186:3
    #1 0x54e4c4 in muscle_syncline_grow /data/code/bison/src/muscle-tab.c:214:3
    #2 0x54c815 in muscle_code_grow /data/code/bison/src/muscle-tab.c:227:3
    #3 0x5c4783 in gram_parse /data/code/bison/src/parse-gram.c:2082:7
    #4 0x6074a5 in reader /data/code/bison/src/reader.c:766:3
    #5 0x54a754 in main /data/code/bison/src/main.c:118:3
    #6 0x7f62fc25a082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16
    #7 0x41d70d in _start (/data/program/bison/orig-msan/bin/bison+0x41d70d)

SUMMARY: MemorySanitizer: use-of-uninitialized-value /data/code/bison/src/muscle-tab.c:186:3 in muscle_grow

How to Reproduce

The aforementioned bug can be stably reproduced in version 3.8.2.45 (commit id 25b3d0e1).

  1. Download the bison source code with the official link.
  2. Using clang/clang++ (10.0.0-4ubuntu1), build bison with MSan.
    • -U_FORTIFY_SOURCE -fsanitize=memory -g
  3. Execute bison with the provided input files.
    • eg: /data/program/bison/orig-msan/bin/bison <input-file-path>