Bug 100699 - X11 Color Map creation problem on VNC client, XAllocColorCells call throw BadValue error, using 32 bit libX11.so.6.3.0 library
Summary: X11 Color Map creation problem on VNC client, XAllocColorCells call throw Bad...
Status: RESOLVED NOTOURBUG
Alias: None
Product: xorg
Classification: Unclassified
Component: Lib/Xlib (show other bugs)
Version: unspecified
Hardware: x86-64 (AMD64) other
: medium major
Assignee: Xorg Project Team
QA Contact: Xorg Project Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-04-17 09:38 UTC by Subrata
Modified: 2017-08-24 15:22 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Subrata 2017-04-17 09:38:28 UTC
An 32 bit X11 application running on 64 bit RHEL 7 and use libX11-1.6.3-2.el7.i686 rpm X11 library. This application is facing problem while creating its own color map. 

This X11 application is getting BadValue error while calling XAllocColorCells function when I run the application from VNC. But same code is working properly on Citrix client. Application tries to create a new color map by calling XCreateColormap.

From the gdb debugging I can see two major difference in Xlibrary call behavior between VNC and Citrix clients.

1> XDisplayCells return values are different . on VNC XDisplayCells returns 64 but on Citrix client it return 256.

2> On VNC the XCreateColormap call is returning a bigger color map ID (compared with Citrix client) which maybe out of range and so bad value error occur.
For VNC XCreateColormap return 37748737 but for Citrix it return 8388609.


Below is the high level code of the color map creation…




void createColormap(Display *display)
{
int i, n, snr, coffset, ncolors;
Display *dnr;
XColor dcolors[256];
Window win;
Colormap colormap0, colormap1;
Visual *vis;

win = DefaultRootWindow(display);
ncolors = XDisplayCells(display, DefaultScreen(display)); // Return 64 on VNC , and 256 for Citrix.
dnr = display;
snr = XDefaultScreen(display);
colormap0 = DefaultColormap(dnr,snr);
colormap = colormap0;

if(ncolors > 256) {
return;
}
if(ncolors > 2) {

vis = XDefaultVisual(dnr, XDefaultScreen(dnr));
if(vis == NULL) {
return;
}

//----------------------------------------- portion between this dotted lines do not execute on VNC as ncolors =64 and thus coffset =0 -------------------------------------------------------- //
if(ncolors > 16) {
if(ncolors > 128) {
coffset = 32;
} else {
coffset = 0;
}
} else {
coffset = 0;
}
if(coffset > ncolors) {
coffset = 0;
}
n = ncolors - coffset;

for(i=0; i dcolors[i].pixel = i;
XQueryColor(dnr, colormap0, &(dcolors[i]));
dcolors[i].flags = DoRed | DoGreen | DoBlue;
}
//----------------------------------------- portion between this dotted lines do not execute on VNC as ncolors =64 and thus coffset =0 -------------------------------------------------------- //


colormap1 = XCreateColormap(dnr, win, vis, AllocNone); // This line execute on both. Returns 37748737 for VNC but 8388609 Citrix.
if(colormap1 == colormap) {
return;
}

//============================ portion between this dotted lines do not execute on VNC as ncolors < 256 and coffset < 128 ========================== //
if(ncolors >= 256 && coffset < 128) {
int r, g, b;
for(r=0; r < 4; r++) {
for(g=0; g < 4; g++) {
for(b=0; b < 4; b++) {
dcolors[coffset].pixel = coffset;
dcolors[coffset].flags = DoRed | DoGreen | DoBlue;
dcolors[coffset].red = (short) (r * 21845);
dcolors[coffset].green = (short) (g * 21845);
dcolors[coffset].blue = (short) (b * 21845);
coffset++;
if(coffset >= 256) break;
}
if(coffset >= 256) break;
}
if(coffset >= 256) break;
}
}
//============================ portion between this dotted lines do not execute on VNC as ncolors < 256 and coffset < 128 ========================== //

unsigned long plane_masks_return[1];
unsigned int nplanes= 0;
unsigned long pixels_return[256];
unsigned int npixels = coffset;
int status;
status = XAllocColorCells(dnr, colormap1, True, plane_masks_return, nplanes, pixels_return, npixels); //this call throw BadValue error.
if(status == 0) {
return;
} else {
XStoreColors(dnr, colormap1, &(dcolors[0]), coffset);
colormap = colormap1;
}
}
}
Comment 1 Subrata 2017-04-19 04:33:02 UTC
Hi Alan Coopersmith,
First of all thanks for your reply. 

It is still not clear why XAllocColorCells throws BadValue error ??  In this case which parameter of XAllocColorCells call is out of range ?? 

If BadValue error is coming due to some wrong parameter value of XAllocColorCells call then what should be the processing before calling XAllocColorCells ?? Or in other words what X calls should be made before calling XAllocColorCells function and in which order??

Thanks
Subrata
Comment 2 Adam Jackson 2017-08-24 15:22:11 UTC
(In reply to Subrata from comment #0)

> 1> XDisplayCells return values are different . on VNC XDisplayCells returns
> 64 but on Citrix client it return 256.

The VNC server and Citrix server are running at different color depths, and your code is handling one of them correctly but not the other.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.