After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 597292 - handling of flags types with unknown flags
handling of flags types with unknown flags
Status: RESOLVED FIXED
Product: gjs
Classification: Bindings
Component: general
unspecified
Other Linux
: Normal major
: ---
Assigned To: gjs-maint
gjs-maint
Depends on: 634994
Blocks:
 
 
Reported: 2009-10-04 12:44 UTC by Bjørn Haagensen
Modified: 2011-06-14 20:05 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Bjørn Haagensen 2009-10-04 12:44:21 UTC
Sometimes alt-tab stops working and I get the errors below in the terminal. The popup works and I can change between the two most recent (I think) windows, but subsequent tab'ing produces the error. The error will also seemingly randomly dissappear and reappear. 

System is Ubuntu 9.10 beta updated as of 4.10.2009. gnome-shell is of the git-repository pulled the same date (donno how to get more specific version-info)
built using 'jhbuild build'. 


    JS ERROR: !!!   Exception was: Error: 0x2018 is not a valid value for flags GdkModifierType
    JS ERROR: !!!     lineNumber = '0'
    JS ERROR: !!!     fileName = 'gjs_throw'
    JS ERROR: !!!     message = '0x2018 is not a valid value for flags GdkModifierType'
    JS ERROR: !!!     stack = 'Error("0x2018 is not a valid value for flags GdkModifierType")@:0
("0x2018 is not a valid value for flags GdkModifierType")@gjs_throw:0
@:0
(1)@/home/bh/gnome-shell/source/gnome-shell/js/ui/altTab.js:148
([object _private_Shell_WM],"switch_windows",null,false)@/home/bh/gnome-shell/source/gnome-shell/js/ui/windowManager.js:277
([object _private_Shell_WM],"switch_windows",null,false)@/home/bh/gnome-shell/install/share/gjs-1.0/lang.js:110
Error("Chained exception")@:0
("Chained exception")@gjs_throw:0
'
Comment 1 Bjørn Haagensen 2009-10-04 12:56:06 UTC
git-version is 9b05304c2d58b8fc5f5e75c6a2ac2ec4523d4565
Comment 2 Dan Winship 2009-10-04 14:01:39 UTC
    JS ERROR: !!!   Exception was: Error: 0x2018 is not a valid value for flags
GdkModifierType

of course, GdkModifierType is just a wrapper around a set of X defines, and sometimes contains bits that don't have names in the GdkModifierType enum. I think this has to be considered a gjs bug?

(gdktypes.h suggests that 0x2000 is something XKB-related. So if this only happens sometimes, it may have to do with either (a) which keyboard layout you're using at the time, or (b) whether the currently-selected app supports XKB natively or is using the fallback to core X keyboard support.)

We can work around this in 2.28.0 by just writing a C function to check the modifier state for us.
Comment 3 Havoc Pennington 2009-10-04 14:05:59 UTC
not sure what we'd do here. maybe introspection should have an annotation like "flags can have arbitrary value, do not validate" ?
Comment 4 Dan Winship 2009-10-04 14:16:55 UTC
Hm. I was going to say that there's no need to validate values coming *from* C, but I guess if you still validated values going *to* C then you'd end up with situations where something like:

    foo.set_flags(foo.get_flags() | PERFECTLY_LEGITIMATE_VALUE);

could fail

What Would PyGtk Do?
Comment 5 Bjørn Haagensen 2009-10-04 14:36:58 UTC
Briefly scanned your comments and I can confirm that I am alternating between two keyboard layouts at "run time", Danish and UK.
Comment 6 Havoc Pennington 2009-10-04 15:05:15 UTC
I guess just never validating at all is an option, the tradeoff is there's more ability to crash C code from JS

Don't know if it's worth a special-case in introspection or not to preserve that
Comment 7 Bjørn Haagensen 2009-10-04 15:14:48 UTC
Just a brief comment to tell you that sticking to only one layout (only tried UK) seems to avoid the problem.
Comment 8 Dan Winship 2009-10-06 15:06:15 UTC
(In reply to comment #4)
> What Would PyGtk Do?

it appears to just strip them out. eg:

>>> gtk.gdk.display_get_default().get_pointer()
(<gtk.gdk.ScreenX11 object at 0x7f9d030100f0 (GdkScreenX11 at 0xa0e180)>, 245, 769, <flags GDK_MOD2_MASK of type GdkModifierType>)

while xev shows:

KeyPress event, serial 30, synthetic NO, window 0x4000001,
    root 0x100, subw 0x0, time 148402192, (82,155), root:(86,203),
    state 0x2010, keycode 38 (keysym 0x71, q), same_screen YES,
          ^^^^^^
Comment 9 Dan Winship 2009-10-06 15:07:31 UTC
oh btw, bug 597559 filed with workaround for gnome-shell. Bjørn, could you test that?
Comment 10 Havoc Pennington 2009-10-06 15:12:44 UTC
that's kinda evil... I mean, in theory the keyboard group flag is useful.

Maybe the real bug here is in GDK for not defining an enum value for that flag bit?
Comment 11 Dan Winship 2009-10-06 20:09:30 UTC
git bz fail
Comment 12 Colin Walters 2010-11-16 16:07:39 UTC
https://bugzilla.gnome.org/show_bug.cgi?id=634994
Comment 13 Colin Walters 2010-11-19 17:15:41 UTC
So a data point is that pygtk appears to have changed in the last year, I now get:

KeyPress event, serial 33, synthetic NO, window 0x5600001,
    root 0x126, subw 0x0, time 6277267, (630,638), root:(634,687),
    state 0x4000, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False


(<gtk.gdk.ScreenX11 object at 0x1a3b0f0 (GdkScreenX11 at 0x1abd7d0)>, 628, 711, <flags 16384 of type GdkModifierType>)
Comment 14 Colin Walters 2011-05-16 16:50:01 UTC
Clutter fix:
https://bugzilla.gnome.org/show_bug.cgi?id=650329
Comment 15 Colin Walters 2011-06-14 20:05:10 UTC
This should be fixed now.