A dream within a dream

How do you know that you're not dreaming? Philosophers have asked this question for centuries. Everything got mixed up. Dreams. Illusions. Hallucinations. Simulated realities. Everything in one basket.
Technically, memory hallucinations, including dreams and effects like deja vu or jamais vu, are the results of data readouts during a hot memory maintenance. Defragmentation is the key process there. We expect to see a loss of continuity. Things will suddenly disappear or appear out of nowhere. Pay attention. Make notes. Compare notes. If something is off, you'll notice that.
Also, physics will be broken. Hallucinating brains will not be able to build the reflection that matches any random object. It's just a reading process that happens in the wrong place at the wrong time. Not a computation. Combinations of pieces of data can be complex and convincing, yes, but the objects have to be saved in advance. Usually we don't see things upside down, and they're not saved in our memory like that. Therefore, horizontal reflections of them cannot be hallucinated. Actually, it's a funny problem with AI image generators. Most of them have real troubles with rendering arbitrary objects upside down. For this exact reason. Oh, and vampires and other unholy otherworldly creatures don't reflect in rivers. It's the same thing.
However, you have to remember that you need to test things. If you don't remember that, you will get the "butterfly dream", that leads to all sorts of speculations about alternative realities. Once you do the tests and see the issues, it will become clear that your memory is hallucinating.
Being inside a simulated reality is different. It's like being inside a virtual machine. Everything will look normal, consistent. When the machine is under maintenance, everything stops. Looking from the inside, you'll not notice that. You'll be stopped yourself. The time will not exist for you.
Usually, when we create malware, we want it to know that it's not inside some virtual machine under investigation. How? We collect information about the system. We know what to expect in the real machine, and we look for something out of place. Virtual machines don't simulate every aspect of real ones. It requires a lot of resources and is unnecessary for standard applications. They may simulate hardware that was never produced by any manufacturer. Sometimes we expect to see some user activity and it's not there. We can use all these things as clues.
The problem with the offline world is that we don't know what is supposed to be here. Without that knowledge, all these comparisons are useless.
What if the machine itself is glitching? It's a good question. 99% of our code is utter garbage. Why would we even think that the programmers of the matrix are better in that department? We can look for bugs. Great. How do we know that something is a bug and not a feature? We compare the system's behavior with its specification. Where is our specification for the universe? Oh, wait. We got a problem.
Even if we imagine a program that somehow understands that it is running inside a virtual machine, even if it finds a way to break out, it's still a program, just running on real hardware. There is no way out of here.