[comp.windows.x] BadLength for XDrawLines

john@quonset.cfht.hawaii.edu (02/16/91)

I am running X11r3 code (HP has not gotten us to R4 yet) on an
HP9000 system and get the following errors upon requesting 16k
points:

   X Protocol error detected by server: BadLength, poly request too
   large or internal Xlib length error.
    Failed request major op code 67 (X_PolyRectangle)
      .....

The number of points is an int and I haven't exceeded that.  Is this
a bug in X?

Thanks in advance if you can shed some light on this.

jk


 ----------------------------------------------------------------------------
 John Kerr                      Canada-France-Hawaii Telescope Corp.
 Computer Sys. Engineer         INTERNET: john@cfht.hawaii.edu 
                                BITNET:   john@uhcfht
 ----------------------------------------------------------------------------

klee@wsl.dec.com (Ken Lee) (02/16/91)

In article <11474@uhccux.uhcc.Hawaii.Edu>, john@quonset.cfht.hawaii.edu writes:
|> I am running X11r3 code (HP has not gotten us to R4 yet) on an
|> HP9000 system and get the following errors upon requesting 16k
|> points:
|> 
|>    X Protocol error detected by server: BadLength, poly request too
|>    large or internal Xlib length error.
|>     Failed request major op code 67 (X_PolyRectangle)
|>       .....
|> 
|> The number of points is an int and I haven't exceeded that.  Is this
|> a bug in X?

X servers are required to support requests of up to 16KB, though some
support more and some Xlib's automatically break up (some) long
requests to fit.  The XMaxRequestSize() function will tell you the max
length for your server.

-- 
Ken Lee
DEC Western Software Laboratory, Palo Alto, Calif.
Internet: klee@wsl.dec.com
uucp: uunet!decwrl!klee

pete@iris49.UUCP (Pete Ware) (02/19/91)

No, it's not _really_ a bug in X.  The problem is that there is a
maximum request length that is implicitly used by all the output
functions.  The protocol document (X Window System, 2nd edition, page
382) guarantees this value is at least 4096 4 byte units (i.e.
16KBytes).  It is established at connection time and each server is
free to implement any value larger than 4096.  There is no function or
macro to get this from the display structure.

What this means is that one is allowed to send less than 2000
rectangles per request XDrawRectangles() (each XRectangle structure is
8 bytes plus some overhead for the packet).  There are similar
implicit sizes for XDrawPoints, XDrawLines, XDrawArcs, etc.

To forestall further questions, in general, Xlib cannot breakup such
requests into multiple calls because the requests may depend on
previous values.  For example:
	XDrawPoints	coord mode
	XDrawLines	joins, intersections, coord mode
	XDrawRectangles	no reason
	XDrawArcs	intersections

--pete
Pete Ware / Biosym / San Diego CA / (619) 546-5532
uucp:	  scripps.edu!bioc1!pete
Internet: bioc1!pete@scripps.edu

pete@iris49.UUCP (Pete Ware) (02/19/91)

Courtesy of a later mail message from Ken Lee, I correct my statement
that there is no way to find out the maximum request size.  It's
documented in "X Window System" 2nd edition, Appendix C, page 617.

--pete
Pete Ware / Biosym / San Diego CA / (619) 546-5532
uucp:	  scripps.edu!bioc1!pete
Internet: bioc1!pete@scripps.edu

ekberg@asl.dl.nec.COM (Tom Ekberg) (02/19/91)

 > I am running X11r3 code (HP has not gotten us to R4 yet) on an
 > HP9000 system and get the following errors upon requesting 16k
 > points:
 > 
 >    X Protocol error detected by server: BadLength, poly request too
 >    large or internal Xlib length error.
 >     Failed request major op code 67 (X_PolyRectangle)
 >       .....
 > 
 > The number of points is an int and I haven't exceeded that.  Is this
 > a bug in X?

The limit is smaller than 2^32.  I believe the protocol specification limits
this to be 2^16-3 points.

If you look at the value returned by XMaxRequestSize you can find out what the
limit is for the server.  The Xlib manual says that this value will be no
smaller than 16K bytes.  You will have to use the protocol specification to
determine how to translate that into numbers of points.

  -- tom, ekberg@aslss02.asl.dl.nec.com (x3503)

doug@genmri.UUCP (Doug Becker) (02/21/91)

Are you discussing R3 or R4?

    There is no function or
    macro to get this from the display structure.

In R4, there is the XMaxRequestSize function.  R3 users will have to use
dpy->max_request_size directly.
    
    To forestall further questions, in general, Xlib cannot breakup such
    requests into multiple calls because the requests may depend on
    previous values.  For example:

As far as I know, the situation in MIT's R4 Xlib is this: In the case of
XDrawPoints, CoordModePrevious can be (and is) handled by Xlib.
XDrawRectangles also breaks up its requests.  The plural PolyText{8,16},
PolySegment, and PolyFillArc request generating functions split up their
requests as well.

The XDrawLines and XDrawArcs functions do not break up their requests
because of the wide-line intersection and joining specifications of those
calls, as you mentioned (this is conjecture on my part).  

The partitioning of poly protocol requests by Xlib is definitely a grey
area, one I'm hoping will be addressed in R5 (if nowhere else then in the
Xlib spec).  I've mentioned this situation to a couple of people at MIT are
in a position to do something about it; the last I heard was that MIT would
investigate it.

-- 

Doug Becker
doug@nmri.ge.com
crdgw1.ge.com!sane!doug