Data and LaForge are enjoying a Sherlock Holmes holoprogram when LaForge notices an NPC glitch.
Because they have more important things to do, they call Barclay, who inadvertently activates the sentient Moriarty simulation (from s2e3, “Elementary, Dear Data“). Picard is shocked to learn that Moriarty has experienced consciousness while stored in the computer databank. Moriarty becomes convinced Picard lied to him about asking Starfleet to work on a method to let Moriarty exist off the holodeck.
Moriarty shows a stunned Picard, Data and Barclay that he can leave the holodeck and walk out into the corridor without disappearing. Crusher reports that when she scans him, he seems human, and LaForge reports no signs that he’s going to disintegrate as they would expect of holo-matter.
As Moriarty grapples with the fact he’s on a starship, and asks whether he can bring the fictional love of his life, the Countess Regina Bartholomew, off the holodeck as well. Picard responds with sympathy, but because nobody can explain why Moriarty can exist off the holodeck, there’s no guarantee that the countess could as well.
I thought I remembered this episode pretty well, but some of the plot twists stillI caught me by surprise because I was so thoroughly enjoying Picard wrestling with the moral implications and paying a social call to the charming holo-countess.
Some details that seemed like weak hand-waving (such as Crusher’s unexplored statement that the mysteriously incarnated Moriarty has DNA that is “a little unusual”) end up getting a satisfying in-world explanation, and Barclay is well-used in a supporting role.
Barclay’s line referencing “a glitch in the matrix diodes” predates the movie The Matrix by five or six years. My preliminary search hasn’t turned up any previous references to the phrase “glitch in the matrix,” so it’s possible that this episode is the source of the viral phrase (though of course the idea that we might be living in a simulation, or that we might all be butterflies dreaming that we are philosophers, is an old one).