[Tinycc-devel] bugs: global state corruption after setjmp()

2008-04-20 Thread egodust
Heyas, Using libtcc in the following way shows up some bugs, the first bug hides the second bug. tcc=tcc_new(); tcc_add_file(tcc, bad.c); // returns 0 as expected tcc_delete(tcc); tcc=tcc_new(); // -- fails with :1: invalid macro name '' The global state is left unclean because the error

Re: [Tinycc-devel] libtcc API v.s. global state v.s. tcc state

2008-04-20 Thread grischka
From: egodust: My version of tcc_export_binary_image() just *moves* the pointers inside the state structure into the binary structure, tcc still owns the memory, thats why *free() is needed, tcc_free() doesn't deep free and tcc_delete() only works on TCCState objects. Ah, okay. I thought you

Re: [Tinycc-devel] libtcc API v.s. global state v.s. tcc state

2008-04-20 Thread egodust
Heyas, On Sun, Apr 20, 2008 at 7:10 PM, grischka [EMAIL PROTECTED] wrote: Ah, okay. I thought you wanted to copy all the section data into one single piece of flat memory, like: |text--data-bss---| This to free is plain easy. It is (moderately) more complex to make,

Re: [Tinycc-devel] libtcc API v.s. global state v.s. tcc state

2008-04-20 Thread grischka
From: egodust: 1. tcc_new() MUST be matched by a tcc_delete() that share the same sections, i.e. no mixing of different states, only ONE state is allowed to exist at a time because of global copies. No, that does not follow necessarily. It only means that only one state can have global copies.

Re: [Tinycc-devel] libtcc API v.s. global state v.s. tcc state

2008-04-20 Thread egodust
Hey, On Sun, Apr 20, 2008 at 8:50 PM, grischka [EMAIL PROTECTED] wrote: From: egodust: 1. tcc_new() MUST be matched by a tcc_delete() that share the same sections, i.e. no mixing of different states, only ONE state is allowed to exist at a time because of global copies. No, that does

Re: [Tinycc-devel] libtcc API v.s. global state v.s. tcc state

2008-04-20 Thread David Given
grischka wrote: [...] Well, I need to suggest something. So, maybe I'd move the bits in tcc_delete, that mess with globals, out from tcc_delete into another function. Then that function (name it tcc_cleanup) can be called from tcc_new instead. How is this? Well, speaking as someone who

Re: [Tinycc-devel] libtcc API v.s. global state v.s. tcc state

2008-04-20 Thread grischka
From: David Given: grischka wrote: [...] Well, I need to suggest something. So, maybe I'd move the bits in tcc_delete, that mess with globals, out from tcc_delete into another function. Then that function (name it tcc_cleanup) can be called from tcc_new instead. How is this?

Re: [Tinycc-devel] libtcc API v.s. global state v.s. tcc state

2008-04-20 Thread grischka
From: egodust: Yes, but then there is a memory leak!, tcc_new() overwrites globals with section data that tcc_delete() frees, it can only free the 'last known' section, i.e. As far as I can see all section data can be reached from the TCCState itself. For example symtab_section is in the