A slamfire is a premature, usually unintended discharge of a firearm that occurs as a cartridge is being loaded into the chamber. Slamfires are most common in military firearms that have a free-floating firing pin, as opposed to a spring-loaded one. In the action of a typical semi-automatic firearm, the energy of a fired round forces the bolt and bolt carrier rearward, ejecting the empty case. A spring then forces the bolt forward again, and in the process a fresh round is stripped out of the magazine. When the face of the bolt hits the head of the chamber, unless there is a spring around the pin to retard its movement, inertia causes the firing pin to continue forward until it is stopped on the primer of the round. Sometimes this inertial force is sufficient to set off the primer, thereby firing the round without the operator pulling the trigger. In semi- or fully automatic firearms this can potentially cause the firearm to fire continuously until the magazine has been emptied.
Unintended slamfires are extremely dangerous, as the shooter may lose control of the firearm when a normally semi-automatic firearm "goes full auto" unexpectedly. In particular, there is a significant risk of a semi-auto gun being uncontrollably propelled backwards by the recoil and firing rounds at the shooter and any bystanders. Slamfires are very rare in properly maintained firearms using quality ammunition and not altered outside of manufacturer specifications (especially triggers adjusted to an overly light pull weight).
It is always wise to ensure that the firearm is pointed in a safe direction ("downrange") before closing the bolt and chambering a cartridge. If a slamfire does occur, the shooter must do his best to remain calm and hold the firearm securely, pointed in a safe direction, until it ceases firing. Needless to say, this requires extraordinary discipline, and many operators will become surprised and instinctively drop the firearm as soon as it begins firing.
Aside from the dangers of any accidental discharge, slamfires present the particular risk of an out-of-battery detonation. This occurs when a round is fired before it is completely secured in the chamber, and can cause a breech explosion, leading to the firearm being damaged or destroyed, as well as potentially injuring the operator and bystanders.