The poetic parallelism between "evils" and "iniquities" is significant.
In the interlinear, the grammatical notations, coupled with the lexical aids giving the definitions for each word, are revealing. "Evils" (raowt), having the feminine plural suffix, are paired to a third-person common plural verb (apepu), but the object is slipped between, that being a preposition meaning "against" or "above" or "around" or "(down) upon" which is combined with the first-person common singular (my) pronominal suffix. (Note that first-person pronouns are always considered "common" in Hebrew, and do not have masculine or feminine forms, unlike second- or third-person pronouns.)
The link between the two clauses also ties them integrally together. What the gloss in the interlinear shows here is "innumerable else innumerable." That could actually be rendered as "until nothing numerable"--which doesn't sound good in English, but could be rephrased slightly to say: "until [they were] without number."
The KJV translation has not captured the same sense.
For innumerable evils have compassed me about: mine iniquities have
taken hold upon me, so that I am not able to look up; they are more
than the hairs of mine head: therefore my heart faileth me. (Psalm
Notice that in the KJV there is a colon (:) between these clauses. That does not exist in the Hebrew. In fact, the word translated as "iniquities" (עֲ֭וֹנֹתַי) starts with a conjunctive accent, showing it should not be separated from the previous expression. Here it is a bit larger...
The first character (on the right of the image) of this word has what appears to be a patach (like a dash), a shewa (like a colon), and the tarcha (like a backwards comma). It is that latter mark which is the conjunctive accent. (And one must assume there were some font issues here with all three marks trying to fit under the same character.)
The accents in two of the following words also give us some direction.
Notice in the first of these words (the one on the right), there is a backwards "L"-looking accent under one of the middle characters. This, again, is a conjunctive accent mark, meaning there should be no logical separation between this word and those before it.
But the second word (the one on the left) has a caret-looking character (^) under it which is finally a disjunctive accent, showing this word begins a new thought or clause.
So what is it saying?
My novice attempt at translation for this verse might render it something like this:
For evils have surrounded me until, without number, my iniquities have
taken hold upon me so that I am not able to look up; they are more
than the hairs of my head, and my heart forsakes me.
An Additional Insight
One further insight into David's thinking can be found in Psalm 19. In verse 11 we see "great reward" which is followed in verse 13 by the mention of "great transgression." The word "great" here in Hebrew (these are both the same Hebrew word) is unlike the Aramaic equivalent: whereas Aramaic is focused on the quality of the noun in question, Hebrew is focused on its quantity. To say "great," then, means to say "much" or "many." Thus, this "great transgression" of Psalm 19:13 parallels the concept addressed here in Psalm 40:12.
As the matres lectionis (the reading aids added by the Masoretes) indicate, the clauses containing "evils" and "iniquities" are closely joined and part of the same thought expression. The words are used in parallel, and it seems, therefore, natural to conclude that the "they" which follows applies to both of these concepts together.
David's own iniquities are included among the "evils" which surround him.