I am using Wnck
version 3 with python3. The following code cause my program to throw segmentation fault. What is the cause of this issue? and how could I solve it? so I could use Wnck
safely. I don’t see an issue with my code a simple variable assignment cause segmentation fault!!!. To reproduce run the following script.
for i in {1..100}; do python3 window.py & sleep 0.5; sudo kill -9 `pgrep -f "python3 window.py"`; done
window.py
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
window = Gtk.Window()
window.connect('destroy', Gtk.main_quit)
window.show_all()
Gtk.main()
faulty_code.py
w = None
def on_window_opened(screen, window):
global w
if not window:
return
w = window
def main():
Gdk.init([])
loop = GLib.MainLoop.new(None, False)
screen = Wnck.Screen.get_default()
screen.connect("window-opened", on_window_opened)
loop.run()
if __name__ == "__main__":
main()
/wnck_sigfault.py:10: Warning: invalid unclassed pointer in cast to 'WnckClassGroup'
w = window
/wnck_sigfault.py:10: Warning: g_hash_table_remove_internal: assertion 'hash_table != NULL' failed
w = window
Segmentation fault (core dumped)