Reported in the forums
We have experienced this problem before: #3259, #3816, #3859, #4221, #4330, #4974.
So my approach to fixing this bug has failed to fix it across all occurrences.
Maybe there is a better approach (such as making twig fail silently in case of such errors?)