You are using versions of Bitcoin Core and Litecoin Core that are vulnerable to
CVE-2018-17144. Any block that exploits this vulnerability will have the side effect of causing block database corruption when the block is being reorged out of the blockchain. Furthermore, testnet is known to have blocks exploiting this vulnerability, and because you are using vulnerable versions, you are likely running into these invalid blocks which is causing your error.
If you upgrade to the latest versions of Bitcoin Core and Litecoin Core, do you still see the same problem?