perfbook.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -perfbook] Prevent inkscape from interacting with desktop manager
@ 2023-10-20  9:29 Akira Yokosawa
  2023-10-20 17:37 ` Paul E. McKenney
  0 siblings, 1 reply; 3+ messages in thread
From: Akira Yokosawa @ 2023-10-20  9:29 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: perfbook, Akira Yokosawa

Crashes of command-line Inkscape happens when it exits too soon
before it can be properly removed from window manager's list of
applications it is aware of.
Glib 2.75.3 has removed GSlice allocator [1], which was permissive
about UAF issues.

Question is, "why is the command-line Inkscape registered in
such a list in the first place?"

There is mention of an option named "--without-gui" in Inkscape's
wiki page on "Using the Command Line" [2]:

    The --without-gui option has been removed. Most parameters
    trigger Inkscape to run without GUI by default now. Instead
    enable GUI mode specifically using --with-gui if needed.

However, current Inkscape does *initialize* itself as a GUI
application regardless of the need of GUI.

Alternatively, Inkscape can be forced to run isolated from window/
desktop managers with bogus strings set to a couple of env variables.

After some tries and errors, these two env variables turned out
to be essential here:

    - XDG_RUNTIME_DIR
    - DBUS_SESSION_BUS_ADDRESS

Update Makefile and set bogus strings to them, which sounds a little
rough but should be better than ignoring error codes, after reverting
commits:

    - c2f9a99366b3 ("Ignore error of unstable Inkscape")
    - a01629a5f734 ("Make sure all PDF conversions are complete")

This change resolves crashes of Inkscape observed under Fedora 38,
Fedora 39 beta, Ubuntu 23.04, and openSUSE tumbleweed.

[1]: https://gitlab.gnome.org/GNOME/glib/-/issues/1079
[2]: https://wiki.inkscape.org/wiki/index.php/Using_the_Command_Line

Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
---
 Makefile | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/Makefile b/Makefile
index 3875c52b..424a166c 100644
--- a/Makefile
+++ b/Makefile
@@ -111,7 +111,6 @@ INKSCAPE := $(shell $(WHICH) inkscape 2>/dev/null)
 ifdef INKSCAPE
   INKSCAPE_ONE := $(shell inkscape --version 2>/dev/null | grep -c "Inkscape 1")
 endif
-IGNORE_INKSCAPE_ERROR ?= 1
 LATEXPAND := $(shell $(WHICH) latexpand 2>/dev/null)
 QPDF := $(shell $(WHICH) qpdf 2>/dev/null)
 
@@ -267,10 +266,6 @@ endif
 autodate.tex: $(LATEXSOURCES) $(BIBSOURCES) $(LST_SOURCES) \
     $(PDFTARGETS_OF_EPS) $(PDFTARGETS_OF_SVG) $(FCVSNIPPETS) $(FCVSNIPPETS_VIA_LTMS) \
      $(GITREFSTAGS) utilities/autodate.sh
-ifneq ($(IGNORE_INKSCAPE_ERROR),0)
-	# Make sure all SVG --> PDF conversions are complete
-	$(MAKE) -j1 figs
-endif
 	sh utilities/autodate.sh
 
 perfbook_flat.tex: autodate.tex
@@ -455,6 +450,9 @@ else
   include epstopdf-rule.mk
 endif
 
+# bogus settings for preventing Inkscape from interacting with desktop manager
+ISOLATE_INKSCAPE ?= XDG_RUNTIME_DIR=na DBUS_SESSION_BUS_ADDRESS=na
+
 $(PDFTARGETS_OF_SVG): $(FIXSVGFONTS)
 $(PDFTARGETS_OF_SVG): %.pdf: %.svg
 	@echo "$< --> $(suffix $@)"
@@ -488,11 +486,7 @@ endif
 ifeq ($(INKSCAPE_ONE),0)
 	@inkscape --export-pdf=$@ $<i > /dev/null 2>&1
 else
-  ifneq ($(IGNORE_INKSCAPE_ERROR),0)
-	-@inkscape -o $@ $<i > /dev/null 2>&1
-  else
-	@inkscape -o $@ $<i > /dev/null 2>&1
-  endif
+	@$(ISOLATE_INKSCAPE) inkscape -o $@ $<i > /dev/null 2>&1
 endif
 	@rm -f $<i
 ifeq ($(chkpagegroup),on)

base-commit: 0ecdabe67aae15f616e4a6ffeda8c4f76ff385ae
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH -perfbook] Prevent inkscape from interacting with desktop manager
  2023-10-20  9:29 [PATCH -perfbook] Prevent inkscape from interacting with desktop manager Akira Yokosawa
@ 2023-10-20 17:37 ` Paul E. McKenney
  2023-10-23 14:41   ` Akira Yokosawa
  0 siblings, 1 reply; 3+ messages in thread
From: Paul E. McKenney @ 2023-10-20 17:37 UTC (permalink / raw)
  To: Akira Yokosawa; +Cc: perfbook

On Fri, Oct 20, 2023 at 06:29:32PM +0900, Akira Yokosawa wrote:
> Crashes of command-line Inkscape happens when it exits too soon
> before it can be properly removed from window manager's list of
> applications it is aware of.
> Glib 2.75.3 has removed GSlice allocator [1], which was permissive
> about UAF issues.
> 
> Question is, "why is the command-line Inkscape registered in
> such a list in the first place?"
> 
> There is mention of an option named "--without-gui" in Inkscape's
> wiki page on "Using the Command Line" [2]:
> 
>     The --without-gui option has been removed. Most parameters
>     trigger Inkscape to run without GUI by default now. Instead
>     enable GUI mode specifically using --with-gui if needed.
> 
> However, current Inkscape does *initialize* itself as a GUI
> application regardless of the need of GUI.
> 
> Alternatively, Inkscape can be forced to run isolated from window/
> desktop managers with bogus strings set to a couple of env variables.
> 
> After some tries and errors, these two env variables turned out
> to be essential here:
> 
>     - XDG_RUNTIME_DIR
>     - DBUS_SESSION_BUS_ADDRESS
> 
> Update Makefile and set bogus strings to them, which sounds a little
> rough but should be better than ignoring error codes, after reverting
> commits:
> 
>     - c2f9a99366b3 ("Ignore error of unstable Inkscape")
>     - a01629a5f734 ("Make sure all PDF conversions are complete")
> 
> This change resolves crashes of Inkscape observed under Fedora 38,
> Fedora 39 beta, Ubuntu 23.04, and openSUSE tumbleweed.
> 
> [1]: https://gitlab.gnome.org/GNOME/glib/-/issues/1079
> [2]: https://wiki.inkscape.org/wiki/index.php/Using_the_Command_Line
> 
> Signed-off-by: Akira Yokosawa <akiyks@gmail.com>

This issue is a bit annoying, isn't it?  Thank you for persisting
with it!  I have queued and pushed this patch.

							Thanx, Paul

> ---
>  Makefile | 14 ++++----------
>  1 file changed, 4 insertions(+), 10 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index 3875c52b..424a166c 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -111,7 +111,6 @@ INKSCAPE := $(shell $(WHICH) inkscape 2>/dev/null)
>  ifdef INKSCAPE
>    INKSCAPE_ONE := $(shell inkscape --version 2>/dev/null | grep -c "Inkscape 1")
>  endif
> -IGNORE_INKSCAPE_ERROR ?= 1
>  LATEXPAND := $(shell $(WHICH) latexpand 2>/dev/null)
>  QPDF := $(shell $(WHICH) qpdf 2>/dev/null)
>  
> @@ -267,10 +266,6 @@ endif
>  autodate.tex: $(LATEXSOURCES) $(BIBSOURCES) $(LST_SOURCES) \
>      $(PDFTARGETS_OF_EPS) $(PDFTARGETS_OF_SVG) $(FCVSNIPPETS) $(FCVSNIPPETS_VIA_LTMS) \
>       $(GITREFSTAGS) utilities/autodate.sh
> -ifneq ($(IGNORE_INKSCAPE_ERROR),0)
> -	# Make sure all SVG --> PDF conversions are complete
> -	$(MAKE) -j1 figs
> -endif
>  	sh utilities/autodate.sh
>  
>  perfbook_flat.tex: autodate.tex
> @@ -455,6 +450,9 @@ else
>    include epstopdf-rule.mk
>  endif
>  
> +# bogus settings for preventing Inkscape from interacting with desktop manager
> +ISOLATE_INKSCAPE ?= XDG_RUNTIME_DIR=na DBUS_SESSION_BUS_ADDRESS=na
> +
>  $(PDFTARGETS_OF_SVG): $(FIXSVGFONTS)
>  $(PDFTARGETS_OF_SVG): %.pdf: %.svg
>  	@echo "$< --> $(suffix $@)"
> @@ -488,11 +486,7 @@ endif
>  ifeq ($(INKSCAPE_ONE),0)
>  	@inkscape --export-pdf=$@ $<i > /dev/null 2>&1
>  else
> -  ifneq ($(IGNORE_INKSCAPE_ERROR),0)
> -	-@inkscape -o $@ $<i > /dev/null 2>&1
> -  else
> -	@inkscape -o $@ $<i > /dev/null 2>&1
> -  endif
> +	@$(ISOLATE_INKSCAPE) inkscape -o $@ $<i > /dev/null 2>&1
>  endif
>  	@rm -f $<i
>  ifeq ($(chkpagegroup),on)
> 
> base-commit: 0ecdabe67aae15f616e4a6ffeda8c4f76ff385ae
> -- 
> 2.34.1
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH -perfbook] Prevent inkscape from interacting with desktop manager
  2023-10-20 17:37 ` Paul E. McKenney
@ 2023-10-23 14:41   ` Akira Yokosawa
  0 siblings, 0 replies; 3+ messages in thread
From: Akira Yokosawa @ 2023-10-23 14:41 UTC (permalink / raw)
  To: paulmck; +Cc: perfbook, Akira Yokosawa

On 2023/10/21 2:37, Paul E. McKenney wrote:
> On Fri, Oct 20, 2023 at 06:29:32PM +0900, Akira Yokosawa wrote:
>> Crashes of command-line Inkscape happens when it exits too soon
>> before it can be properly removed from window manager's list of
>> applications it is aware of.
>> Glib 2.75.3 has removed GSlice allocator [1], which was permissive
>> about UAF issues.
>>
>> Question is, "why is the command-line Inkscape registered in
>> such a list in the first place?"
>>
>> There is mention of an option named "--without-gui" in Inkscape's
>> wiki page on "Using the Command Line" [2]:
>>
>>     The --without-gui option has been removed. Most parameters
>>     trigger Inkscape to run without GUI by default now. Instead
>>     enable GUI mode specifically using --with-gui if needed.
>>
>> However, current Inkscape does *initialize* itself as a GUI
>> application regardless of the need of GUI.
>>
>> Alternatively, Inkscape can be forced to run isolated from window/
>> desktop managers with bogus strings set to a couple of env variables.
>>
>> After some tries and errors, these two env variables turned out
>> to be essential here:
>>
>>     - XDG_RUNTIME_DIR
>>     - DBUS_SESSION_BUS_ADDRESS
>>
>> Update Makefile and set bogus strings to them, which sounds a little
>> rough but should be better than ignoring error codes, after reverting
>> commits:
>>
>>     - c2f9a99366b3 ("Ignore error of unstable Inkscape")
>>     - a01629a5f734 ("Make sure all PDF conversions are complete")
>>
>> This change resolves crashes of Inkscape observed under Fedora 38,
>> Fedora 39 beta, Ubuntu 23.04, and openSUSE tumbleweed.
>>
>> [1]: https://gitlab.gnome.org/GNOME/glib/-/issues/1079
>> [2]: https://wiki.inkscape.org/wiki/index.php/Using_the_Command_Line
>>
>> Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
> 
> This issue is a bit annoying, isn't it?

Yea.

And it looks like debian's GNOME maintainers are eager enough and have
backported upstream GTK+3's fix mentioned in Inkscape's issue #4117 [3]
into its libgtk-3-0-3.24.38-5 [4].

In the fixes listed in [4], you see:

     - d/p/GtkApplicationImplDBus-Cancel-DBus-method-calls-on-shutdo.patch
       Fix a use-after-free crash during application quit, particularly
       affecting Inkscape command-line export with GLib >= 2.76, by
       cancelling processing of pending D-Bus calls (Closes: #1051220)

Ubuntu 23.10's libgtk-3-0-3.24.38-5ubuntu1 also has the fix.

This explains why debian testing and Ubuntu 23.10 is free of this
crashing issue.

Other affected distro users need to wait some more, I guess ...

[3]: https://gitlab.com/inkscape/inkscape/-/issues/4177#note_1464888693
[4]: https://tracker.debian.org/news/1461984/accepted-gtk30-32438-5-source-into-unstable/

        Thanks, Akira

[...]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-10-23 14:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-20  9:29 [PATCH -perfbook] Prevent inkscape from interacting with desktop manager Akira Yokosawa
2023-10-20 17:37 ` Paul E. McKenney
2023-10-23 14:41   ` Akira Yokosawa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).