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 609101 - [PATCH] assigning key binding to list of keys always causes crash
[PATCH] assigning key binding to list of keys always causes crash
Status: RESOLVED OBSOLETE
Product: metacity
Classification: Other
Component: general
2.28.x
Other Linux
: Normal critical
: ---
Assigned To: Metacity maintainers list
Metacity maintainers list
Depends on:
Blocks:
 
 
Reported: 2010-02-05 16:17 UTC by Stanislav Brabec
Modified: 2012-02-08 14:03 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
metacity-key-list-binding.patch (505 bytes, patch)
2010-02-05 16:17 UTC, Stanislav Brabec
needs-work Details | Review
Fix crash on startup with list bindings (4.46 KB, patch)
2010-02-18 19:30 UTC, Owen Taylor
none Details | Review

Description Stanislav Brabec 2010-02-05 16:17:36 UTC
Created attachment 153091 [details] [review]
metacity-key-list-binding.patch

Metacity is capable to assign a function to more than one key using "_list" gconf key name and string array list value. However any attempt to use this feature always causes a crash.

How to reproduce:
For example setting /apps/metacity/global_keybindings/panel_main_menu_list to string array [Super_L,Super_R]


init_bindings() wants to initialize key bindings. Key panel_main_menu_list
(guessingh that this value does not come from upstream but
gconf2-branding-sled) ends with "_list" and it is processed specially by
update_key_list_binding(key,list_val)

update_key_list_binding(key,list_val) calls
find_and_update_list_binding(key_bindings, name==key, value==list_val)

It cuts the key suffix ("panel_main_menu") does some processing and calls:
update_list_binding(key_bindings,value,type_of_value)

Type of value is always META_LIST_OF_GCONFVALUE_STRINGS (well, strange - the
function is static, called only from a single place, value can never have
different value), the code reaches:
pref_string = gconf_value_get_string (pref_iterator->data);

It always fails (the value in question is string list, not string) and
pref_string is NULL.

NULL is always passed to meta_ui_parse_accelerator (pref_string==NULL, &keysym,
&keycode, &mods) and it always crashes.


Attached patch is the minimal patch.


But it seems the code wants more changes:

There is no use for the other of META_LIST_OF_STRINGS/META_LIST_OF_GCONFVALUE_STRINGS. Argument is always the same.

The whole MetaStringListType has no use - only one value is actually actively used.

Third argument of update_list_binding() is always the same and can be removed.

update_key_list_binding() seems to be intermediate function that only adds one level of indirection with no reason.

Maybe meta_ui_parse_accelerator() should check accel for NULL or use g_strcmp0.

Well, and there is yet another NULL sanity check missing, but it seems to be safe with
the current implementation: list_val can be NULL if the key has suffix "_list"
but the value is is not a list.
Comment 1 Stanislav Brabec 2010-02-05 16:18:39 UTC
Forgot the backtrace:

Program received signal SIGSEGV, Segmentation fault.
0x000000000046312b in meta_ui_parse_accelerator (accel=0x0,
keysym=0x7fffffffdce4, 
    keycode=0x7fffffffdce0, mask=0x7fffffffdcdc) at ui/ui.c:768


  • #0 meta_ui_parse_accelerator
    at ui/ui.c line 768
  • #1 update_list_binding
    at core/prefs.c line 2157
  • #2 find_and_update_list_binding
    at core/prefs.c line 2275
  • #3 update_key_list_binding
    at core/prefs.c line 2284
  • #4 init_bindings
    at core/prefs.c line 1865
  • #5 meta_prefs_init
    at core/prefs.c line 1058
  • #6 main
    at core/main.c line 495

Comment 2 Owen Taylor 2010-02-18 19:30:46 UTC
Created attachment 154165 [details] [review]
Fix crash on startup with list bindings

Just hit and debugged the same crash in the context of Mutter; I don't
think that your patch is really right - in the case when the list key
is changed on the fly, the list passed into update_key_binding() is a
list of GConfValue, not a list of strings; so we actually need to keep
the MetaStringListType and pass it down.

If my understanding is correct, your patch will cause misbehavior or
a crash when the _list key is changed on the fly while Metacity is
running.

You are right that the indirection in update_key_list_binding() /
find_and_update_list_binding() is a bit silly, but I've left that
untouched - it's not really doing any harm.
Comment 3 Owen Taylor 2010-02-18 19:32:37 UTC
Review of attachment 153091 [details] [review]:

Marking your patch needs-work based on my analysis above.
Comment 4 Owen Taylor 2010-02-18 21:25:21 UTC
Attachment 154165 [details] pushed as 8875e73 - Fix crash on startup with list bindings
Comment 5 Stanislav Brabec 2010-03-12 15:29:38 UTC
Your fix does not crash while changing the key list on the fly.

But it is still not fully correct:

- Change of foo_list on the fly has no effect. One has to change key foo to get new value of foo_list into effect.
Comment 6 Stanislav Brabec 2010-03-12 15:33:23 UTC
Update: Only removal of foo_list has no immediate effect. Other changes (addition, change) seems to work.
Comment 7 Vincent Untz 2010-09-16 08:03:50 UTC
Can we get Owen's patch committed to metacity? :-)
Comment 8 Vincent Untz 2012-02-08 14:03:18 UTC
Pretty sure this is obsolete with the move to gsettings.