A fresh cup of coffee is the best weapon when dealing with bugs - for one thing walking away from the PC and making yourself a cup lets your mind concentrate on the issues, usually without you being aware of it. I've lost count of the number of times I've gone and made a coffee after getting frustrated with a bug, then when I come back it just seems to 'occur' to me what's wrong after a few minutes.
It's good to break away and do something moronic, like make a coffee, do the dishes, watch some TV - main thing is to turn away from the PC so your mind isn't stuck in the same 'loop' - hell I often sit there, then all of a sudden I'll just forget what I've been doing, I'll change code, build, run, and then have to stop and think what I'm supposed to be testing. It happens when you spend far too long in front of a computer, brain gets exhausted and needs to re-charge, like every hour take a 10 minute break, and it's just great for productivity in the long run. Actually going to bed at a reasonable hour is another one - I'm more productive if I get to sleep and get up earlier, put that morning energy to good use. Often, you get stuck in a slump when working late, and hours can pass with very little progress, sleep, eat, and have a run at it the next day. It can turn a show-stopping bug from the night before into a non-concern.
Unless you get a brain bug, when you are trying to sleep but come up with an idea, or a fix for a bug that's been annoying you, and you don't want to sleep and forget the solution - in that case I would consider getting back up and doing the work, maybe have a snack, then sleep much better after that.