For example, an uninitialized variable might cause an identifier of 0x0 to be incorrectly supplied. More complex is, for example, supplying a pixmap identifier when a window identifier is required. Or, a previously valid window identifier may refer to a window that has since been destroyed. In the latter two cases, a BadWindow error results, but the invalid identifier looks reasonable. Only tracing the error using the techniques provided earlier in this article will find the problem.
BadMatch errors occur when only specific values are acceptable, but another value is provided.
The valid values may be a small set of enumerated integers or they may be a relation between other arguments, e.g., a graphics context in a drawing request must have the same depth as the drawing window. There is rarely more than one possible BadMatch error for any particular request type, so identifying the problem is usually straight forward. In my experience, most BadMatch errors are related to drawable depths. Make sure your windows, pixmaps, visual types, colormaps, etc. have the correct depths in your X requests. The above are the most common error types.