Op 13-10-2025 om 04:00 schreef Lioric Z3:
>There are no memory errors reported by the sanitized tcc compiler.
>So how can I reproduce this?

Forgot to mention that this leak was initially observed when compiling to a memory target using *libtcc*, with *backtrace* enabled and *stabs debug symbols* generated. But I don’t see any reason this behavior would differ when compiling with the *tcc executable*, so I tested it there as well — and the bug is reproducible using the "|-g -bt"| options. (without debug symbols or backtrace, the memory limit is rarely reached, so the leak does not appear.) I have *not* yet tested with backtrace disabled, so please make sure to build TCC with "|--config-backtrace=yes" configure option| when reproducing. The macro string needs to be large enough for the reallocator to switch to the *native allocator* (via |default_reallocator|). I haven’t yet traced why the memory limit is hit so quickly when debug symbols and backtrace information are enabled, but I probably the *debug symbol allocations* also use the *TAL allocator*, which could fill the memory pool faster. That said, this is still speculation — I haven’t traced the stabs debug handling or creation paths at all yet.
In my local setup, the issue can be reproduced with the following code:
----------

#define cl_inst(cl) \
void $_##cl##_ctor(void* addr) { cl obj = (cl)addr; obj->$meta = $_##cl##_OM; } \ void $_##cl##_hx_construct(cl this, int i, float f, bool b) { this->iValue = i; this->fValue = f; this->bValue = b; } \ static inline cl $_new_##cl() { return $_new($_##cl##_OM->size,#cl,$_##cl##_ctor); } \
static const int $_sMemberFields[] = { \
{&OS_STRING_S("iValue",0), 1,offsetof(obj,name)}, \
{&OS_STRING_S("fValue",0), 2,offsetof(obj,type)}, \
{&OS_STRING_S("bValue",0), 3,offsetof(obj,offset)}, \
{0} \
}; \
#line 1 ""

cl_inst(int);
This testcase helped a lot.
I pushed a fix on mob.

    Herman
_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to