vnmakarov / mir

A lightweight JIT compiler based on MIR (Medium Internal Representation) and C11 JIT compiler and interpreter based on MIR

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Segfault in `get_enum_basic_type`

clesmian opened this issue · comments

When executing c2m on poc.txt, a segfault occurs

POC

struct{
        long f0:f0;
        int;
};

ASAN Output

AddressSanitizer:DEADLYSIGNAL
=================================================================
==2244418==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000008 (pc 0x561ae261f12c bp 0x6040000136e4 sp 0x7fa6437fa390 T1)
==2244418==The signal is caused by a READ memory access.
==2244418==Hint: address points to the zero page.
    #0 0x561ae261f12b in get_enum_basic_type c2mir/c2mir.c:5760
    #1 0x561ae261f12b in set_type_layout c2mir/c2mir.c:6071
    #2 0x561ae26af374 in check c2mir/c2mir.c:9674
    #3 0x561ae26b8fa0 in check c2mir/c2mir.c:9215
    #4 0x561ae26b1b1f in check c2mir/c2mir.c:8286
    #5 0x561ae26cbead in check_decl_spec c2mir/c2mir.c:6645
    #6 0x561ae26ae527 in check c2mir/c2mir.c:9156
    #7 0x561ae26b1b1f in check c2mir/c2mir.c:8286
    #8 0x561ae26b1099 in check c2mir/c2mir.c:9431
    #9 0x561ae26f4314 in do_context c2mir/c2mir.c:9697
    #10 0x561ae26f4314 in c2mir_compile c2mir/c2mir.c:13481
    #11 0x561ae26f7d6a in compile c2mir/c2mir-driver.c:498
    #12 0x7fa646e68608 in start_thread /build/glibc-SzIz7B/glibc-2.31/nptl/pthread_create.c:477
    #13 0x7fa646d8d132 in __clone (/lib/x86_64-linux-gnu/libc.so.6+0x11f132)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV c2mir/c2mir.c:5760 in get_enum_basic_type
Thread T1 created by T0 here:
    #0 0x7fa647012815 in __interceptor_pthread_create ../../../../src/libsanitizer/asan/asan_interceptors.cc:208
    #1 0x561ae260c6f8 in init_compilers c2mir/c2mir-driver.c:540
    #2 0x561ae260c6f8 in main c2mir/c2mir-driver.c:656

==2244418==ABORTING

Found while fuzzing d51b45f, verified with cf3c9c1

I fixed this one by 666a9fd