[X2Go-Dev] debian jessie general protection trap in libNX_X11.so.6.2 caused by some apps
Mike Gabriel
mike.gabriel at das-netzwerkteam.de
Fri Oct 2 04:41:46 CEST 2015
Hi Jean-Francois,
On Do 01 Okt 2015 22:10:04 CEST, Mike Gabriel wrote:
>> Program received signal SIGSEGV, Segmentation fault.
>> _XData32 (dpy=dpy at entry=0x2b319b0, data=<optimized out>,
>> data at entry=0x34580d4, len=14588, len at entry=18652) at XlibInt.c:3792 3792
>> *buf++ = *data++; (gdb) l
>> 3787 i = len;
>> 3788 dpy->bufptr = (char *)buf + i;
>> 3789 len -= i;
>> 3790 i >>= 2;
>> 3791 while (--i >= 0)
>> 3792 *buf++ = *data++;
>> 3793 }
>> 3794 return 0;
>> 3795 }
>> 3796 #endif /* LONG64 */
>>
>> Then I did several tests. To get better debug resolution, I compiled the
>> lib again, but with '-Og' (or -O0, I tried both). Oddly, the problem
>> goes away! I think there's some alignment problems here: See also:
>> https://www.mail-archive.com/misc@openbsd.org/msg129941.html
>
> Ok... Have you checked upstram X.Org already? Checked what they have
> at that place in the code? They probably have already fixed it.
>
> See the xorg/libx11 Git repo on git.freedesktop.org. I normally
> compare the nxagent code with latest X.Org and then many issues
> dissolve when apply their changes.
>
>> I'm really confused, If i change the "data" member to an int (32bits)
>> then it doesn't work. I get no errors, my x11 clients just don't show up
>> (I use xterm as a test client app). I did manage to fix it by doing:
>> diff --git a/nx-X11/lib/X11/XlibInt.c b/nx-X11/lib/X11/XlibInt.c index
>> 47e2ea1..bfcab8d 100644 --- a/nx-X11/lib/X11/XlibInt.c +++
>> b/nx-X11/lib/X11/XlibInt.c @@ -3770,11 +3770,11 @@ void Data(
>> int
>> _XData32(
>> Display *dpy,
>> - register long *data,
>> + volatile long *data,
>> unsigned len)
>> {
>> - register int *buf;
>> - register long i;
>> + volatile int *buf;
>> + volatile long i;
>>
>> while (len) {
>> buf = (int *)dpy->bufptr;
>> @@ -3785,6 +3785,7 @@ _XData32(
>> }
>> if (len < i)
>> i = len;
>> + i &= ~0x3;
>> dpy->bufptr = (char *)buf + i;
>> len -= i;
>> i >>= 2;
>>
>
> Ok...
>
attached is the only change that has happened since 2006 or so around
the code block you reference.
@@ -1739,7 +1739,7 @@ void Data(
int
_XData32(
Display *dpy,
- register long *data,
+ register _Xconst long *data,
unsigned len)
{
register int *buf;
Mike
--
DAS-NETZWERKTEAM
mike gabriel, herweg 7, 24357 fleckeby
fon: +49 (1520) 1976 148
GnuPG Key ID 0x25771B31
mail: mike.gabriel at das-netzwerkteam.de, http://das-netzwerkteam.de
freeBusy:
https://mail.das-netzwerkteam.de/freebusy/m.gabriel%40das-netzwerkteam.de.xfb
-------------- next part --------------
commit f0b171c8ea7b055ba520272ea9a2604e18841ac7
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date: Fri Feb 15 23:34:40 2013 -0800
Preserve constness in casting arguments through the Data*() routines
Casts were annoying gcc by dropping constness when changing types,
when routines simply either copy data into the request buffer or
send it directly to the X server, and never modify the input.
Fixes gcc warnings including:
ChProp.c: In function 'XChangeProperty':
ChProp.c:65:6: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual]
ChProp.c:65:6: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual]
ChProp.c:74:6: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual]
ChProp.c:74:6: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual]
ChProp.c:83:6: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual]
SetHints.c: In function 'XSetStandardProperties':
SetHints.c:262:20: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual]
SetPntMap.c: In function 'XSetPointerMapping':
SetPntMap.c:46:5: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual]
SetPntMap.c:46:5: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual]
StBytes.c: In function 'XStoreBuffer':
StBytes.c:97:33: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual]
StName.c: In function 'XStoreName':
StName.c:40:27: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual]
StName.c: In function 'XSetIconName':
StName.c:51:27: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual]
Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
diff --git a/include/X11/Xlibint.h b/include/X11/Xlibint.h
index 7911fd7..c2232de 100644
--- a/include/X11/Xlibint.h
+++ b/include/X11/Xlibint.h
@@ -610,17 +610,17 @@ extern void _XFlushGCCache(Display *dpy, GC gc);
dpy->bufptr += (n);
#ifdef WORD64
-#define Data16(dpy, data, len) _XData16(dpy, (short *)data, len)
-#define Data32(dpy, data, len) _XData32(dpy, (long *)data, len)
+#define Data16(dpy, data, len) _XData16(dpy, (_Xconst short *)data, len)
+#define Data32(dpy, data, len) _XData32(dpy, (_Xconst long *)data, len)
#else
-#define Data16(dpy, data, len) Data((dpy), (char *)(data), (len))
+#define Data16(dpy, data, len) Data((dpy), (_Xconst char *)(data), (len))
#define _XRead16Pad(dpy, data, len) _XReadPad((dpy), (char *)(data), (len))
#define _XRead16(dpy, data, len) _XRead((dpy), (char *)(data), (len))
#ifdef LONG64
-#define Data32(dpy, data, len) _XData32(dpy, (long *)data, len)
+#define Data32(dpy, data, len) _XData32(dpy, (_Xconst long *)data, len)
extern int _XData32(
Display *dpy,
- register long *data,
+ register _Xconst long *data,
unsigned len
);
extern void _XRead32(
@@ -629,7 +629,7 @@ extern void _XRead32(
long len
);
#else
-#define Data32(dpy, data, len) Data((dpy), (char *)(data), (len))
+#define Data32(dpy, data, len) Data((dpy), (_Xconst char *)(data), (len))
#define _XRead32(dpy, data, len) _XRead((dpy), (char *)(data), (len))
#endif
#endif /* not WORD64 */
diff --git a/src/ChProp.c b/src/ChProp.c
index b957751..190a224 100644
--- a/src/ChProp.c
+++ b/src/ChProp.c
@@ -62,7 +62,7 @@ XChangeProperty (
len = ((long)nelements + 3)>>2;
if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) {
SetReqLen(req, len, len);
- Data (dpy, (char *)data, nelements);
+ Data (dpy, (_Xconst char *)data, nelements);
} /* else force BadLength */
break;
@@ -71,7 +71,7 @@ XChangeProperty (
if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) {
SetReqLen(req, len, len);
len = (long)nelements << 1;
- Data16 (dpy, (short *) data, len);
+ Data16 (dpy, (_Xconst short *) data, len);
} /* else force BadLength */
break;
@@ -80,7 +80,7 @@ XChangeProperty (
if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) {
SetReqLen(req, len, len);
len = (long)nelements << 2;
- Data32 (dpy, (long *) data, len);
+ Data32 (dpy, (_Xconst long *) data, len);
} /* else force BadLength */
break;
diff --git a/src/SetHints.c b/src/SetHints.c
index 0c33f59..1cde48f 100644
--- a/src/SetHints.c
+++ b/src/SetHints.c
@@ -259,7 +259,9 @@ XSetStandardProperties (
if (icon_string != NULL) {
XChangeProperty (dpy, w, XA_WM_ICON_NAME, XA_STRING, 8,
- PropModeReplace, (unsigned char *)icon_string, safestrlen(icon_string));
+ PropModeReplace,
+ (_Xconst unsigned char *)icon_string,
+ safestrlen(icon_string));
}
if (icon_pixmap != None) {
diff --git a/src/SetPntMap.c b/src/SetPntMap.c
index 2e29201..14e104d 100644
--- a/src/SetPntMap.c
+++ b/src/SetPntMap.c
@@ -43,7 +43,7 @@ XSetPointerMapping (
GetReq (SetPointerMapping, req);
req->nElts = nmaps;
req->length += (nmaps + 3)>>2;
- Data (dpy, (char *)map, (long) nmaps);
+ Data (dpy, (_Xconst char *)map, (long) nmaps);
if (_XReply (dpy, (xReply *)&rep, 0, xFalse) == 0)
rep.success = MappingSuccess;
UnlockDisplay(dpy);
diff --git a/src/StBytes.c b/src/StBytes.c
index 13ac879..07ee441 100644
--- a/src/StBytes.c
+++ b/src/StBytes.c
@@ -94,7 +94,7 @@ XStoreBuffer (
{
if ((buffer < 0) || (buffer > 7)) return 0;
return XChangeProperty(dpy, RootWindow(dpy, 0), n_to_atom[buffer],
- XA_STRING, 8, PropModeReplace, (unsigned char *) bytes, nbytes);
+ XA_STRING, 8, PropModeReplace, (_Xconst unsigned char *) bytes, nbytes);
}
int
diff --git a/src/StName.c b/src/StName.c
index fb1e6f5..b4048bf 100644
--- a/src/StName.c
+++ b/src/StName.c
@@ -37,7 +37,7 @@ XStoreName (
_Xconst char *name)
{
return XChangeProperty(dpy, w, XA_WM_NAME, XA_STRING,
- 8, PropModeReplace, (unsigned char *)name,
+ 8, PropModeReplace, (_Xconst unsigned char *)name,
name ? strlen(name) : 0);
}
@@ -47,7 +47,7 @@ XSetIconName (
Window w,
_Xconst char *icon_name)
{
- return XChangeProperty(dpy, w, XA_WM_ICON_NAME, XA_STRING,
- 8, PropModeReplace, (unsigned char *)icon_name,
+ return XChangeProperty(dpy, w, XA_WM_ICON_NAME, XA_STRING, 8,
+ PropModeReplace, (_Xconst unsigned char *)icon_name,
icon_name ? strlen(icon_name) : 0);
}
diff --git a/src/XlibInt.c b/src/XlibInt.c
index 2827c10..e4d35fd 100644
--- a/src/XlibInt.c
+++ b/src/XlibInt.c
@@ -1722,7 +1722,7 @@ void _Xbcopy(b1, b2, length)
#ifdef DataRoutineIsProcedure
void Data(
Display *dpy,
- char *data,
+ _Xconst char *data,
long len)
{
if (dpy->bufptr + (len) <= dpy->bufmax) {
@@ -1739,7 +1739,7 @@ void Data(
int
_XData32(
Display *dpy,
- register long *data,
+ register _Xconst long *data,
unsigned len)
{
register int *buf;
@@ -1781,7 +1781,7 @@ _XData32(
static doData16(
register Display *dpy,
- short *data,
+ _Xconst short *data,
unsigned len,
char *packbuffer)
{
@@ -1814,7 +1814,7 @@ static doData16(
_XData16 (
Display *dpy,
- short *data,
+ _Xconst short *data,
unsigned len)
{
char packbuffer[PACKBUFFERSIZE];
@@ -1836,7 +1836,7 @@ _XData16 (
static doData32(
register Display *dpy
- long *data,
+ _Xconst long *data,
unsigned len,
char *packbuffer)
{
@@ -1867,7 +1867,7 @@ static doData32(
void _XData32(
Display *dpy,
- long *data,
+ _Xconst long *data,
unsigned len)
{
char packbuffer[PACKBUFFERSIZE];
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: Digitale PGP-Signatur
URL: <http://lists.x2go.org/pipermail/x2go-dev/attachments/20151002/a225e923/attachment.pgp>
More information about the x2go-dev
mailing list