lua-users home
lua-l archive

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


I do not normally compile more than one script at a time with 'luac',
however, today I needed to do so and ran into an issue.

In the function 'combine' in the file 'luac.c' there is the following line:

f->sizelineinfo=0;

This is setting the size of the 'source line to code instruction' mapping
array to zero... without actually freeing the memory first. When running
with the 'ltests.c' module enabled the realloc function throws an assert
when trying to free the prototype as f->lineinfo still contains an allocated
block but f->sizelineinfo has been set to zero and no longer matches the
value in the memory header.

When coding and testing under 'ltests' it is inconvenient to have 'luac'
assert when compiling more than one file at a time!

I can see two possible solutions:

1) Remove the line and accept the 'luac' generated main function will
   show a source code line mapping of '1' instead of '-'.

2) Change the code as follows to free the mapping array memory:

   luaM_freearray(L, f->lineinfo, f->sizelineinfo);
   f->lineinfo = NULL; f->sizelineinfo = 0;

I have patched my version of Lua to free the memory and display a '-'
for the line number, which was the originally intended behavior.

~Paige