[comp.windows.x] Bad pixmaps

jcc@MAGILLA.SIEMENS.COM (Joe Camaratta) (03/20/90)

 Our application allocates and uses pixmaps, but looses its connection
to the server because of invalid Pixmap values.  The number of pixmaps
that we can allocate seems to be dependent on the server on which the
application is running.  Is there anyway of knowing when the Pixmap
value returned by the server is valid?

			Joe Camaratta
			Siemens Corporate Research

ekberg@ti-csl.csc.ti.COM (03/20/90)

 >  Our application allocates and uses pixmaps, but looses its connection
 > to the server because of invalid Pixmap values.  The number of pixmaps
 > that we can allocate seems to be dependent on the server on which the
 > application is running.  Is there anyway of knowing when the Pixmap
 > value returned by the server is valid?

The server doesn't return anything upon successful completion of the
CreatePixmap request.  It is the client side of the network that generates the
pixmap ID.  You don't see this happening because Xlib does it for you.  You
will get an invalid pixmap ID error (e.g. a Drawable error) when using an ID
that hasn't been returned from the XCreatePixmap function.  This error can also
be generated when a pixmap is freed by the FreePixmap request and then used
anyway, for example in a drawing request.  The FreePixmap request will be
successful, but the drawing request will generate a Drawable error.

I have had the latter error in C++ when a destructor is run `for me' to destroy
something and then I try and use it anyway.

  -- tom (aisle C-4Q), ekberg@csc.ti.com

john@acorn.co.uk (John Bowler) (03/21/90)

In article <Ea1HpKe1GE8lA1GWcB@magilla.siemens.com> jcc@MAGILLA.SIEMENS.COM (Joe Camaratta) writes:
>
> Our application allocates and uses pixmaps, but looses its connection
>to the server because of invalid Pixmap values.  The number of pixmaps
>that we can allocate seems to be dependent on the server on which the
>application is running.  Is there anyway of knowing when the Pixmap
>value returned by the server is valid?
>
The server doesn't make up the numbers for the pixmaps - the application
does.  I encountered a similar problem in the X Test Suite (I left the
volume/stress tester running over christmas last year...)  In this case
the resource_id field in the display structure was simply overflowing
the number of bits granted to the application by the server - this number
can vary from server to server (it must be at least 18, so you need to
allocate at least 2^18 ids to overflow it...).  You can find out if this
is the problem by examining the resource id which the server doesn't
like and comparing it with the information in the Xlib Display structure;
in particular the resource_mask field.

If it is the problem the fix is very application specific.  The resource_alloc
field of the Display structure needs to be changed to point to a routine
which will allocate valid XID's.  That doesn't just mean fixing the
overflow, it also means avoiding allocating XIDs which are already in
use.  Not easy.  In the X Test Suite I just modified the resource_id
field directly so that the same XID was continuously reused (the pixmap
was created then deleted immediately afterwards).

John Bowler (jbowler@acorn.co.uk)