rui314 / chibicc

A small C compiler
MIT License
9.69k stars 883 forks source link

memory sanitizer #5

Closed tankf33der closed 4 years ago

tankf33der commented 4 years ago

Failed run tests by (make test-all) if chibicc compiled under memory sanitizer:

./chibicc -Iinclude -Itest -c -o test/variable.o test/variable.c
==3636==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x4d531b in array_dimensions /home/mpech/chibicc/parse.c:667:26
    #1 0x4d3b8a in type_suffix /home/mpech/chibicc/parse.c:680:12
    #2 0x4d5c3e in declarator /home/mpech/chibicc/parse.c:719:8
    #3 0x4d5824 in declarator /home/mpech/chibicc/parse.c:705:5
    #4 0x4c1d3e in is_function /home/mpech/chibicc/parse.c:3306:14
    #5 0x4f3aae in compound_stmt /home/mpech/chibicc/parse.c:1793:11
    #6 0x4ed476 in primary /home/mpech/chibicc/parse.c:2998:18
    #7 0x4ec4fb in postfix /home/mpech/chibicc/parse.c:2835:16
    #8 0x4d251c in unary /home/mpech/chibicc/parse.c:2568:10
    #9 0x4d0495 in cast /home/mpech/chibicc/parse.c:2511:10
    #10 0x4cd9f5 in mul /home/mpech/chibicc/parse.c:2453:16
    #11 0x4cd425 in add /home/mpech/chibicc/parse.c:2431:16
    #12 0x4cce35 in shift /home/mpech/chibicc/parse.c:2338:16
    #13 0x4cc495 in relational /home/mpech/chibicc/parse.c:2306:16
    #14 0x4cbea5 in equality /home/mpech/chibicc/parse.c:2284:16
    #15 0x4cbb27 in bitand /home/mpech/chibicc/parse.c:2273:16
    #16 0x4cb7c7 in bitxor /home/mpech/chibicc/parse.c:2262:16
    #17 0x4cb467 in bitor /home/mpech/chibicc/parse.c:2251:16
    #18 0x4cb107 in logand /home/mpech/chibicc/parse.c:2240:16
    #19 0x4ca3a7 in logor /home/mpech/chibicc/parse.c:2229:16
    #20 0x4bcf7a in conditional /home/mpech/chibicc/parse.c:2200:16
    #21 0x4dfe68 in assign /home/mpech/chibicc/parse.c:2159:16
    #22 0x4f1f88 in funcall /home/mpech/chibicc/parse.c:2901:17
    #23 0x4ec62b in postfix /home/mpech/chibicc/parse.c:2839:14
    #24 0x4d251c in unary /home/mpech/chibicc/parse.c:2568:10
    #25 0x4d0495 in cast /home/mpech/chibicc/parse.c:2511:10
    #26 0x4cd9f5 in mul /home/mpech/chibicc/parse.c:2453:16
    #27 0x4cd425 in add /home/mpech/chibicc/parse.c:2431:16
    #28 0x4cce35 in shift /home/mpech/chibicc/parse.c:2338:16
    #29 0x4cc495 in relational /home/mpech/chibicc/parse.c:2306:16
    #30 0x4cbea5 in equality /home/mpech/chibicc/parse.c:2284:16
    #31 0x4cbb27 in bitand /home/mpech/chibicc/parse.c:2273:16
    #32 0x4cb7c7 in bitxor /home/mpech/chibicc/parse.c:2262:16
    #33 0x4cb467 in bitor /home/mpech/chibicc/parse.c:2251:16
    #34 0x4cb107 in logand /home/mpech/chibicc/parse.c:2240:16
    #35 0x4ca3a7 in logor /home/mpech/chibicc/parse.c:2229:16
    #36 0x4bcf7a in conditional /home/mpech/chibicc/parse.c:2200:16
    #37 0x4dfe68 in assign /home/mpech/chibicc/parse.c:2159:16
    #38 0x4cada8 in expr /home/mpech/chibicc/parse.c:1832:16
    #39 0x4fd15b in expr_stmt /home/mpech/chibicc/parse.c:1825:15
    #40 0x4fc7f5 in stmt /home/mpech/chibicc/parse.c:1772:10
    #41 0x4f3ece in compound_stmt /home/mpech/chibicc/parse.c:1805:25
    #42 0x4c3829 in function /home/mpech/chibicc/parse.c:3265:14
    #43 0x4bdf9c in parse /home/mpech/chibicc/parse.c:3361:13
    #44 0x4b6da0 in cc1 /home/mpech/chibicc/main.c:570:15
    #45 0x4b0164 in main /home/mpech/chibicc/main.c:680:5
    #46 0x7f83b7e490b2 in __libc_start_main /build/glibc-ZN95T4/glibc-2.31/csu/../csu/libc-start.c:308:16
    #47 0x41c2fd in _start (/home/mpech/chibicc/chibicc+0x41c2fd)

SUMMARY: MemorySanitizer: use-of-uninitialized-value /home/mpech/chibicc/parse.c:667:26 in array_dimensions
Exiting
rui314 commented 4 years ago

Thank you for reporting the bug! I fixed this issue locally.