I was told that it happened in Chicago, but the story is apocryphal. An obstreperous drunk disturbs the morning docket at the jail. The judge gets sufficiently angry to have the guy brought before him and he holds a quick trial which results in the defendant's getting the death penalty.
In a case like that, the trial court's lack of subject matter jurisdiction would not have to be preserved.
Subject matter jurisdiction is never presumed and cannot be waived. Texas Association of Business v. Texas Air Control Board, 852 S.W.2d 440, 443-444 (Tex. 1993). If a trial or appellate court inappropriately takes up a matter it does not have the power to, that lack of authority can be brought up at any time.
Anybody's who's been to law school or hung out a lot with a person who's been to law school, knows that practically every legal rule has exceptions. We'll catch up on another exception next week.