I tested it now. a sinval message is waiting on the transaction end. So when a variable is used, then it is working fine until the transaction ends.
But when the session makes some DDL, then send sinval to self, and at this moment, the variable can be dropped before the transaction ends.
a backend can accept sinval in very common scenarios, like acquiring a heavyweight lock. That includes accessing a relation thats not in the catcache, so that's really critical to have a protection here.