tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] standalone backtraces


From: grischka
Subject: Re: [Tinycc-devel] standalone backtraces
Date: Sun, 19 Jan 2020 02:01:57 +0100
User-agent: Thunderbird 2.0.0.23 (Windows/20090812)

Herman ten Brugge via Tinycc-devel wrote:
Thanks for doing this. This was indeed needed.

There are 2 problems I see.

The first one is that you removed the alloca/vla code for bounds checking.
The following program:

extern void *alloca(int size);
void tst1(void) { void *a = alloca(16); }
void tst2(void) { int i; int a[10]; for (i=0;i<10;i++)a[i]=0; }

int main(void) { tst1(); tst2(); }

When compiled with bounds checking it fails. The alloca
is not deleted because no __bound_local_delete is generated.
The original code in tccgen.c created a dummy lbounds section
so that __bound_local_new(not needed) and __bound_local_delete
were generated.

How many dummy entries do you need to make sure __bound_local_delete
is called, and do you need any at all, really?

For the same reason the tests/tests2/79_vla_continue.c fails when
compiled with bounds checking.


The other problem is that testcase 112 produces on linux:
# ./tcc -b -dt 112_backtrace.c -o 112_backtrace -Dtest_bcheck_100
# ./112_backtrace
112_backtrace.c:107: at main: BCHECK: 0x7ffed562f6e4 is outside of the
region
112_backtrace.c:107: at main: BCHECK: invalid pointer 0x7ffed562f6da,
size 0xa in memcpy dest

This looks correct.

But on windows (and wine) I get:
# ./tcc.exe -b -dt 112_backtrace.c -o 112_backtrace.exe -Dtest_bcheck_100
# ./112_backtrace.exe
00401535 : at ???: BCHECK: 000000000022FA84 is outside of the region
00404447 : by ???
00404666 : by ???
112_backtrace.c:107: by main
0040447a : at ???: BCHECK: invalid pointer 000000000022FA7A, size 0xa in
memcpy dest
00404666 : by ???
112_backtrace.c:107: by main

That looks like missing -g when bcheck.c was compiled.

Btw, there seems to be a bug in the sym-version code that crashes
tcc when it tries to link with a .so, for example:

    echo "void f() {}" | tcc - -shared -o a.so
    echo "main() {}" | tcc - a.so
    <segmentation fault>

Thanks,

--- grischka

All other tests in 112_backtrace.c have simular problems.

Perhaps I did something wrong with windows/wine. I only use windows
to update my tomtom.

The makefile for wine I used is at: https://svn.code.sf.net/p/wintcc/svn

Regards,

        Herman

On 2020-01-17 23:21, grischka wrote:
Hi folks,

Thought the entire bcheck stuff is pretty much completely useless
if it doesn't give you any hint where in the your code the problem
actually happens.  So I added some patch of mine that allows tcc to
include the backtrace features for -run into standalone executables.

It should work with DLLs/SOs too (i.e. multiple instances of stab
debug infos).  See

    https://repo.or.cz/tinycc.git/commitdiff/ef42295f

--- grischka



reply via email to

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