Disable Low-Voltage ICSP
Low voltage ICSP programming mode is enabled by default on the PIC18F242. In this mode, RB5 can't be used as a general-purpose I/O pin, which caused havoc for my Ifos project. Simply reorienting the breadboard or touching a connector would cause the device's heartbeat LED to freeze, then resume after a random interval.
I finally realized that stray voltages were actually causing it to enter low-voltage programming mode, after which it would time out and reset itself. Clearing the appropriate configuration bit (LVP in CONFIG4L) trivially solved the problem. Chalk up another issue to my lack of experience with PICs.