Bug introduced in 9.0 or earlier, persisting through 13.2 or later
With the following Dynamic
cell, I can reproducibly crash Mathematica, so do not try this unless you have saved all your work!
l=1;
Dynamic[Sin[l = l + 1]]
This will harmlessly run forever, or until you try to right-click on the dynamic output (to get the context menu and perhaps to copy the current value). When you right-click on it, Mathematica crashes.
Is there a simple way to avoid or catch this error before it occurs?
Edit
I also see this crash when literally using the example from the documentation for Dynamic
(under "Applications"):
{Trigger[Dynamic[x, (a = FractionalPart[#]; x = Round[#]) &], {0,
Infinity}],
Dynamic[{Quotient[x, 60], Mod[x, 60], SetPrecision[10 a, 2]}]}
and again trying to right-click. So it's not like I'm doing something outlandish here.
Edit 2 The link Szabolcs found does indeed answer my question:
EventHandler[Dynamic[Sin[l = l + 1]], {"MouseUp", 2} :> Null]
seems to prevent the crash.