[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] standalone backtraces
From: |
Herman ten Brugge |
Subject: |
Re: [Tinycc-devel] standalone backtraces |
Date: |
Sun, 19 Jan 2020 09:58:01 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 |
On 2020-01-19 02:01, grischka wrote:
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?
I need only 1. I modified the code. See attached patch.
This solves both problems.
There is no alloca_free() so I need a trigger to remove the alloca/vla data.
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.
Oops. Need more coffee.
Fixed the Makefile.
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>
I cannot reproduce this. I checkout a fresh copy and see no problem.
I use Fedora 31 with all updates.
Regards,
Herman
patch
Description: Text document
- [Tinycc-devel] standalone backtraces, grischka, 2020/01/17
- Re: [Tinycc-devel] standalone backtraces, Christian Jullien, 2020/01/18
- Re: [Tinycc-devel] standalone backtraces, Herman ten Brugge, 2020/01/18
- Re: [Tinycc-devel] standalone backtraces, grischka, 2020/01/18
- Re: [Tinycc-devel] standalone backtraces,
Herman ten Brugge <=
- Re: [Tinycc-devel] standalone backtraces, grischka, 2020/01/19
- Re: [Tinycc-devel] standalone backtraces, Christian Jullien, 2020/01/19
- Re: [Tinycc-devel] standalone backtraces, Herman ten Brugge, 2020/01/19
- Re: [Tinycc-devel] standalone backtraces, Herman ten Brugge, 2020/01/19
- Re: [Tinycc-devel] standalone backtraces, Michael Matz, 2020/01/20