Bugs item #1484284, was opened at 2006-05-08 18:56
Message generated for change (Comment added) made by brianp
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=100003&aid=1484284&group_id=3

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
>Status: Closed
Resolution: Fixed
Priority: 5
Submitted By: Josh Holtrop (jh0038)
Assigned to: Nobody/Anonymous (nobody)
Summary: glutMouseFunc segmentation fault with scroll wheel

Initial Comment:
Josh Holtrop & John Van Enk

The attached program seems to crash on 64-bit boxen
when scrolling the mouse up in the window.

The problem might be due to the following:

glutint.h contains the following line:
#define GLUT_MAX_MENUS              3
  int menu[GLUT_MAX_MENUS];  /* attatched menu nums */


and glut_event.c contains the following:
menuNum = window->menu[event.xbutton.button - 1];


Now my xorg setup maps my mouse's "Z axis" (scroll
wheel) mouse buttons to numbers 4 and 5. If
event.xbutton.button was higher than 2 it seems like
this code would be indexing farther into the menu array
then it should be. Perhaps a bounds check of some sort
would be appropriate.



----------------
Platform:
Gentoo Linux, kernel 2.6.15-gentoo-r7
xorg 6.8.2
AMD Athlon(tm) 64 Processor 3000+


----------------------------------------------------------------------

>Comment By: Brian Paul (brianp)
Date: 2006-05-10 13:22

Message:
Logged In: YES 
user_id=983

OK, I see what you mean now.  I've checked in your fix.


----------------------------------------------------------------------

Comment By: Josh Holtrop (jh0038)
Date: 2006-05-10 10:06

Message:
Logged In: YES 
user_id=1519494

The solution I proposed would not be treating higher number
buttons as if they were *button* number 0, rather *menuNum*
0, which looked to me like it would signal that no menu was
accessed and would cause the window->mouse() callback to be
called normally. That seems like it would keep the max
number of menus at 3 just fine but allow higher buttons to
work with the callback.

Now, increasing GLUT_MAX_MENUS to 5 would probably also
solve the problem as long as those new couple entries were
initialized correctly.


----------------------------------------------------------------------

Comment By: Brian Paul (brianp)
Date: 2006-05-10 08:50

Message:
Logged In: YES 
user_id=983

I would not presume that higher-numbered buttons should be
treated as if they were button zero.

My feeling is that pressing a button that doesn't explicitly
have a menu attached to it should not cause a menu to appear.

Upon examining the code, there's other problems.  There's a
few places where the _GLUTwindow::menu[] array is indexed
without checking if the index is < GLUT_MAX_MENUS.

Also, GLUT_MAX_MENUS is three, but __glutNumMouseButtons is
never clamped to that value.

Maybe GLUT_MAX_MENUS should be increased to something like 5
and _glutNumButtons should be clamped to that value.


----------------------------------------------------------------------

Comment By: Josh Holtrop (jh0038)
Date: 2006-05-09 21:44

Message:
Logged In: YES 
user_id=1519494

Thanks for fixing, and in the future I will use the
freedesktop.org database.

However, I'm not sure that your solution is appropriate.
You now have the check:
if (window && event.xbutton.button <= GLUT_MAX_MENUS)

which would seem to bypass the entire calling of the mouse
function callback in the block of the if statement if the
button number is too high:
window->mouse( ... )

Since, presumably, you'd still want the mouse callback
called for higher button numbers, it would seem more
appropriate to keep the
if (window)
check, but change the line where it indexes into the menu array:
menuNum = (event.xbutton.button <= GLUT_MAX_MENUS) ?
window->menu[event.xbutton.button - 1] : 0;


----------------------------------------------------------------------

Comment By: Brian Paul (brianp)
Date: 2006-05-09 08:53

Message:
Logged In: YES 
user_id=983

I've added a bounds check.  Thanks.

In the future, please report bugs in the database on
freedesktop.org


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=100003&aid=1484284&group_id=3


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Mesa3d-dev mailing list
Mesa3d-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to