[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] tcc fails UBSan and ASan

From: Michael Matz
Subject: Re: [Tinycc-devel] tcc fails UBSan and ASan
Date: Sun, 27 Jan 2019 01:12:25 +0100 (CET)
User-agent: Alpine 2.21 (LSU 202 2017-01-01)


On Sat, 26 Jan 2019, Giovanni Mascellani wrote:

This already prints lots of errors when tcc compiles libtcc1.a, mostly
about unaligned struct access. An example:

tcctools.c:189:21: runtime error: member access within misaligned address 
0x564f628c4d3c for type 'struct Elf64_Shdr', which requires 8 byte alignment
0x564f628c4d3c: note: pointer points here
  00 00 00 00 01 00 00 00  01 00 00 00 06 00 00 00  00 00 00 00 00 00 00 00  00 
00 00 00 40 00 00 00

Uninteresting problem. TCC supports only architectures where non-naturally aligned accesses are fine (or at least 4-byte aligned accesses).

tcctest.c: In function ‘switch_test’:
tcctest.c:1969:6: error: case label does not reduce to an integer constant
      case 4LL << 61:

That's tcctest.c. It intentionally contains several non-standard constructs.

Some use-after-free are found in 07_function, 25_quicksort,
26_character_constants and 80_flexarray.

Also testcases. They shouldn't be changed to cater for such checking (or if, then only carefully so, so that they afterwards indeed still test what they were supposed to).

I can try to fix them, but maybe people more knowledgable than me might
be quicker and produce a more correct fix.

If you can fix the misaligned accesses without using memcpy or similar 100% portable means that just busily change code to please automatic tools then fine. Please don't change the testcases for automatic tools.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]