pango_layout_get_pixel_size() causes critical warnings and loops
See the following testcase:
#include <pango/pango.h>
int main() {
PangoContext *ctx = pango_context_new();
PangoLayout *layout = pango_layout_new(ctx);
pango_layout_set_text(layout, "blabla", -1);
gint width, height;
pango_layout_get_pixel_size(layout, &width, &height);
printf("%d %d\n", width, height);
return 0;
}
Running this leads to
(process:1132007): Pango-CRITICAL **: 23:22:04.147: pango_font_map_load_fontset: assertion 'fontmap != NULL' failed
(process:1131332): GLib-GObject-CRITICAL **: 23:17:26.912: g_object_get_qdata: assertion 'G_IS_OBJECT (object)' failed
(process:1131332): GLib-GObject-CRITICAL **: 23:17:26.912: g_object_replace_qdata: assertion 'G_IS_OBJECT (object)' failed
with the last two lines looping forever. Backtrace of the first warning is
(process:1132007): Pango-CRITICAL **: 23:22:04.147: pango_font_map_load_fontset: assertion 'fontmap != NULL' failed
Program received signal SIGTRAP, Trace/breakpoint trap.
g_logv (log_domain=0x7ffff7f76e6d "Pango", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=<optimized out>) at ../../../glib/gmessages.c:1417
1417 ../../../glib/gmessages.c: No such file or directory.
(gdb) bt
#0 g_logv (log_domain=0x7ffff7f76e6d "Pango", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=<optimized out>) at ../../../glib/gmessages.c:1417
#1 0x00007ffff7b5a78f in g_log (log_domain=log_domain@entry=0x7ffff7f76e6d "Pango", log_level=log_level@entry=G_LOG_LEVEL_CRITICAL, format=format@entry=0x7ffff7bb1d3a "%s: assertion '%s' failed")
at ../../../glib/gmessages.c:1455
#2 0x00007ffff7b5afd9 in g_return_if_fail_warning
(log_domain=log_domain@entry=0x7ffff7f76e6d "Pango", pretty_function=pretty_function@entry=0x7ffff7f7c930 <__func__.4> "pango_font_map_load_fontset", expression=expression@entry=0x7ffff7f7c7da "fontmap != NULL") at ../../../glib/gmessages.c:2898
#3 0x00007ffff7f607ce in pango_font_map_load_fontset (fontmap=<optimized out>, context=<optimized out>, desc=<optimized out>, language=<optimized out>) at ../pango/pango-fontmap.c:161
#4 0x00007ffff7f5d7bc in itemize_state_update_for_new_run (state=0x7fffffffdcc0) at ../pango/pango-context.c:1466
#5 itemize_state_process_run (state=state@entry=0x7fffffffdcc0) at ../pango/pango-context.c:1491
#6 0x00007ffff7f5ea68 in pango_itemize_with_base_dir
(context=0x555555566420 [PangoContext], base_dir=base_dir@entry=PANGO_DIRECTION_LTR, text=0x555555569000 "blabla", start_index=0, length=6, attrs=attrs@entry=0x0, cached_iter=0x0)
at ../pango/pango-context.c:1646
#7 0x00007ffff7f67d46 in pango_layout_check_lines (layout=<optimized out>) at ../pango/pango-layout.c:4389
#8 0x00007ffff7f69c39 in pango_layout_get_extents_internal (layout=0x555555568830 [PangoLayout], ink_rect=ink_rect@entry=0x0, logical_rect=logical_rect@entry=0x7fffffffe530, line_extents=line_extents@entry=0x0)
at ../pango/pango-layout.c:2698
#9 0x00007ffff7f6a1bd in pango_layout_get_pixel_size (layout=<optimized out>, width=0x7fffffffe57c, height=0x7fffffffe578) at ../pango/pango-layout.c:2967
#10 0x00005555555551cc in main () at test.c:8