# Tilde in section title + amsmath & hyperef & silence leads to crash

I stumbled upon a LaTeX crash (capacity exceeded, parameter stack size=10000) and condensed it into the minimal working example below. I assume this is a bug in one of these packages? Can anyone explain what happens here? (And, if this is a bug, which of the packages is responsible?)

I experienced this on the current TeX Live with all updates from CTAN, but I'm relatively sure I had the same problem on a fresh TeX Live 2018 install (without any CTAN updates).

\documentclass{article}

% uncommenting any one of these packages avoids the crash
\usepackage{amsmath}
\usepackage{hyperref}
\usepackage{silence}

\begin{document}
\section{$\tilde O$}
% \section[]{$\tilde O$}     % using this instead of line above also prevents crash, even with all three packages above
\end{document}


I would say it is not really a bug. hyperref removes the math shift ($) when creating the bookmarks (you can see the warning in the log), this means that the \tilde now should normally give an error as it is outside math. The code in hyperref tries to prevent this, but as silence redefines \PackageError the hyperref code now fails. Imho the best is to use \texorpdfstring to avoid that the tilde is used in the bookmarks. You can also use \pdfstringdef to give the tilde a more safe definition. \documentclass{article} % uncommenting any one of these packages avoids the crash \usepackage{amsmath} \usepackage{silence} \usepackage{hyperref} %\pdfstringdef{\tilde}{} \begin{document} \section{\texorpdfstring{$a\tilde{O}$}{aO}} \end{document}  • I see, thanks for the explanation! I still don't quite get the role amsmath, but that's a minor point. – Peter Kling Apr 20 '19 at 14:54 • amsmath changes the definition of \tilde from \mathaccent "707E\relax to \protect \mathaccentV {tilde}07E. – Ulrike Fischer Apr 20 '19 at 14:57 • I see, thanks for the clarification! – Peter Kling Apr 20 '19 at 15:38 seems like silence has defeated the normal protection mechanism, simplest is not to use the package (disabling warnings seems a suspicious thing to do anyway) but you could make \tilde etex \protected robust then it is safe again, adding \protected\expandafter\def\expandafter\tilde\expandafter{\tilde}  after the packages makes the document work (with warnings from hyperref) You wouldn't get the tilde in the bookmarks anyway, so my suggestion is to add a definition for \tilde in the bookmarks. Load silence before hyperref. \documentclass{article} \usepackage{amsmath} \usepackage{silence} \usepackage{hyperref} \WarningFilter{hyperref}{Token not allowed} \pdfstringdefDisableCommands{\let\tilde\relax} \begin{document} \section{$\tilde O\$}