The same thing will happen if you try to place a torch on a half-block. Is your floor made of wooden half-blocks, by any chance?
And you cannot "outrun" the GUI. Right clicking a chest with a torch in your hand opens it, the first code segment processed has to check what kind of block you're trying to interact with. If it returns that there is a right-click function, it will process that before running a placement strand.
No, I'm actually a Java programmer; I understood. I haven't looked at the code myself because I'm too impatient to deobfuscate it myself, and I haven't been able to find some pre-deobfuscated (lol) source on the web anywhere.
I'm not sure what surface to which the torch was attempting to attach, but I'll assume it's some variation on one of the oddities already mentioned.
Rollback Post to RevisionRollBack
"Don't pay any attention to the critics. Don't even ignore them." -Nicolas Negroponte
I'm pretty sure it's caused by attempting to put a torch where it can't go, into the same air block as the chest. Since there's nothing in the programming to stop them from attaching to chests, it goes there. The only reason you can't put torches directly onto chests is because 'place torch' and 'open chest' are the same button.
I do this all the time by putting a block one block in front of and over the chest (so the bottom of the block is over the air in front of the chest. Then point at the bottom of the block and place the torch. Voila! Lit chest!
The torch occupies the air block. And the chest is the only available thing to be attached to.