If you open /var/report/300877676469, changes are you get a message like that :
The error appears to come from a plugin from the Page Cache Magento module.
Let edit the plugin a bit to make it log the problematic string (don’t forget to roll back the modification after the debug session) :
You’ll get the HTML that was fetched from the cache logged to var/log/pagecache- followed by the current timestamp.
Now we can use grep that log to print the lines that contains invalid UTF-8 characters :
Seems the rendering of our meta description is responsible for the crash. Now let’s go to the code that prints that tag:
substr truncates the string regardless the encoding. Usually characters are encoded with a single byte, but UTF-8 character may be composed of two, three or even four bytes.
Using substr here works only works if the 150th byte is not part of a multi-byte character, and won’t behave as expected (but won’t cause a crash) if the string contains multi-byte characters before the 150th byte.
Replacing substr by mb_substr solves the problem :