xmonobut
Hello,
xmonobut segfault. I need this patch to get it works again.
Sincerely,
Alain
----------------------------------------------
main.c renamed from main.c.orig +3 -3
@@ -137,7 +137,7 @@ {Display *dpy;Window root; -unsigned char map[6 ]; +unsigned char map[31 ];int buts, rst;
@@ -190,7 +190,7 @@if (active_button_num != last_button_num) { - buts =XGetPointerMapping (dpy, map,5 ); + buts =XGetPointerMapping (dpy, map,32 );switch (active_button_num) {
@@ -217,7 +217,7 @@break ; }mb_tray_app_repaint (app); -while ((rst =XSetPointerMapping (dpy, map, buts)) == MappingBusy); +while ((rst =XSetPointerMapping (dpy, map,32 )) == MappingBusy); last_button_num = active_button_num; } }
Quoted 3 lines · On Mon, 2009-09-28 at 02:16 +0200, Alain2210 wrote:
Hello,
xmonobut segfault. I need this patch to get it works again.
That patch looks harmless enough in itself (and maybe a good thing), but if you're seeing a segfault without it then that would suggest that your Xlib is broken. It would be better to fix the bug in Xlib.
p.
Quoted 6 lines · On Monday 28 September 2009 02:16:07 Alain2210 wrote:
Hello,
xmonobut segfault. I need this patch to get it works again.
main.c renamed from main.c.orig +1
-1-unsigned char map[6 ]; +unsigned char map[31 ];
...
Quoted 1 line
+ buts =
XGetPointerMapping(dpy, map, 32);
,,.
Quoted 1 line
+
while((rst = XSetPointerMapping(dpy, map, 32)) == MappingBusy);
31. vs 32... please send an updated patch
z.
Quoted 5 lines · Holger Hans Peter Freyther
Quoted 3 lines · On Monday 28 September 2009 02:16:07 Alain2210 wrote:
Hello,
xmonobut segfault. I need this patch to get it works again.
Quoted 8 lines
Quoted 2 lines
main.c renamed from main.c.orig +1
-1-unsigned char map[6 ]; +unsigned char map[31 ];...
Quoted 1 line
+ buts =
XGetPointerMapping(dpy, map, 32);,,.
Quoted 1 line
+
while((rst = XSetPointerMapping(dpy, map, 32)) == MappingBusy);31. vs 32... please send an updated patch
Looking at this patch again, I think it is just broken and (even aside from the 31/32 thing) should not be applied.
I guess the cause of the original segfault was that "buts" is set to a value greater than six and hence the XSetPointerMapping() call runs off the end of the array. However, the solution presented in the patch, i.e. just ignoring the return value from XGetPointerMapping() altogether, doesn't seem too good either since this will cause XSetPointerMapping() to read uninitialised garbage from the balance of the array.
A minimal fix for the original crash would probably be to insert something like:
if (buts > sizeof(map))
buts = sizeof(map);
after the XGetPointerMapping() call. A slightly better fix would perhaps be to make an initial call to XGetPointerMapping() with nmap=0 to find out how many buttons are present, then to dynamically allocate an array of the right size and read the mapping into it.
p.
Hello,
thanks for the answers.
Selon Phil Blundell <[email protected]>:
Quoted 6 lines · Holger Hans Peter Freyther
Quoted 5 lines · On Monday 28 September 2009 02:16:07 Alain2210 wrote:
Quoted 3 lines
Hello,
xmonobut segfault. I need this patch to get it works again.
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
main.c renamed from main.c.orig +1
-1-unsigned char map[6 ]; +unsigned char map[31 ];...
Quoted 1 line
+ buts =
XGetPointerMapping(dpy, map, 32);,,.
Quoted 1 line
+
while((rst = XSetPointerMapping(dpy, map, 32)) == MappingBusy);31. vs 32... please send an updated patch
Sorry for the mistake.
Quoted 2 lines
Looking at this patch again, I think it is just broken and (even aside from the 31/32 thing) should not be applied.
I have seen in the september answer that you says that xlib should be corrected. In fact, I do not understand the behaviour of XG/SetPointerMapping since the third argument seems to be ignored in a certain sense.
Quoted 9 lines
I guess the cause of the original segfault was that "buts" is set to a value greater than six and hence the
XSetPointerMapping()call runs off the end of the array. However, the solution presented in the patch, i.e. just ignoring the return value fromXGetPointerMapping()altogether, doesn't seem too good either since this will causeXSetPointerMapping()to read uninitialised garbage from the balance of the array.
Quoted 7 lines
A minimal fix for the original crash would probably be to insert something like:
if (buts > sizeof(map))
buts = sizeof(map);after the
XGetPointerMapping()call.
I will try this. (and will try to remember what was exactly the problem).
Quoted 4 lines
A slightly better fix would
perhaps be to make an initial call toXGetPointerMapping()with nmap=0 to find out how many buttons are present, then to dynamically allocate an array of the right size and read the mapping into it.
Sorry, it is beyond my capabilities.
Thanks,
Alain