magiblot / tvision

A modern port of Turbo Vision 2.0, the classical framework for text-based user interfaces. Now cross-platform and with Unicode support.
Other
1.99k stars 150 forks source link

Crash in genparts #160

Closed jengelh closed 3 months ago

jengelh commented 3 months ago

genparts invokes undefined behavior and with xSAN crashes/exits.

[ 96%] Linking CXX executable ../../genparts
cd ~/examples/tvforms && /usr/bin/cmake -E cmake_link_script CMakeFiles/genparts.dir/link.txt --verbose=1
/usr/bin/c++ -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type  -g -O0 -ggdb3 -fsanitize=address,undefined -O0 -ggdb3  -Wl,--as-needed -Wl,--no-undefined -Wl,-z,now CMakeFiles/genparts.dir/Unity/unity_0_cxx.cxx.o -o ../../genparts  ../../libtvision.a -lncursesw /usr/lib64/libtinfo.so
~/genparts
Creating  parts.f32
=================================================================
==27085==ERROR: AddressSanitizer: alloc-dealloc-mismatch (operator new vs operator delete []) on 0x516000000080
    f0 in operator delete[](void*) (/lib64/libasan.so.8+0xfcd48)
    f1 in TDataCollection::freeItem(void*) ~/examples/tvforms/datacoll.cpp:109
    f2 in TNSCollection::freeAll() ~/source/tvision/tcollect.cpp:161
    f3 in TNSCollection::shutDown() ~/source/tvision/tcollect.cpp:60
    f4 in TObject::destroy(TObject*) ~/include/tvision/tvobjs.h:52
    f5 in main ~/examples/tvforms/genform.cpp:80

0x516000000080 is located 0 bytes inside of 524-byte region [0x516000000080,0x51600000028c)
allocated by thread T0 here:
    f0 0x7f8baa2fc1d8 in operator new(unsigned long) (/lib64/libasan.so.8+0xfc1d8)
    f1 0x4164f6 in main ~/examples/tvforms/genform.cpp:70

Culprits:

        p = new TDataRec;

vs.

        delete[] (char *) item;