This is a fine-tuning sort of grammar lesson. As in, this sort of error is easily overlooked, only glaring to those of us who know better.
But writers should MASTER their native language. (I really believe this. I do!) So here's the deal:
GERUND: A verbal (verb-form-that-is-not-being-used-as-a-verb) that ends in -ING. In short, it's a verb that's been made into a noun by adding -ING.
Writing brings me great joy. (WRITING = subject, which means it's a noun. But its real name is "gerund.")
So. What about sentences that have a gerund modified by a pronoun?
INCORRECT: I was annoyed by him arriving late.
CORRECT: I was annoyed by his arriving late.
In the above example, ARRIVING is the object of the preposition BY. Which makes it a NOUN (because objects are always nouns or pronouns.) But its real name is GERUND -- a verb ending in -ING that is being used as a noun.
Now. If it's a NOUN, and we're saying to whom it BELONGS, that dictates the use of the POSSESSIVE NOUN OR PRONOUN.
(To whose arriving late are we referring? To HIS arriving late.)
That's why the second example is correct. The possessive pronoun HIS tells us WHOSE "arriving late" is annoying me.
HIM, on the other hand, is an OBJECTIVE PRONOUN. That is, it's a pronoun that's used as an object in a sentence. NOT to modify a gerund or any other substantive.
CORRECT EXAMPLES OF OBJECTIVE PRONOUN USAGE:
Please give the manuscript to him.
I would like to sit with them.
Beth stood behind me in line.
The audience laughed at us.
Examples are the best way to learn, so here are some more right-and-wrongs for modifying gerunds:
INCORRECT: Are you angry at me singing off key?
CORRECT: Are you angry at my singing off key?
INCORRECT: Lulu was embarrassed by him acting goofy in the restaurant.
CORRECT: Lulu was embarrassed by his acting goofy in the restaurant.
INCORRECT: Brutus the Blogger was saddened by them always leaving negative comments.
CORRECT: Brutus the Blogger was saddened by their always leaving negative comments.
INCORRECT: The petulant writer lamented us hating her terrible novel.
CORRECT: The petulant writer lamented our hating her terrible novel.
Got it? Good!
Side note: I learned this in eighth grade as part of the "gifted program." (Insert eyeroll here.) Three of us--the Gifted--sat at a round table in the back of English class with a young, balding dude who handed out copies of Edgar Allen Poe and taught us about using possessive pronouns with gerunds. I'm not sure what the connection between Poe and grammar was, but I do know I've never forgotten the pronoun thing.
I still don't understand why the whole class didn't learn it, though. There's nothing particularly "gifted" about a possessive pronoun.
Ah, well. Consider yourself gifted!