Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hook enddocument/info is written twice if rolled back #1407

Open
muzimuzhi opened this issue Jul 10, 2024 · 3 comments
Open

Hook enddocument/info is written twice if rolled back #1407

muzimuzhi opened this issue Jul 10, 2024 · 3 comments
Labels
bug category base (latex) fixed in dev Fixed in development branch, not in stable release

Comments

@muzimuzhi
Copy link
Contributor

Brief outline of the bug

If LaTeX is rolled back to 2020-10-01 or later, enddocument/info hook is written twice, once by the format and once by rollback code. This causes the file list (if enabled), end document warnings (if exist), and release info written to log twice.

Minimal example showing the bug

\RequirePackage{latexbug}       % <--should be always the first line (see CONTRIBUTING)!
\RequirePackage[2023-11-01]{latexrelease}
\documentclass{article}

\ShowHook{enddocument/info}

\begin{document}
\end{document}

shows in the log

-> The hook 'enddocument/info':
> Code chunks:
>     kernel/filelist -> \@dofilelist \@dofilelist 
>     kernel/warnings -> \@enddocument@kernel@warnings \@enddocument@kernel@war
nings 
>     kernel/release -> \let \show@release@info \wlog \show@release@info { ****
*******}\the \LaTeXReleaseInfo \show@release@info { ***********}\let \show@rele
ase@info \wlog \show@release@info { ***********}\the \LaTeXReleaseInfo \show@re
lease@info { ***********}
> Document-level (top-level) code (executed last):
>     ---
> Extra code for next invocation:
>     ---
> Rules:
>     kernel/warnings|kernel/filelist with relation >
>     kernel/release|kernel/filelist with relation <
> Execution order (after applying rules):
>     kernel/release, kernel/filelist, kernel/warnings.
<recently read> }
                 
l.5 \ShowHook{enddocument/info}

Log file (required) and possibly PDF file

enddocument-info-hook-doubly-written.log

Related source code

  • \IncludeInRelease{2023/11/01}

    latex2e/base/ltmiscen.dtx

    Lines 279 to 285 in 0a5276b

    \AddToHook{enddocument/info}[kernel/filelist]{\@dofilelist}
    \AddToHook{enddocument/info}[kernel/warnings]{\@enddocument@kernel@warnings}
    \AddToHook{enddocument/info}[kernel/release]{%
    \let\show@release@info\wlog
    \show@release@info{ ***********}%
    \the\LaTeXReleaseInfo
    \show@release@info{ ***********}}
  • \IncludeInRelease{2020/10/01}

    latex2e/base/ltmiscen.dtx

    Lines 392 to 398 in 0a5276b

    %<latexrelease>\AddToHook{enddocument/info}[kernel/filelist]{\@dofilelist}
    %<latexrelease>\AddToHook{enddocument/info}[kernel/warnings]{\@enddocument@kernel@warnings}
    %<latexrelease>\AddToHook{enddocument/info}[kernel/release]{%
    %<latexrelease> \let\show@release@info\wlog
    %<latexrelease> \show@release@info{ ***********}%
    %<latexrelease> \the\LaTeXReleaseInfo
    %<latexrelease> \show@release@info{ ***********}}
@FrankMittelbach
Copy link
Member

I guess the solution is to clear the hook first since we do not know from which version we roll back and none of the later code should be there.

FrankMittelbach added a commit that referenced this issue Jul 10, 2024
@muzimuzhi
Copy link
Contributor Author

Or skip both the \NewHook{<hook>} and \AddToHook{<hook>}{<code>} if such <hook> already exists?

@FrankMittelbach
Copy link
Member

\NewHook is needed in case of roll forward and it is properly handled/suppressed by the rollback code, so I think it is correct the way it is

FrankMittelbach added a commit that referenced this issue Jul 13, 2024
* fix for #1407

* corrections

* further suggestions by CAR
@FrankMittelbach FrankMittelbach added the fixed in dev Fixed in development branch, not in stable release label Jul 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug category base (latex) fixed in dev Fixed in development branch, not in stable release
Projects
Status: Done in dev
Development

No branches or pull requests

2 participants