From cf2db3dde36a25353a5929f154a8bc03dadba289e4dd770ea2c74a7e32ff7f8b Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Sat, 30 Jun 2018 13:43:37 +0000 Subject: [PATCH 1/3] . OBS-URL: https://build.opensuse.org/package/show/editors/emacs?expand=0&rev=255 --- emacs.spec | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/emacs.spec b/emacs.spec index e5c2f26..601f5e6 100644 --- a/emacs.spec +++ b/emacs.spec @@ -64,7 +64,9 @@ BuildRequires: mailutils-devel %endif BuildRequires: makeinfo BuildRequires: ncurses-devel +%if 0%{?suse_version} >= 1500 BuildRequires: system-user-games +%endif BuildRequires: update-alternatives BuildRequires: update-desktop-files BuildRequires: xz @@ -76,7 +78,11 @@ BuildRequires: pkgconfig(gio-2.0) BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(gsettings-desktop-schemas) BuildRequires: pkgconfig(ice) +%if 0%{?suse_version} >= 1500 BuildRequires: pkgconfig(libacl) +%else +BuildRequires: libacl-devel +%endif BuildRequires: pkgconfig(libsystemd) BuildRequires: pkgconfig(pango) BuildRequires: pkgconfig(sm) From a106192f0f8eeff8880cd88b1504a33f999121e45199d447c0ace73b834874d8 Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Sat, 30 Jun 2018 13:46:04 +0000 Subject: [PATCH 2/3] . OBS-URL: https://build.opensuse.org/package/show/editors/emacs?expand=0&rev=256 --- emacs.spec | 2 ++ 1 file changed, 2 insertions(+) diff --git a/emacs.spec b/emacs.spec index 601f5e6..fb0c464 100644 --- a/emacs.spec +++ b/emacs.spec @@ -118,8 +118,10 @@ Requires: etags Requires: mailutils %endif Requires(pre): fileutils +%if 0%{?suse_version} >= 1500 Requires(pre): group(games) Requires(pre): user(games) +%endif Source: ftp://ftp.gnu.org/gnu/emacs/emacs-%{version}.tar.xz Source1: app-defaults.Emacs Source2: site-lisp.tar.bz2 From 4c3bb02022654a22355dd87bfb472e11070186c92154ecdafe48befa9bfd8d0c Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Mon, 9 Jul 2018 06:05:13 +0000 Subject: [PATCH 3/3] Accepting request 621595 from home:AndreasSchwab:f - xwidget.patch: Make xwidget-webkit-execute-script safe against GC - Re-enable Xwidgets on 32bit architectures OBS-URL: https://build.opensuse.org/request/show/621595 OBS-URL: https://build.opensuse.org/package/show/editors/emacs?expand=0&rev=258 --- emacs.changes | 6 ++ emacs.spec | 9 +-- xwidget.patch | 164 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 173 insertions(+), 6 deletions(-) create mode 100644 xwidget.patch diff --git a/emacs.changes b/emacs.changes index 2b03bdb..4e98b26 100644 --- a/emacs.changes +++ b/emacs.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Sun Jul 8 20:14:24 UTC 2018 - schwab@linux-m68k.org + +- xwidget.patch: Make xwidget-webkit-execute-script safe against GC +- Re-enable Xwidgets on 32bit architectures + ------------------------------------------------------------------- Fri Jun 15 05:14:18 UTC 2018 - werner@suse.de diff --git a/emacs.spec b/emacs.spec index fb0c464..efbfc5a 100644 --- a/emacs.spec +++ b/emacs.spec @@ -145,6 +145,7 @@ Patch23: emacs-25.1-custom-fonts.patch # symlink Patch24: emacs-25.2-ImageMagick7.patch Patch25: emacs-26.1-xft4x11.patch +Patch26: xwidget.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build %{expand: %%global include_info %(test -s /usr/share/info/info.info* && echo 0 || echo 1)} @@ -252,6 +253,7 @@ and most assembler-like syntaxes. %patch23 -p0 -b .custfnt %patch24 -p1 -b .imag %patch25 -p0 -b .xft +%patch26 -p1 %patch -p0 -b .0 %build @@ -393,13 +395,8 @@ DESKTOP="--with-x \ %if %{with cairo} --with-cairo \ %endif + --with-xwidgets \ " -if (($(getconf LONG_BIT) >= 62)) -then - # Does not compile on 32bit architecture due failing - # `verify (USE_LSB_TAG)' in src/xwidget.c - GTK="${GTK} --with-xwidgets" -fi X11="${DESKTOP} \ --with-x-toolkit=lucid \ --with-toolkit-scroll-bars \ diff --git a/xwidget.patch b/xwidget.patch new file mode 100644 index 0000000..04a1c84 --- /dev/null +++ b/xwidget.patch @@ -0,0 +1,164 @@ +Index: emacs-26.1/src/xwidget.c +=================================================================== +--- emacs-26.1.orig/src/xwidget.c ++++ emacs-26.1/src/xwidget.c +@@ -362,7 +362,7 @@ webkit_js_to_lisp (JSContextRef context, + static void + webkit_javascript_finished_cb (GObject *webview, + GAsyncResult *result, +- gpointer lisp_callback) ++ gpointer arg) + { + WebKitJavascriptResult *js_result; + JSValueRef value; +@@ -370,6 +370,11 @@ webkit_javascript_finished_cb (GObject + GError *error = NULL; + struct xwidget *xw = g_object_get_data (G_OBJECT (webview), + XG_XWIDGET); ++ ptrdiff_t script_idx = (intptr_t) arg; ++ Lisp_Object script_callback = AREF (xw->script_callbacks, script_idx); ++ ASET (xw->script_callbacks, script_idx, Qnil); ++ if (!NILP (script_callback)) ++ xfree (XSAVE_POINTER (XCAR (script_callback), 0)); + + js_result = webkit_web_view_run_javascript_finish + (WEBKIT_WEB_VIEW (webview), result, &error); +@@ -381,19 +386,19 @@ webkit_javascript_finished_cb (GObject + return; + } + +- context = webkit_javascript_result_get_global_context (js_result); +- value = webkit_javascript_result_get_value (js_result); +- Lisp_Object lisp_value = webkit_js_to_lisp (context, value); +- webkit_javascript_result_unref (js_result); ++ if (!NILP (script_callback) && !NILP (XCDR (script_callback))) ++ { ++ context = webkit_javascript_result_get_global_context (js_result); ++ value = webkit_javascript_result_get_value (js_result); ++ Lisp_Object lisp_value = webkit_js_to_lisp (context, value); ++ ++ /* Register an xwidget event here, which then runs the callback. ++ This ensures that the callback runs in sync with the Emacs ++ event loop. */ ++ store_xwidget_js_callback_event (xw, XCDR (script_callback), lisp_value); ++ } + +- /* Register an xwidget event here, which then runs the callback. +- This ensures that the callback runs in sync with the Emacs +- event loop. */ +- /* FIXME: This might lead to disaster if LISP_CALLBACK's object +- was garbage collected before now. See the FIXME in +- Fxwidget_webkit_execute_script. */ +- store_xwidget_js_callback_event (xw, XIL ((intptr_t) lisp_callback), +- lisp_value); ++ webkit_javascript_result_unref (js_result); + } + + +@@ -687,8 +692,7 @@ DEFUN ("xwidget-webkit-goto-uri", + DEFUN ("xwidget-webkit-zoom", + Fxwidget_webkit_zoom, Sxwidget_webkit_zoom, + 2, 2, 0, +- doc: /* Change the zoom factor of the xwidget webkit instance +-referenced by XWIDGET. */) ++ doc: /* Change the zoom factor of the xwidget webkit instance referenced by XWIDGET. */) + (Lisp_Object xwidget, Lisp_Object factor) + { + WEBKIT_FN_INIT (); +@@ -703,12 +707,33 @@ referenced by XWIDGET. */) + return Qnil; + } + ++/* Save script and fun in the script/callback save vector and return ++ its index. */ ++static ptrdiff_t ++save_script_callback (struct xwidget *xw, Lisp_Object script, Lisp_Object fun) ++{ ++ Lisp_Object cbs = xw->script_callbacks; ++ if (NILP (cbs)) ++ xw->script_callbacks = cbs = Fmake_vector (make_number (32), Qnil); ++ ++ /* Find first free index. */ ++ ptrdiff_t idx; ++ for (idx = 0; !NILP (AREF (cbs, idx)); idx++) ++ if (idx + 1 == ASIZE (cbs)) ++ { ++ xw->script_callbacks = cbs = larger_vector (cbs, 1, -1); ++ break; ++ } ++ ++ ASET (cbs, idx, Fcons (make_save_ptr (xlispstrdup (script)), fun)); ++ return idx; ++} + + DEFUN ("xwidget-webkit-execute-script", + Fxwidget_webkit_execute_script, Sxwidget_webkit_execute_script, + 2, 3, 0, +- doc: /* Make the Webkit XWIDGET execute JavaScript SCRIPT. If +-FUN is provided, feed the JavaScript return value to the single ++ doc: /* Make the Webkit XWIDGET execute JavaScript SCRIPT. ++If FUN is provided, feed the JavaScript return value to the single + argument procedure FUN.*/) + (Lisp_Object xwidget, Lisp_Object script, Lisp_Object fun) + { +@@ -717,23 +742,19 @@ argument procedure FUN.*/) + if (!NILP (fun) && !FUNCTIONP (fun)) + wrong_type_argument (Qinvalid_function, fun); + +- GAsyncReadyCallback callback +- = FUNCTIONP (fun) ? webkit_javascript_finished_cb : NULL; ++ script = ENCODE_SYSTEM (script); + +- /* FIXME: The following hack assumes USE_LSB_TAG. */ +- verify (USE_LSB_TAG); +- /* FIXME: This hack might lead to disaster if FUN is garbage +- collected before store_xwidget_js_callback_event makes it visible +- to Lisp again. See the FIXME in webkit_javascript_finished_cb. */ +- gpointer callback_arg = (gpointer) (intptr_t) XLI (fun); ++ /* Protect script and fun during GC. */ ++ intptr_t idx = save_script_callback (xw, script, fun); + + /* JavaScript execution happens asynchronously. If an elisp + callback function is provided we pass it to the C callback + procedure that retrieves the return value. */ + webkit_web_view_run_javascript (WEBKIT_WEB_VIEW (xw->widget_osr), +- SSDATA (script), ++ XSAVE_POINTER (XCAR (AREF (xw->script_callbacks, idx)), 0), + NULL, /* cancelable */ +- callback, callback_arg); ++ webkit_javascript_finished_cb, ++ (gpointer) idx); + return Qnil; + } + +@@ -1200,6 +1221,16 @@ kill_buffer_xwidgets (Lisp_Object buffer + gtk_widget_destroy (xw->widget_osr); + gtk_widget_destroy (xw->widgetwindow_osr); + } ++ if (!NILP (xw->script_callbacks)) ++ { ++ ptrdiff_t idx; ++ for (idx = 0; idx < ASIZE (xw->script_callbacks); idx++) ++ { ++ if (!NILP (AREF (xw->script_callbacks, idx))) ++ xfree (XSAVE_POINTER (XCAR (AREF (xw->script_callbacks, idx)), 0)); ++ ASET (xw->script_callbacks, idx, Qnil); ++ } ++ } + } + } + } +Index: emacs-26.1/src/xwidget.h +=================================================================== +--- emacs-26.1.orig/src/xwidget.h ++++ emacs-26.1/src/xwidget.h +@@ -47,6 +47,9 @@ struct xwidget + /* A title used for button labels, for instance. */ + Lisp_Object title; + ++ /* Vector of currently executing scripts with callbacks. */ ++ Lisp_Object script_callbacks; ++ + /* Here ends the Lisp part. "height" is the marker field. */ + + int height;