"For 'tis the sport to have the enginer
Hoist with his own petard"
Wm. Shakespeare, "Hamlet"
A petard was a bomb used to blow up castle walls, and the engineer was responsible for setting the bomb. The bomb would sometimes go off prematurely, sending skyward, or hoisting, the engineer, probably in pieces.
Apparently, in Hamlet's day it was considered great fun when the engineer blew himself to bits with his own bomb.