Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#16820 closed defect (fixed)

Crash when creating wx.FontDialog under GTK3

Reported by: swt2c Owned by: Vadim Zeitlin <vadim@…>
Priority: normal Milestone:
Component: wxGTK Version: 3.0.2
Keywords: Cc:
Blocked By: Blocking:
Patch: yes

Description

When creating a wx.FontDialog under wxPython (3.0.2.0 compiled with wxGTK3 backend), these errors are emitted and then the application crashes:

[talbert@easel demo]$ python FontDialog.py
Python 2.7.8 (default, Nov 10 2014, 08:19:18)
[GCC 4.9.2 20141101 (Red Hat 4.9.2-1)]
wx.version: 3.0.2.0 gtk3 (classic)

(FontDialog.py:4710): Gtk-WARNING : Unknown type PangoFontFace specified in treemodel model

(FontDialog.py:4710): Gtk-WARNING : gtkliststore.c:516: Invalid type (null)

(FontDialog.py:4710): GLib-GObject-CRITICAL : g_value_type_transformable: assertion 'G_TYPE_IS_VALUE (src_type)' failed

(FontDialog.py:4710): GLib-GObject-WARNING : gtype.c:4221: type id '0' is invalid

(FontDialog.py:4710): GLib-GObject-WARNING : can't peek value table for type '<invalid>' which is not currently referenced
Segmentation fault (core dumped)

I have done some investigation but I can't for the life of me figure out why it is failing. What's odd is that the wxGTK font sample application works fine, and the wxPython sample does basically the same thing.

Attachments (2)

dlopenflags_v2.patch download (1.2 KB) - added by swt2c 5 years ago.
0001-Ensure-the-PangoFontFace-type-is-loaded.patch download (740 bytes) - added by swt2c 5 years ago.
wxWidgets workaround

Download all attachments as: .zip

Change History (13)

comment:1 Changed 5 years ago by swt2c

So, after a long investigation, I figured out what's going on here. It turns out that GTK loads some function addresses at runtime using dlsym(). In this particular case, it is trying to load the function pango_font_face_get_type(). It does so after doing a dlopen(NULL). In the case of wxGTK, the GTK and dependent libraries have been loaded globally, so it finds the symbol. In the case of wxPython, since the Python extension modules are loaded locally (ie, python does dlopen(RTLD_LOCAL)), GTK can't find the symbol.

I'm looking at having wxPython load its extension modules with RTLD_GLOBAL as a possible solution.

comment:2 Changed 5 years ago by vadz

  • Component changed from wxGTK to wxPython

Doing dlopen(NULL) in GTK looks like a really bad idea, perhaps you could convince GTK people to avoid doing this?

comment:3 Changed 5 years ago by swt2c

I don't disagree, but that seems to be the way they are going. See the discussion here:
https://bugzilla.gnome.org/show_bug.cgi?id=745066

Changed 5 years ago by swt2c

comment:4 Changed 5 years ago by swt2c

  • Patch set

Patch attached that sets the dlopen flags before importing the core wx C extension, causing GTK's symbols to be loaded into the global namespace.

Changed 5 years ago by swt2c

wxWidgets workaround

comment:5 Changed 5 years ago by swt2c

I am a bit worried about potential impacts from the dlopen() change. Instead, I would propose a lower-impact workaround. I know this isn't really a wxWidgets issue, but would you consider this simple patch to ensure the PangoFontFace type is loaded. If not, it can probably go in the wxPython C++ code.

comment:7 Changed 5 years ago by swt2c

  • Component changed from wxPython to wxGTK

Reassigning back to wxGTK for consideration of lower-risk patch.

comment:8 Changed 5 years ago by Vadim Zeitlin <vadim@…>

  • Owner set to Vadim Zeitlin <vadim@…>
  • Resolution set to fixed
  • Status changed from new to closed

In 54e653d044f81f15f48aec0da20df274b6aebacc/git-wxWidgets:

Ensure the PangoFontFace type is loaded.

This works around problems with using wxFontDialog from wxPython.

Closes #16820.

comment:9 Changed 5 years ago by swt2c

  • Resolution fixed deleted
  • Status changed from closed to reopened

Thanks. Do you mind cherry-picking this to WX_3_0_BRANCH also?

comment:10 Changed 5 years ago by Vadim Zeitlin <vadim@…>

  • Resolution set to fixed
  • Status changed from reopened to closed

In 5d3376802258191166a86cd9175cb4adb0a16c2e/git-wxWidgets:

Ensure the PangoFontFace type is loaded.

This works around problems with using wxFontDialog from wxPython.

Closes #16820.

comment:11 Changed 5 years ago by Vadim Zeitlin <vadim@…>

In 44e3c508398dc81639333715edb95dc0e3264381/git-wxWidgets:

Compilation fix for wxGTK3 after PangoFontFace fix.

Bracket the changes of 54e653d044f81f15f48aec0da20df274b6aebacc with a glib
version check: g_type_ensure() is only available in 2.34+.

See #16820.

Note: See TracTickets for help on using tickets.