Currently, this is possible:
- Someone has a very old P2SH-invalid block in his block file
- When importing this block file, it gets accepted (because script checks that would catch this are disabled before the last checkpoint)
- It gets immediately reorganized when a later block is imported
- When disconnecting, its transactions enter the memory pool, as again, signature checks are disabled
- As long as not rebooted, this transaction remains in the mempool, and causes a (harmless) error to be reported when trying to construct a block
Two solutions (and I think both are useful anyway):
- During IBD, don't move disconnected transactions to the mempool at all
- Do not disable signature checks from disconnected transactions entering the mempool
Thanks to @gmaxwell for spotting a weird P2SH-invalid transaction in his mempool.