As one of the ways this 'bug' can occur has been mentioned above, I won't repeat it. I don't usually play 1.8, but I have had this bug before, and I know it isn't that pleasant during PvP. However, there is also another way for the bug to occur (on 1.9+). When playing and having a shield in your offhand, a similar bug can also occur when you accidentally use the shield. For instance, after holding your mouse button to eat, the shield will also be used and with some misfortune, a bug will occur that will require you to re-use the shield to be able to hit other people again. During this bug, it will appear as if you are running normally whilst using a shield to other players. Besides you not being able to deal damage, other players will also be able to deal more knockback to you, as that is the case when actually using a shield and you will be able to hear the shield block sound.