segfault when no X11 is available / DISPLAY=""
Running a simple python gtk application (e.g. the hello world example from [1]) without access to the X server crashes.
Test:
- Save example from [1] as hello.py
- run: DISPLAY="" python3 hello.py
This looks like a null pointer deref. I'll paste an ASAN stack trace below.
[1] https://python-gtk-3-tutorial.readthedocs.io/en/latest/introduction.html
==9099==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000018 (pc 0x7f323789bf78 sp 0x7ffca73d0320 bp 0x6290000a2020 T0)
#0 0x7f323789bf77 in _gtk_settings_get_screen /var/tmp/portage/x11-libs/gtk+-3.24.2/work/gtk+-3.24.2/gtk/gtksettings.c:3300
#1 0x7f32375d9b3f in gtk_css_value_icon_theme_compute /var/tmp/portage/x11-libs/gtk+-3.24.2/work/gtk+-3.24.2/gtk/gtkcssiconthemevalue.c:84
#2 0x7f3237617d17 in gtk_css_static_style_compute_value /var/tmp/portage/x11-libs/gtk+-3.24.2/work/gtk+-3.24.2/gtk/gtkcssstaticstyle.c:237
#3 0x7f32375ee55c in _gtk_css_lookup_resolve /var/tmp/portage/x11-libs/gtk+-3.24.2/work/gtk+-3.24.2/gtk/gtkcsslookup.c:122
#4 0x7f3237617bf3 in gtk_css_static_style_new_compute /var/tmp/portage/x11-libs/gtk+-3.24.2/work/gtk+-3.24.2/gtk/gtkcssstaticstyle.c:195
#5 0x7f3237617ca4 in gtk_css_static_style_get_default /var/tmp/portage/x11-libs/gtk+-3.24.2/work/gtk+-3.24.2/gtk/gtkcssstaticstyle.c:164
#6 0x7f32375f0145 in gtk_css_node_init /var/tmp/portage/x11-libs/gtk+-3.24.2/work/gtk+-3.24.2/gtk/gtkcssnode.c:667
#7 0x7f323ade294e in g_type_create_instance (/usr/lib64/libgobject-2.0.so.0+0x7b94e)
#8 0x7f323ada242e (/usr/lib64/libgobject-2.0.so.0+0x3b42e)
#9 0x7f323ada4b80 in g_object_new_with_properties (/usr/lib64/libgobject-2.0.so.0+0x3db80)
#10 0x7f323ada63d3 in g_object_new (/usr/lib64/libgobject-2.0.so.0+0x3f3d3)
#11 0x7f3237625cc9 in gtk_css_widget_node_new /var/tmp/portage/x11-libs/gtk+-3.24.2/work/gtk+-3.24.2/gtk/gtkcsswidgetnode.c:297
#12 0x7f3237a21715 in gtk_widget_init /var/tmp/portage/x11-libs/gtk+-3.24.2/work/gtk+-3.24.2/gtk/gtkwidget.c:4420
#13 0x7f323ade294e in g_type_create_instance (/usr/lib64/libgobject-2.0.so.0+0x7b94e)
#14 0x7f323ada242e (/usr/lib64/libgobject-2.0.so.0+0x3b42e)
#15 0x7f323ada5364 in g_object_newv (/usr/lib64/libgobject-2.0.so.0+0x3e364)
#16 0x7f323aef905e (/usr/lib64/python3.6/site-packages/gi/_gi.cpython-36m-x86_64-linux-gnu.so+0x2e05e)
#17 0x7f323af09bc7 (/usr/lib64/python3.6/site-packages/gi/_gi.cpython-36m-x86_64-linux-gnu.so+0x3ebc7)
#18 0x7f323ea6ca1b (/usr/lib64/libpython3.6m.so.1.0+0x231a1b)
#19 0x7f323e982241 in _PyObject_FastCallDict (/usr/lib64/libpython3.6m.so.1.0+0x147241)
#20 0x7f323e9ca816 (/usr/lib64/libpython3.6m.so.1.0+0x18f816)
#21 0x7f323e981ebf in PyObject_Call (/usr/lib64/libpython3.6m.so.1.0+0x146ebf)
#22 0x7f323eb629b9 in _PyEval_EvalFrameDefault (/usr/lib64/libpython3.6m.so.1.0+0x3279b9)
#23 0x7f323eb57e50 (/usr/lib64/libpython3.6m.so.1.0+0x31ce50)
#24 0x7f323eb71384 in _PyFunction_FastCallDict (/usr/lib64/libpython3.6m.so.1.0+0x336384)
#25 0x7f323e98243d in _PyObject_FastCallDict (/usr/lib64/libpython3.6m.so.1.0+0x14743d)
#26 0x7f323e9829d8 in _PyObject_Call_Prepend (/usr/lib64/libpython3.6m.so.1.0+0x1479d8)
#27 0x7f323e981ebf in PyObject_Call (/usr/lib64/libpython3.6m.so.1.0+0x146ebf)
#28 0x7f323ea80733 (/usr/lib64/libpython3.6m.so.1.0+0x245733)
#29 0x7f323ea76e01 (/usr/lib64/libpython3.6m.so.1.0+0x23be01)
#30 0x7f323e982241 in _PyObject_FastCallDict (/usr/lib64/libpython3.6m.so.1.0+0x147241)
#31 0x7f323eb589b0 (/usr/lib64/libpython3.6m.so.1.0+0x31d9b0)
#32 0x7f323eb6522e in _PyEval_EvalFrameDefault (/usr/lib64/libpython3.6m.so.1.0+0x32a22e)
#33 0x7f323eb57e50 (/usr/lib64/libpython3.6m.so.1.0+0x31ce50)
#34 0x7f323eb58fbd in PyEval_EvalCodeEx (/usr/lib64/libpython3.6m.so.1.0+0x31dfbd)
#35 0x7f323eb58fea in PyEval_EvalCode (/usr/lib64/libpython3.6m.so.1.0+0x31dfea)
#36 0x7f323ebc5c47 (/usr/lib64/libpython3.6m.so.1.0+0x38ac47)
#37 0x7f323ebcaf94 in PyRun_FileExFlags (/usr/lib64/libpython3.6m.so.1.0+0x38ff94)
#38 0x7f323ebcb271 in PyRun_SimpleFileExFlags (/usr/lib64/libpython3.6m.so.1.0+0x390271)
#39 0x7f323ebff975 in Py_Main (/usr/lib64/libpython3.6m.so.1.0+0x3c4975)
#40 0x401337 in main (/usr/bin/python3.6m+0x401337)
#41 0x7f323e274ae6 in __libc_start_main (/lib64/libc.so.6+0x21ae6)
#42 0x4014c9 in _start (/usr/bin/python3.6m+0x4014c9)