[BRLTTY] Solaris memory leak, maybe windows too

Samuel Thibault samuel.thibault at ens-lyon.org
Wed Aug 19 18:57:55 EDT 2009


Hello,

After more debugging, it seems the culprit is variable-length arrays,
which aren't freed by the solaris C compiler.  I remembered something
like that on the Cell processor and checked C99:

“An object whose identier is declared with no linkage and without the
storage-class specier static has automatic storage duration. For such
an object that does not have a variable length array type, its lifetime
extends from entry into the block with which it is associated until
execution of that block ends in any way.”

So for variable-length arrays, the standard doesn't say that its
lifetime extends only to the end of the block, thus allowing compilers
to be lazy and just allocate them on the stack and not free them.  The
only portable way to free them is thus to return from the function
containing the block.  For brltty, that means making the content of the
while(1) loop a function called by runProgram, else its variable-length
arrays keep getting allocated and never freed.  Dave?

Maybe that's the same memory leak as some people have been experiencing
on windows.

Samuel


More information about the BRLTTY mailing list