Sparse Context Checking in the Linux Kernel

Sparse is a static code analysis tool, originally and primarily targetting the Linux kernel. I’ve used it previously to find bugs due to mixing incompatible pointer types (user vs kernel). So when I discovered locking problems, I naturally returned to it.

Sparse does lock checking via its more general “context” checking. Linus’ original email announcing context checking was, as typical, concise, so I hoped it would just work.

Bugger. It didn’t. This post is my (ongoing) attempt to make sense of it…

Naive Attempts


August 1, 2013
85 words


linux kernel debugging



ccoffing on GitHub

ccoffing on LinkedIn