Randomly occurring memory error

This is indeed likely a memory error, and the location of the complaint is generally not the location of the bug. Can you run with valgrind and upload the output as an attachment, please?