Fog Creek Software
Discussion Board

Dictionary of Code Faults

I recently pointed out on this group that I am anxious to gather a collection of types of code fault that people have found to occur in practice.  I promised to send a copy of the finally gathered collection to each contributor. 

A few examples were contributed in the discussion  that immediately followed; my thanks to those who contributed.

Items already in my collection have been gathered from

Industrial Strength C++ - Henricson and Nyquist
Effective C++ - Meyers
More Effective C++ - Meyers
C traps and Pitfalls - Koenig
Safer C - Hatton
Large Scale C++ Software Design - Lakos

Do readers think that this is an adequate list?
have I omitted some valuable sources here?


Keith Paton
Sunday, January 13, 2002

Exceptional C++ (Herb Sutter) - and presumably More Exceptional C++ (recently out, and top of my "buy soon" list).


Tim Sharrock
Monday, January 14, 2002

Highly recommended and encyclopedic in scope: Steve McConnell's "Code Complete"

Monday, January 14, 2002

Don Knuth kept a log of every error he made while developing TeX, and published the log and an analysis of it in "Literate Programming". Definitely worth a read.

Andrew Simmons
Monday, January 14, 2002

Whilst I do not have a source (that is not already listed) I would be most interested in the resulting list.
Great idea, and I look forward to the outcome.

Regs, James.

James Ladd
Monday, January 14, 2002

How about "Obfuscated C and Other Mysteries", by Don Libes? It's very readable and explains a lot of C programming "tricks" that programmers typically employ but is rarely committed to paper.

He's also the author of Expect, a well known unix based automation tool.

James Wann
Monday, January 14, 2002

I used to work on Microsoft's Windows NT QA team. They had a group a full-time code reviewers (pseudo-open source) called the "Tiger Team" or the "Penetration Test Team". btw, I was not on that team. Let's just say that saying you work on the Tiger Team sounds cooler than working on the "Penetration Team".  ;-)

They wrote a document describing the most common coding errors and oversights found in the Windows NT code. I have a hard-copy and I don't want to retype the whole paper, but here is a list from the table of contents:

- Allocation failures
- Uninitialized memory
- Leaks
- Using freed resources
- Resource attacks

- Division by zero
- Signed vs. unsigned variables
- Floating-point variables

- Simple buffer overflow
- Size overflow or underflow
- Abuse of enumerated types
- Using internal lengths for comparisons to external input

- Handle-based objects
- Correlated parameters
- Limits of exception handling
- Use of internal interfaces
- Alternate code paths
- Trusted data sources

- Relying on common interfaces to check parameters
- Validating context information from network before using it
- Beware special cas entry for network services
- Accessing data or services by proxy

- Dangers of typecasting
- Operator precedence
- Conditional termination confusion
- Misuse of OPTIONAL parameters
- Inconsistent return values or errors
- Relying on volatile objects
- Spinlock order problems (deadlock, "deadly embrace")
- Determining membership in Administrators group

- Accessing user-provided memory without probing
- Multiple user-mode reads without captures
- Don't trust the TEB (Thread Environment Block)!
- Race conditions modifying kernel data on user request
- Common interfaces for user-mode and kernel-mode
- Validating buffer IO in device drivers
- METHOD_NEITHER requires full probe and capture

Tuesday, January 15, 2002

Also, here is a list of the 800+ coding errors that Gimpel Software's Flexelint/PC-Lint looks for:

Tuesday, January 15, 2002

I just looked at my array of Win2k/NT machines with an even greater sense of unease.

Simon Lucy
Tuesday, January 15, 2002

While this is a Java book:
Java 2 Performance and Idiom Guide
Craig Larman  Rhett Guthrie
ISBN: 0130142603

it's one of the best I found filled with little tricks-of-the-trade, eg using
instead of

to avoid NullPointerExceptions, as well as general Java idioms on how to use Exceptions, how to override Object.equals(), Object.hashCode() like the wizards do.

It gave me the idea to use Hashtable as a compact multi-dimensional dynamic lookup-table just by making sure the hashcode preserved the orthogonality of the dimensions I was using in the lookup.

Definitely worth a read, and most of the concepts can be ported to other languages.

Wednesday, January 16, 2002

OT on Java... you likely want to use Collections like HashMap instead of old classes like Hashtable.  This isn't anything new, but older books still use the old classes.

Cletus Washington
Wednesday, January 16, 2002


Sorry if I was not clear. The book is not about Hashtable vs Hashwhatnot (which, you are correct, is OT), it's about _idioms_.

New ways to look at things you _thought_ you had used in every possibly imaginable effective way. And what a marvel it is when somebody shows you yet another useful way to apply old tools.

In this case, the post was about the book offering a new view on using the dum' ol' hashtable to find something quickly given coordinates (x1, x2, ..., x11), regardless of the programming language.

Wednesday, January 16, 2002

Testing Computer Software (2nd ed) by Kaner, Falk, and Nguyen has a language neutral list of errors in the appendix - looking at both cause and effect.

Gerson Koenig
Wednesday, January 16, 2002


The link you pointed to

does not work.

Can you post the proper link again.


Monday, January 21, 2002

At a higher level:  Antipatterns ...Published by addison wellesly.

Adam Younga
Friday, January 25, 2002

*  Recent Topics

*  Fog Creek Home