HomeAbout Us A-Z IndexSearch * Contact Us Register LoginPress Shop

The Open Brand -- Problem Reporting and Interpretations System


Problem Report 1853 Details

Help Show help | Quick Search | Submit a Test Suite Support Request | Click here to view your privileges

This page provides all information on Problem Report 1853.


Report 1853 Actions


    Problem Report Number 1853
    Submitter's Classification Specification problem
    State Resolved
    Resolution Test Suite Deficiency (TSD)
    Problem Resolution ID TSD.X.0930
    Raised 2002-08-16 08:00
    Updated 2003-03-13 08:00
    Published 2002-09-10 08:00
    Product Standard Window System Application Interface V2
    Certification Program The Open Brand certification program
    Test Suite VSW version 5.1.2
    Test Identification Xlib7/XQueryColors 1
    Problem Summary TSD4W.00175 The test hangs when it encounters a BadLength error for StaticGray visuals with depth 16.
    Problem Text
    When running the VSW 5.1.2 suite, the test run would never progress
    past the test for XQueryColors. The test would have to be interrupted
    to continue.

    Investigation uncovered that the StaticGray visuals with a depth of
    16 were involved in the problem. These visuals allow 65535 entries
    in the colormap for the visuals.

    Further investigation into the X Window code uncovered the following:

    In test purpose 1, file tset/Xlib7/qryclrs/Test.c, function t001() we have:

    #1: Get the number of colormap entries possible for the visual, so we
    allocate a colormap of that size. In this case that is 65,535
    entries.
    #2: Create all of the colormap entries (65,535 of them).
    #3: Set the number of colors for the XQueryColors to size (65,535)

    ----------------------------------------------------------------------------
    static void t001(){

    XVisualInfo *vp;
    XColor *cellptr, *defptr, *refptr, *acptr;
    int size;
    unsigned long i;
    unsigned long vmask = 0L;
    int pass = 0, fail = 0;

    report_purpose(1);

    [SNIP]

    tpstartup();
    setargs();
    if((vmask = visualsupported(display, vmask)) != 0L)
    for(resetsupvis(vmask); nextsupvis(&vp); ) {
    [#1] size = vp->colormap_size;
    if (vp->class == DirectColor)
    size = maxsize(vp);
    colormap = makecolmap(display, vp->visual, AllocNone);

    defptr = (XColor *) malloc( size * sizeof(XColor));
    refptr = (XColor *) malloc( size * sizeof(XColor));

    if( (defptr == (XColor *) 0) || (refptr == (XColor *) 0)) {
    delete("malloc() failed to allocate space for the colour array.");
    return;
    }

    [#2] for(i=0, cellptr = defptr; i<size; i++, cellptr++) { /* May or may not allocate the entire colourmap */
    cellptr->pixel = ~0L;
    cellptr->red = i<<8;
    cellptr->green = i<<8;
    cellptr->blue = i<<8;
    cellptr->flags = 0;

    if(XAllocColor(display, colormap, cellptr) == False) {
    delete("XAllocColor() failed.");
    return;
    }

    refptr[i] = defptr[i];
    }
    if(i == size)
    CHECK;

    [#3] ncolors = size;
    defs_in_out = defptr;
    startcall(display);
    if (isdeleted())
    return;

    XQueryColors(display, colormap, defs_in_out, ncolors);

    [SNIP]
    }
    -------------------------------------------------------------------------------


    This is where we run into a problem with the implementation. In file
    x/xc/lib/X11/QuColors.c, function XQueryColors() we have:

    #1: Set the length of the request to the number of XColor entries we
    have in the colormap. The comment indicates this field should be
    a 32-bit field for the lenght for the xQueryColorsReq structure.

    -----------------------------------------------------------------------------
    XQueryColors(dpy, cmap, defs, ncolors)
    register Display *dpy;
    Colormap cmap;
    XColor *defs; /* RETURN */
    int ncolors;
    {
    register int i;
    xrgb *color;
    xQueryColorsReply rep;
    long nbytes;
    register xQueryColorsReq *req;

    LockDisplay(dpy);
    GetReq(QueryColors, req);

    req->cmap = cmap;
    [#1]req->length += ncolors; /* each pixel is a CARD32 */
    [SNIP]
    }
    -----------------------------------------------------------------------------

    Taking a look in file x/xc/include/Xproto.h, at the xQueryColorsReq structure,
    we see:

    typedef struct {
    CARD8 reqType;
    BYTE pad;
    CARD16 length B16;
    Colormap cmap B32;
    } xQueryColorsReq;

    and CARD16 is defined in x/xc/include/Xmd.h as:

    typedef unsigned short CARD16;

    So, in theory, the length field could hold the count for the 65,535
    colormap entries. However, the assignment is really and addition to
    the existing length value, which is set to sizeof(xQueryColorsReq) in
    the GetReq macro (file x/xc/lib/X11/Xlibint.h):

    -----------------------------------------------------------------------------
    #define GetReq(name, req) \
    WORD64ALIGN\
    if ((dpy->bufptr + SIZEOF(x##name##Req)) > dpy->bufmax)\
    _XFlush(dpy);\
    req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\
    req->reqType = X_##name;\
    req->length = (SIZEOF(x##name##Req))>>2;\
    dpy->bufptr += SIZEOF(x##name##Req);\
    dpy->request++
    -----------------------------------------------------------------------------

    Since the sizaeof the structure is 64 bits. There can only be 65,519
    colormap entries added to the length or you will overflow the length
    field resulting in a BadLength error (in the tet_xres file in the test
    case directory)

    This appears to be a problem in the example implementation of
    XQueryColors since there is no mention on the limit of the size for
    a colormap. In addition, it appears to be an undocumented constraint
    for all of the x/*name*/Req structures since the length for all of these is limited to 16 bit length values for the request. I could
    not find a mention on the limit for colormap entries in the Chapter
    7 of the Xlib Programming Manual
    Test Output
    70||"VSW5TESTSUITE CASE XQueryColors 3"
    10|0 /tset/Xlib7/qryclrs/Test 16:17:20|TC Start, scenario ref 2-0
    15|0 3.3-lite 3|TCM Start
    400|0 1 1 16:17:26|IC Start
    200|0 1 16:17:26|TP Start
    520|0 1 000260334 1 1|VSW5TESTSUITE PURPOSE 1
    520|0 1 000260334 1 2|Assertion XQueryColors-1.(A)
    520|0 1 000260334 1 3|A call to XQueryColors obtains the RGB values of the
    520|0 1 000260334 1 4|colourmap entries specified by the pixel components of the520|0 1 000260334 1 5|XColor structures named by the defs_in_out argument, and
    520|0 1 000260334 1 6|returns the RGB values in the red, green, and blue
    520|0 1 000260334 1 7|components and sets the flags components to the bitwise OR520|0 1 000260334 1 8|of DoRed, DoGreen, and DoBlue.
    520|0 1 000260334 1 9|METH: For each supported visual class :
    520|0 1 000260334 1 10|METH: Create a colormap with XCreateColormap with alloc = AllocNone.
    520|0 1 000260334 1 11|METH: Allocate a new r/o colourmap cell with XAllocColor.
    520|0 1 000260334 1 12|METH: Obtain the rgb values and flags components with XQueryColors using the pixel returned by XAllocCOlor.
    520|0 1 000260334 1 13|METH: Verify that the returned flags component was set
    to DORed|DoGreen|DoBlue.
    520|0 1 000260334 1 14|METH: Verify that the rgb values are identical to those returned by XAllocColor.
    520|0 1 000260334 1 15|unexpected signal 2 (SIGINT) received
    520|0 1 000260334 1 16|unexpected signal 15 (SIGTERM) received
    510|0|system 0, errno = 9 (EBADF): (dresfile.c, 822): write failed on temp result file
    220|0 1 7 16:21:09|NORESULT (auto-generated by TCC)
    90|16:21:09|User Abort
    80|0 1 16:21:09|TC End, scenario ref 2-0
    900|16:21:09|TCC End

    Review Information

    Review Type TSMA Review
    Start Date null
    Completed null
    Status Complete
    Review Recommendation No Resolution Given
    Review Response
    Although the constraint on the value of ncolors in an XQueryColors() call
    is not explicitly stated in the Xlib specification, it is not exactly
    "undocumented", since Appendix A states that a call to XQueryColors()
    generates a QueryColors protocol request, and the precise format of
    that protocol request is documented in the X Protocol specification.

    The test suite should be changed to ensure that the ncolors value it
    passes to XQueryColors() will not result in a BadLength error.

    It is recommended that a Test Suite Deficiency is granted.

    Review Type SA Review
    Start Date null
    Completed null
    Status Complete
    Review Resolution Test Suite Deficiency (TSD)
    Review Conclusion
    This is an agreed Test Suite Deficiency.

    Problem Reporting System Options:

     

    Back   


Contact the Certification Authority