Psalm 40:2

Amplified Bible (AMP)
2 He drew me up out of a horrible pit [a pit of tumult and of destruction], out of the miry clay (froth and slime), and set my feet upon a rock, steadying my steps and establishing my goings.

King James 2000 Bible (©2003)
He brought me up also out of a horrible pit, out of the miry clay, and set my feet upon a rock, and established my steps.

Barnes’ Notes on the Bible

He brought me up also out of an horrible pit – Margin: “A pit of noise.” The word used here means a pit; a cistern; a prison; a dungeon; a grave. This last signification of the word is found in
Psalm 28:1Psalm 30:4Psalm 88:4Isaiah 38:18Isaiah 14:19.
It may refer to any calamity – or to trouble, like being in a pit – or it may refer to the grave. The word rendered “horrible” – שׁאון shâ’ôn – means properly “noise, uproar, tumult,” as of waters; of a crowd of men; of war. Then it seems to be used in the sense of “desolation” or “destruction,” as applicable to the grave. DeWette understands it here of a pit, a cavern, or an abyss that roars or is tumultuous; that is, that is impassable. Perhaps this is the idea – a cavern, deep and dark, where the waters roar, and which seems to be filled with horrors. So Rosenmuller understands it. The Septuagint renders it: ἐκ λάκκου ταλαιπωρίας ek lakkou talaipōrias, “a lake of misery.” It is a deep and horrid cavern, where there is no hope of being rescued, or where it would seem that there would be certain destruction…
” Jesus is a life style ” notes… 
Integrity. From James 1, passing the test! Meaning of the word temptation. Turin, Jan 23rd 2013.