A heavy naval gun that has snapped its restraining tackles and is rolling freely across the gun deck. Because these iron weapons weigh several tons, a freely moving gun on a pitching ship will crush bulkheads, destroy the hull, and kill sailors until it is secured. The phrase survives as an idiom for an unpredictable danger.
Heard on the job
Secure those tackles before the sea picks up, or we'll have a loose cannon smashing through the hull.