[Xfce4-commits] <midori:master> midori_view_set_uri: Work-around about:version crash

Christian Dywan noreply at xfce.org
Sun May 13 23:44:01 CEST 2012


Updating branch refs/heads/master
         to f5dd1f9ab512399f2f9ca316807c4380320a96f6 (commit)
       from 109ed3cd9254e95b4d4233b9c8d5eaeab0020455 (commit)

commit f5dd1f9ab512399f2f9ca316807c4380320a96f6
Author: Alexander Strasser <eclipse7 at gmx.net>
Date:   Sun May 13 23:13:37 2012 +0200

    midori_view_set_uri: Work-around about:version crash
    
      On some systems (e.g. x86_64 linux) midori crashes when
    trying to visit "about:version".
    
      The crash happens in some printf function deeper in the
    call stack. But I have a theory that much stack space is
    occupied already before calling g_strdup_printf. I have
    not analyzed the situation more closely.
    
      This fixes the crash by splitting the generation of the
    version information page into multiple calls. If my theory
    is correct, it should now only work because I reduced peak
    stack usage.

 midori/midori-view.c |   78 +++++++++++++++++++++++++++++++------------------
 1 files changed, 49 insertions(+), 29 deletions(-)

diff --git a/midori/midori-view.c b/midori/midori-view.c
index aa49de7..934b68b 100644
--- a/midori/midori-view.c
+++ b/midori/midori-view.c
@@ -4315,12 +4315,47 @@ midori_view_set_uri (MidoriView*  view,
                 WebKitWebFrame* web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view->web_view));
                 JSContextRef js_context = webkit_web_frame_get_global_context (web_frame);
                 gchar* video_formats = list_video_formats (js_context);
+
+                /* FIXME: This is for workarounding a crash deeper down the callstack on some systems. */
+                static char const * const version_format_strings[] = {
+                    "<tr><td>libsoup</td><td>%s</td></tr>",
+                    "<tr><td>cairo</td><td>%s ",
+                    "(%s)</td></tr>",
+                    "<tr><td>granite</td><td>%s</td></tr>",
+                    "<tr><td>libnotify</td><td>%s</td></tr>",
+                    "<tr><td>single instance</td><td>%s</td></tr>",
+                    "<tr><td>Platform</td><td>%s ",
+                    "%s ",
+                    "%s</td></tr>",
+                    "<tr><td>Identification</td><td>%s</td></tr>",
+                    "<tr><td>Video Formats</td><td>%s</td></tr>",
+                };
+                char const *  version_strings[] = {
+                    LIBSOUP_VERSION,
+                    CAIRO_VERSION_STRING, cairo_version_string (),
+                    GRANITE_VERSION,
+                    LIBNOTIFY_VERSION,
+                    #ifdef HAVE_HILDON_2_2
+                    "Hildon 2.2",
+                    #elif HAVE_HILDON
+                    "Hildon",
+                    #elif HAVE_UNIQUE
+                    "libunique " UNIQUE_VERSION,
+                    #else
+                    "Sockets",
+                    #endif
+                    platform, sys_name, architecture ? architecture : "", ident,
+                    video_formats,
+                };
+                int i = 0;
+                GString * tmp = g_string_new("");;
+
                 GString* more = g_string_new ("");
                 list_netscape_plugins (more, js_context);
                 list_about_uris (more);
 
                 katze_assign (view->uri, g_strdup (uri));
-                data = g_strdup_printf (
+                g_string_append_printf (tmp,
                     "<html><head><title>about:version</title></head>"
                     "<body><h1>about:version</h1>"
                     "<p>%s</p>"
@@ -4331,18 +4366,7 @@ midori_view_set_uri (MidoriView*  view,
                     "<tr><td>Midori</td><td>%s (%s)</td></tr>"
                     "<tr><td>WebKitGTK+</td><td>%d.%d.%d (%d.%d.%d)</td></tr>"
                     "<tr><td>GTK+</td><td>%d.%d.%d (%d.%d.%d)</td></tr>"
-                    "<tr><td>Glib</td><td>%d.%d.%d (%d.%d.%d)</td></tr>"
-                    "<tr><td>libsoup</td><td>%s</td></tr>"
-                    "<tr><td>cairo</td><td>%s (%s)</td></tr>"
-                    "<tr><td>granite</td><td>%s</td></tr>"
-                    "<tr><td>libnotify</td><td>%s</td></tr>"
-                    "<tr><td>single instance</td><td>%s</td></tr>"
-                    "<tr><td>Platform</td><td>%s %s %s</td></tr>"
-                    "<tr><td>Identification</td><td>%s</td></tr>"
-                    "<tr><td>Video Formats</td><td>%s</td></tr>"
-                    "</table>"
-                    "%s"
-                    "</body></html>",
+                    "<tr><td>Glib</td><td>%d.%d.%d (%d.%d.%d)</td></tr>",
                     _("Version numbers in brackets show the version used at runtime."),
                     command_line,
                     PACKAGE_VERSION, midori_app_get_name (NULL),
@@ -4353,22 +4377,18 @@ midori_view_set_uri (MidoriView*  view,
                     GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION,
                     gtk_major_version, gtk_minor_version, gtk_micro_version,
                     GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION,
-                    glib_major_version, glib_minor_version, glib_micro_version,
-                    LIBSOUP_VERSION,
-                    CAIRO_VERSION_STRING, cairo_version_string (),
-                    GRANITE_VERSION,
-                    LIBNOTIFY_VERSION,
-                    #ifdef HAVE_HILDON_2_2
-                    "Hildon 2.2",
-                    #elif HAVE_HILDON
-                    "Hildon",
-                    #elif HAVE_UNIQUE
-                    "libunique " UNIQUE_VERSION,
-                    #else
-                    "Sockets",
-                    #endif
-                    platform, sys_name, architecture ? architecture : "", ident,
-                    video_formats, (gchar*)(more->str));
+                    glib_major_version, glib_minor_version, glib_micro_version);
+
+                for (i = 0;
+                     i < sizeof (version_format_strings) / sizeof (version_format_strings[0]);
+                     ++i)
+                    g_string_append_printf (tmp, version_format_strings[i], version_strings[i]);
+
+                g_string_append_printf (
+                    tmp, "</table>%s</body></html>", (gchar*)(more->str));
+
+                data = g_string_free (tmp, FALSE);
+
                 g_free (command_line);
                 g_free (arguments);
                 g_free (ident);


More information about the Xfce4-commits mailing list