Font selection on MacOS (especially Big Sur and Monterey) leads to _gtk_css_font_weight_value_new warning and _gtk_css_value_ref segfault
Steps to reproduce
When calling the gtk+ testfontselection
test on some installations of MacOS (especially Big Sur and Monterey), an illegal weight font (of value 0) leads to a warning then, either to a segfault (in non-debug mode) or another warning (in debug=yes mode).
I tried to debug a bit but w/o final success. At some time, the call to font_weight_assign
(via _gtk_style_properties_set_property_by_property
) calls _gtk_css_font_weight_value_new
with value 0 instead of one of the possible enumerated values of PangoWeight
(100, 200, etc.). So, presumably font_weight_assign
does not already get a valid GValue
that g_value_get_enum
can extract.
In particular, I could not understand what is special to MacOS, except that the buggy weight is related to the font family .AppleSystemUIFont
: the warning appears 4 times, corresponding to 4 calls to font_weight_assign
with value 0, out of 42 calls to font_weight_assign
(i.e. 38 valid calls) for which the corresponding call to font_family_assign
reports the name .AppleSystemUIFont
. Knowing from where gtk+ extracts the font properties of MacOS would probably help.
Note that the original issue that led to this report is a crash of coqide reported for MacOS Big Sur and Monterey (but also observed on a specific installation of Sierra).
Version information
Tested with GTK+ 3.24.34
Warnings
file ../gtk/gtkcssenumvalue.c: line 529 (_gtk_css_font_weight_value_new): should not be reached
Backtrace
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libgtk-3.0.dylib 0x103a40c54 _gtk_css_value_ref + 0
1 libgtk-3.0.dylib 0x103cc19f8 _gtk_style_properties_set_property_by_property + 276
2 libgtk-3.0.dylib 0x103a3b92c _gtk_css_style_property_assign + 64
3 libgtk-3.0.dylib 0x103a370d8 unpack_font_description + 436
...
With debug=yes, we get instead the warning:
(<unknown>:69747): Gtk-CRITICAL **: 21:13:52.956: _gtk_css_value_ref: assertion 'value != ((void*)0)' failed