The Underworld AI glitch, also known as the suicidal enemy glitch, is a glitch that is only present in the first Japanese release of Final Fantasy IV. The glitch is a result of the game loading the wrong enemy table after memory address oversights involving the way the game stores the party's location.
The problem lies within memory addresses 7E1701-7E1702, which stores the current location of the player's party. If the location is 015A-015C or 0167-017E, which are all locations for dungeons on the moon, then the game sets a flag to load a separate enemy data table. Because of a shared memory byte, however, this information is not correct when on an overworld map. Once the party is on one of the maps, the game continues to store the last two bytes of the party's last location at 7E1702, and stores which map they are on at 7E1701 (00 for overworld, 01 for underworld, 02 for the moon).
Now, one should leave any area with the location 005A-005C or 0067-007E, which includes the Mist Cave, the west entrance to Mt. Hobs, Antlion's Den, basement areas of Troia and the Underground Waterway. For Troia, the only way out is the Exit spell. Once in the Underworld, the party will have a clear view of 015A-015C or 0167-017E.
With the game thinking the party is at those locations, they should find a random encounter on the underworld map, and the game will try to load the wrong table for the enemy's AI. As a result of being absolutely broken, the enemies will have no choice but to use Stone on themselves and each other until they are all dead. No enemy will ever make an attempt to harm the team.
This bug was fixed for the Revision A, or v1.1, release of Final Fantasy IV, and the fix is the only thing changed between the two versions of the game. The version this glitch is found in, dubbed v1.0, is notorious for being rumored to have been produced in a limited quantity before Square pulled it to fix this bug.