Zolpidem is famous for this, although it’s raised more questions than answers. This particular phenomenon has been known since the early 2000s; NYT has a good write up about it: https://www.nytimes.com/2011/12/04/magazine/can-ambien-wake-...
https://en.wikipedia.org/wiki/Loa
Combine with parts of https://en.wikipedia.org/wiki/Simulation_hypothesis as you see fit, for instance some bored coder looking into why some parts of code suddenly fail, and putting you into debug mode :)
edit: also https://en.wikipedia.org/wiki/Jinn
Are you seriously suggesting that demonic possession is real and that a drug could lead to it?
treatment effective in the short term, but only in a small proportion of cases (estimated at around 5%)