The best hardware bug I heard of was of a high-speed train in France that would just randomly do emergency stop in service, but only when passengers were on board.
Every time it happened, they took it out of service, and found nothing wrong. So they put it back in service, and it would eventually do an emergency stop.
During one test run, a test engineer riding the train went to the toilet, and as soon as he flushed the toilet, BANG! emergency stop.
He radioed the engine, and asked "what did you just do before it braked?"
— Well, I was braking downhill...
Which was strange, because on the course of the normal run, they brake downhill dozens of times. So they go on, and at the next downhill, the engine radioes "Okay! I'm gonna brake downhill", and nothing happenned.
— What were you doing when it braked the last time, asked the engine?
— Well, I was… I was in the toilet…
— Well, go to the toilet and do what you did when we get to the downhill!
So he goes to the toilet and when the engine called "Okay! I'm braking now", he flushed the can, and sure enough, the train did an emergency stop.
Now that they could reproduce the problem, they went on to find out why.
It took two minutes to notice that an engine brake remote control (the train has one engine at each end) cable was detached from the wiring cabinet wall, and fell on the relay that controls the toilet trap solenoid... When the relay operated, it induced some interference in the brake cable and the fail-safe system simply did an emergency braking.