I think they can time these things by the time of the concert. Also I don't know how much water they drink or food they eat before hand. But after practicing for so long on the concert i'm sure they can think of a time to use the restroom.
(For those who don't know what happened, Fergie was performing as Black Eyed Peas and she drank too much water but didn't have time to pee so she ran onstage and while performing she had peed her pants.)