Things got nasty on the set of the upcoming "Joker" movie over the weekend ... we're told extras were locked on a subway car for more than 3 hours, and it got so bad some people started peeing on the tracks.

Sources on set tell TMZ ... extras for the movie were filming a scene in a Brooklyn subway station and they were locked in a train car and denied their break after 2 hours of work ... leading to a sticky situation.

The extras started banging on the subway doors asking to be let out because people needed to use the bathroom, but they were kept inside and eventually resorted to pissing on the tracks through the small spaces between cars.

We've learned SAG received a complaint about a break time violation and they sent a rep to the set to resolve the situation ... and SAG will continue to follow up and monitor the set.