1
votes

I've just started building a minimal X server for Windows from scratch. As I work through it I'm sure I'll run into all kinds of errors and glitches as I work the bugs out and learn more about the protocol.

Here's an example of an error I have seen printed by a client:

X Error of failed request:  0
  Major opcode of failed request:  0 ()
  Serial number of failed request:  0
  Current serial number in output stream:  3

The major opcode meaning seems pretty obvious, but where are the "X Error" codes defined?

What are the serial numbers of the failed request and output stream? Are these supposed to match each other? By output stream, does that mean what was sent to the xserver or what was sent to the xclient? Is this related to sequence numbers?

2
Are you sure you mean "X server" and not an "X client" the server is what formats the displays the client is the program making the requests.James Anderson
Yes. Though I'm working on creating an x server, it's the client that reports the error message.Jason Champion

2 Answers

3
votes

grep the source...

in libX11, XlibInt.c, _XPrintDefaultError() you can find this error message.

Most of what's printed is from the error event, which is presumably sent by your server.

The current serial is dpy->request which is in Xlibint.h:

 unsigned long request;  /* sequence number of last request. */

i.e. the last X request that was sent. This may or may not be the same as the request causing the error. (event->serial is supposed to be the request that caused the error, but your server may not have gotten this right)

To hope to code an X server I think you'll be digging into the source code a lot - the docs are not precise or thorough enough... really, you may as well use some of the existing code, the license is liberal enough.

3
votes

Error codes are defined in the X Protocol specification chapter called Errors. The other items in an error response are defined in the first chapter Protocol Formats. The actual values and layout of the error messages are found in the Errors section of the Protocol Encoding appendix.

From the contents of that message though it appears you're sending a response filled with zeros when the client isn't expecting a response - most requests to the X server should not get a response sent back through the protocol unless they failed.