tinycc-devel
[Top][All Lists]
Advanced

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

[Tinycc-devel] Some Leaks isolated and kinda fixed


From: Thomas Harning Jr.
Subject: [Tinycc-devel] Some Leaks isolated and kinda fixed
Date: Wed, 08 Oct 2003 13:06:09 -0400

I've run a commercial Win32 debugger tool on my direct port of TCC [VERY few changes, except the fact that TCC isnt an executable and can't create executables, o, a, so   or their Win32 counterparts [yet?] as well as no memory bounds checker] so the leaks should still be present and fixed the same way on TCC 0.9.20
...
As an aside, would it be permissible for me to set up my own TCC-Win32 sourceforge project to have the Win32 version openly developed alongside TCC.  I would attempt to port each change of the original TCC each version change and any fixes that are independent of our project being Win32, would be presented in a way that it could possibly be put back into TCC [perhaps with feedback/the change to make our fix better]
I've found that compiling TCC on VC++ can make the code contained inside an EXE that uses the library directly to ~48 KB [compressed w/ UPX by ~50%].  Surprisingly, the EXE also uses C++ and a thin wrapper around the library functions, so being that VC oftentimes can bloat code, it squeezes this code great.
...

I found 2 leaks with the stack trace which I'll put later.

The fix: put these 2 lines in tcc_delete somewhere [anywhere really, since they aren't part of the TCCState ]

local_stack leaked 32 bytes
tokcstr leaked 8 bytes

 /** ADDED - MetX **/
tcc_free(local_stack);
cstr_free(&tokcstr);


Version of TCC before port: 0.9.20
Note: the local_stack was after a call to tcc_compile_string that resulted in an error due to declaration of a function twice [though that appears not to be the cause and shouldnt be].
Those 2 variables are left dangling after these function stacks:
all in file: tcc.c
[rel : ##] relative line # in the function
[line: ##] line # in my source file , dont rely.. but its good for quicker lookup
[local_stack]
tcc_compile_string      [line: 8784]    [rel: 20]
->tcc_compile           [line: 8741]    [rel: 66]  @ decl(VT_CONST)
->decl                  [line: 8586]    [rel: 122] @
sym_push2(&local_stack, SYM_FIELD, 0, 0);
->sym_push2             [line: 1525]    [rel: 2]
->tcc_malloc            [line: 877]     [rel: 2]

[tokcstr]
next_nomacro1   [line: 3408]    [rel: 194]
->cstr_cat              [line: 1345]    [rel: 4]
->cstr_realloc          [line: 1331]    [rel: 9]
...


Hope this helps fix the problem where it starts... perhaps with the way this works tcc_delete is where it should go.. haven't delved into the source layout that much yet.
Going to use the program and perhaps i can get a good layout of call orders, etc.

reply via email to

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