[luatex] Memory leak in token.put_next() implementation
luigi scarso
luigi.scarso at gmail.com
Sun Nov 3 13:40:55 CET 2024
On Tue, 29 Oct 2024 at 06:13, user202729--- via luatex <luatex at tug.org>
wrote:
> I notice that the `run_put_next` function inserts the token list using
>
> begin_token_list(h,0);
>
> however, this has the problem that in `end_token_list`, the token list is
> not freed when the type is `0` (i.e. `parameter`).
>
> I think the `0` should be changed to e.g. `inserted` (4), so that it is
> correctly freed.
>
> For a test case, consider the following program.
>
> ```
> lualatex '\directlua{i=1; t=token.get_next()}~\def~#1A{\directlua{i=i+1;if
> i&1023==0 then print(i) end;for i=1,1000 do token.put_next(t); end}A}~A'
> </dev/null
> ```
>
> Before the change, the memory usage grows steadily. After the change, the
> memory usage remains constant.
>
> Please take a look. Thank you.
>
>
commit cd4888ec08e37cf0beae04be0a904d1df17eac41
Author: Luigi Scarso <luigi.scarso at gmail.com>
Date: Sun Nov 3 13:17:40 2024 +0100
Fixed a memory leak in token.put_next() and token.set_macro() (thanks
to user202729 at protonmail.com)
(also in texlive)
--
luigi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://tug.org/pipermail/luatex/attachments/20241103/2df6fe62/attachment.htm>
More information about the luatex
mailing list.