This, I think, to stop \extrafloats reaching down in to the "classic" range
0-255.
I just added the line marked.

\documentclass{minimal}
\makeatletter
\def\extrafloats#1{%
\ifnum#1>\z@
\count@\numexpr\float@count-1\relax
  \ifnum\count@<\@cclvi \ch@ck0\m@ne\insert\fi%<<<<<<<<<<<<
  \ch@ck0\count@\count
  \ch@ck1\count@\dimen
  \ch@ck2\count@\skip
  \ch@ck4\count@\box
\global\e@alloc@chardef\float@count\count@
\global\expandafter\e@alloc@chardef
            \csname bx@\the\float@count\endcsname\float@count
\@cons\@freelist{\csname bx@\the\float@count\endcsname}%
\expandafter
\extrafloats\expandafter{\numexpr#1-1\relax}%
\fi}%


\newcommand{\stressInsert}[1]{%
  \@tempcnta=0\relax%
  \@whilenum\the\@tempcnta<#1\do%
   {\advance\@tempcnta +1\relax%
    \expandafter\newinsert\csname TestInsert\the\@tempcnta\endcsname%
    \message{insert \the\@tempcnta:  \number\csname
TestInsert\the\@tempcnta\endcsname,  \the\allocationnumber^^J}%
   }%
  }
\makeatother
\stressInsert{70000}
\begin{document}
\end{document}

On Wed, 5 Apr 2023 at 10:40, David Carlisle <d.p.carli...@gmail.com> wrote:

> The code (and error messages) you are showing are from latex  not from the
> luatex engine.
> so should be reported https://github.com/latex3/latex2e/issues not here
>
> If you stress \newinsert that much, as documented in source2e.pdf
> (ltplain.dtx)
> it will shuffle some float box allocations around but it does look like it
> does not
> correctly trap the end condition. Other engines (even when they have e-tex
> extended
> registers) count down from 255 for \newinsert. so get to 0 without any
> complication
> around legacy use of 255. lualatex is counting down from a few thousand.
>
> In practice latex doesn't use insert much (it only uses two inserts by
> default) so apart from
> test cases this seems unlikely to ever occur in practice but we should
> probably fix.
>
> At least I suspect a fix is needed, I haven't fully traced what your log
> is showing yet.
>
> David
>
>
> On Wed, 5 Apr 2023 at 07:54, Martin Münch <martin.mue...@uni-bonn.de>
> wrote:
>
>> May the file LuaInsert.tex consist of
>>
>>
>> \documentclass{minimal}
>> \makeatletter
>> \newcommand{\stressInsert}[1]{%
>>   \@tempcnta=0\relax%
>>   \@whilenum\the\@tempcnta<#1\do%
>>    {\advance\@tempcnta +1\relax%
>>     \expandafter\newinsert\csname TestInsert\the\@tempcnta\endcsname%
>>     \message{insert \the\@tempcnta: \the\allocationnumber^^J}%
>>    }%
>>   }
>> \makeatother
>> \stressInsert{70000}
>> \begin{document}
>> \end{document}
>>
>>
>> then
>>
>>  > lualatex LuaInsert.tex
>>
>> creates LuaInsert.log, which also contains:
>>
>> This is LuaHBTeX, Version 1.16.0 (TeX Live 2023)  (format=lualatex
>> 2023.4.4)
>> ...
>> \TestInsert1=\insert199
>>   insert 1: 199
>> \TestInsert2=\insert198
>> insert 2: 198
>> ...
>> \TestInsert17=\insert183
>> insert 17: 183
>>                               [ *** 1st JUMP HERE *** ]
>> \TestInsert18=\insert252
>> insert 18: 252
>> \TestInsert19=\insert251
>> insert 19: 251
>> ...
>> \TestInsert68=\insert202
>> insert 68: 202
>> \TestInsert69=\insert201
>> insert 69: 201
>>                               [ *** 2nd JUMP HERE *** ]
>> \TestInsert70=\insert65534
>> insert 70: 65534
>> \TestInsert71=\insert65533
>> insert 71: 65533
>> ...
>> \TestInsert65350=\insert254
>> insert 65350: 254
>> \TestInsert65351=\insert253
>> insert 65351: 253
>> \TestInsert65352=\insert252 [ *** AGAIN?! ***]
>> insert 65352: 252
>> \TestInsert65353=\insert251 [ *** AGAIN?! ***]
>> insert 65353: 251
>> ...
>> \TestInsert65368=\insert236 [ *** AGAIN?! ***]
>> insert 65368: 236
>> \TestInsert65369=\insert235 [ *** AGAIN?! ***]
>> insert 65369: 235
>> ! No room for a new \count .
>> \ch@ck ...\else \errmessage {No room for a new #3}
>>                                                    \fi
>> l.12 \stressInsert{70000}
>>
>> ? x
>>
>> So, are \insert252 to \insert235 used twice?!
>>
>> And Lua does not even stop there because of "No room for a new insert",
>> but because there is no room for a new \count! Otherwise more inserts
>> would see double use?
>> Should after \insert253 (!, not 235) the next \newinsert produce some
>> error "No room for a new \insert"?
>> _______________________________________________
>> dev-luatex mailing list
>> dev-luatex@ntg.nl
>> https://mailman.ntg.nl/mailman/listinfo/dev-luatex
>>
>
_______________________________________________
dev-luatex mailing list
dev-luatex@ntg.nl
https://mailman.ntg.nl/mailman/listinfo/dev-luatex

Reply via email to