GNOME Bugzilla – Bug 343546
devilspie segfaults in 'center' funtion
Last modified: 2007-09-23 19:43:30 UTC
Please describe the problem: A documentation for 'libwnck' has the following to say about 'wnck_screen_get_active_workspace ()': "May return NULL sometimes, if we are in a weird state due to the asynchronous nature of our interaction with the window manager". At least with the current libwnck-2.15.2-2 (Fedora "rawhide") we are actually getting NULL always, AFICS, at least in my tests. Unfortunately func_center() is using this function and is passing the resulting NULL to wnck_workspace_get_width(), without checks, and this is causing an immediate segfault. Steps to reproduce: 1. provide in ~/.devilspie/ a .ds file which uses (center) 2. run devilspie 0.17.1 at least with some version of libwnck libraries 3. Actual results: segfault Expected results: Does this happen every time? Other information:
Created attachment 66563 [details] [review] patch which prevents segfault described above if 'wnck_screen_get_workspace ()' is used instead then, at least in my tests, NULL is not returned. OTOH maybe there are situations when geometry of other workspaces is different then geometry of workspace 0 but I did not have a better workaround at this moment. In any case a return value should be checked. With this patch, and the one from bug #330067, (center) does work as expected.
In what situations would get_active_workspace() fail?
On my current test setup ("rawhide" for Fedora Core, libwnck-2.15.2-2) 'wnck_screen_get_active_workspace()' consistently returns NULL _always_ when I am trying to use it in 'func_center()'. In an unpatched code this mean an instant segfault. It is difficult to classify that as "fail" if a documentation explicitely states that NULL may be returned "... due to the asynchronous nature of our interaction with the window manager". If there is some documented way to force such synchronization, so a non-NULL 'workspace' pointer will be always returned, I really have no idea.
Same bug here. With compiz, i try to force all windows to be centered at startup. gnumdk@flanders:~/.devilspie$ cat all.ds (if (matches (application_name) ".*") (begin (center) ) ) gnumdk@flanders:~/.devilspie$ devilspie Erreur de segmentation (segfault in french) gnumdk@flanders:~/.devilspie$
A similar patch has been committed to svn.
*** Bug 420097 has been marked as a duplicate of this bug. ***