I recently fixed a defect in our product, the symptom of which was an access violation caused by accessing a dangling pointer.
For good practice I added a unit test
I ran into this years ago in reverse: The problem was only occurring when the debugger was not attached.
It turned out the code was corrupting the stack-frame of the previous method activation and using the debugger introduced an intermediate stack-frame.
You possibly have a similar situation.