[Libreoffice-commits] core.git: vcl/unx

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Sun Jun 27 18:12:22 UTC 2021


 vcl/unx/gtk3/gtkinst.cxx |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

New commits:
commit 5e37a1d89dfaa12690841213bce0cb6d05faf90a
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Fri Jun 25 16:00:26 2021 +0200
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Sun Jun 27 20:11:49 2021 +0200

    Silence UBSan dynamic-type-mismatch for VclPtr member in GObject
    
    ...that wasn't properly initialized (in an --enable-dbgutil build; see also
    <https://gerrit.libreoffice.org/c/core/+/117878> "There appears to be no reason
    for (DBG_UTIL-only) ~VclPtr to be virtual", but even when VclPtr has no vtable,
    it arguably is to properly con- and destruct CustomCellRendererSurface::device).
    
    For example, in Writer clicking on the "Styles" icon in the side bar:
    
    > vcl/unx/gtk3/gtkinst.cxx:15144:10: runtime error: member call on address 0x625001b42668 which does not point to an object of type 'VclPtr<VirtualDevice>'
    > 0x625001b42668: note: object has invalid vptr
    >  50 62 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  10 8a f0 00 30 60 00 00  80 f8 19 02
    >               ^~~~~~~~~~~~~~~~~~~~~~~
    >               invalid vptr
    >  #0 in (anonymous namespace)::ensure_device((anonymous namespace)::CustomCellRendererSurface*, weld::Widget*) at vcl/unx/gtk3/gtkinst.cxx:15144:10
    
    Change-Id: Ic6ab75668e5b3ecca6d1e5743ed1907c8cbdb143
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117915
    Tested-by: Jenkins
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index 42aee39d4d2c..228b5c1d8d3c 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -7014,6 +7014,10 @@ static gpointer custom_cell_renderer_surface_parent_class;
 static GType custom_cell_renderer_surface_get_type();
 static void custom_cell_renderer_surface_class_init(CustomCellRendererSurfaceClass *klass);
 
+static void custom_cell_renderer_surface_init(GTypeInstance * instance, gpointer) {
+    new(&CUSTOM_CELL_RENDERER_SURFACE(instance)->device) VclPtr<VirtualDevice>;
+}
+
 GType custom_cell_renderer_surface_get_type()
 {
     static GType type = 0;
@@ -7030,7 +7034,7 @@ GType custom_cell_renderer_surface_get_type()
             nullptr, /* class data */
             sizeof (CustomCellRendererSurface), /* instance size */
             0,       /* nb preallocs */
-            nullptr, /* instance init */
+            &custom_cell_renderer_surface_init, /* instance init */
             nullptr  /* value table */
         };
 
@@ -7105,6 +7109,7 @@ static void custom_cell_renderer_surface_finalize(GObject *object)
 
     g_free(cellsurface->id);
     cellsurface->device.disposeAndClear();
+    cellsurface->device.~VclPtr<VirtualDevice>();
 
     G_OBJECT_CLASS(custom_cell_renderer_surface_parent_class)->finalize(object);
 }


More information about the Libreoffice-commits mailing list