Launching a second instance of Shutter if one instance is already open causes a crash

Bug #731874 reported by Michael Kogan
74
This bug affects 14 people
Affects Status Importance Assigned to Milestone
Shutter
Fix Released
Medium
Mario Kemper (Romario)

Bug Description

When Shutter is already open the use of Print or Alt+Print crashes it with following output:

Speicherzugriffsfehler

If using the shortcuts when Shutter isn't open everything works fine.

Rev. 1064 on Arch Linux

Full output attached.

Revision history for this message
Michael Kogan (michael-kogan) wrote :
description: updated
Revision history for this message
Mario Kemper (Romario) (mario-kemper) wrote :

This does not happen when running Ubuntu, but I have seen those crashes during development. Could you please try different capture modes and check if Shutter crashes in all cases? See 'man shutter' for all available capture modes.

Revision history for this message
Michael Kogan (michael-kogan) wrote : Re: Using PrintScreen when Shutter is already open causes a crash

Seems to appear with all modes (selecting different modes in Preferences>Keyboard and then trying Alt+Print).

summary: - Using PrintScreen when Shuter is already open causes a crash
+ Using PrintScreen when Shutter is already open causes a crash
Revision history for this message
Michael Kogan (michael-kogan) wrote :

Using libunique 1.1.6 and perl-gtk2-unique 0.05.

Changed in shutter:
assignee: nobody → Mario Kemper (Romario) (mario-kemper)
importance: Undecided → Low
milestone: none → 0.88.x
status: New → Confirmed
Revision history for this message
Michael Kogan (michael-kogan) wrote :

I thought, you might be interested in the output of the new instance launched with another instance being open, the relevant lines are

WARNING **: Error while sending message: GDBus.Error:org.freedesktop.DBus.Error.NoReply: Message did not receive a reply (timeout by message bus) at /usr/bin/shutter line 320, <DATA> line 19.

INFO: There is already another instance of Shutter running!

Also, the problem is not related to the PrintScreen shortcut, it appears also when both instances are launched from the terminal via "/usr/bin/shutter --full".

summary: - Using PrintScreen when Shutter is already open causes a crash
+ Launching a second instance of Shutter if one instance is already open
+ causes a crash
tags: added: instances
removed: shortkeys
Revision history for this message
bericp1 (bericp1) wrote :

Affects me too on Arch, all packages related to shutter up to date. Any other way to bind shortcut keys without running the shutter command again?

Changed in shutter:
milestone: upload → capture
Revision history for this message
patryk (pbratkowski) wrote :

Also have that problem running aur/shutter 0.90.1-1 and aur/shutter-bzr 1253-2

Using the bzr revision, if I change line 333 from
$app->send_message( $cmdid, text => '' );
to
$app->send_message( $cmdid, text => 'a' );

it no longer crashes when running shutter --full in another window. It appears that $message->get_text causes the segfault when text is set to an empty string.

It still crashes when using shutter --window, because on line 330, $extra is defined, but set to ''.

Sorry, I won't debug the whole thing but this should get you started in the right direction.

Revision history for this message
Sparhawk (sparhawkthesecond) wrote :

I see this bug too, but I just wanted to mention that if I start the first Shutter instance up in a terminal, it tells me that there was a "Segmentation fault (core dumped)". I'm not really sure where to find this dump though. I'm happy to debug more if you can tell me where to look.

Revision history for this message
Sparhawk (sparhawkthesecond) wrote :

Shutter has been accepted into the official Arch repos, and I've created a bug report on the Arch tracker. Please add any useful information and vote there.
https://bugs.archlinux.org/task/41357

Changed in shutter:
importance: Low → Medium
milestone: capture → 0.92
status: Confirmed → Fix Committed
Changed in shutter:
status: Fix Committed → Fix Released
Revision history for this message
Sparhawk (sparhawkthesecond) wrote :

I can confirm that this bug is fixed in Arch Linux. Thanks for sorting that out. Cheers.

Revision history for this message
Sparhawk (sparhawkthesecond) wrote :

Correction: this is fixed for new instances launched with `shutter --full`, but shutter still crashes if the new instance is launched with `shutter --select` or `shutter --window`. (This has been confirmed here: https://bugs.archlinux.org/task/41357#comment126225 )

Revision history for this message
Michael Kogan (michael-kogan) wrote :

I can also confirm the fix to be only partial. Also, running Shutter without any options leads to a crash.

Changed in shutter:
status: Fix Released → In Progress
Changed in shutter:
milestone: 0.92 → misc
Revision history for this message
Aleksej (aleksejrs) wrote :

Started happening to me recently (days to months) on Debian testing with Shutter 0.93.1 Rev.1278. No switches, --select, --section, or --full.

Revision history for this message
Wojciech Skorodecki (wskorodecki) wrote :

I don't know Perl nor GTK2 but I have fixed it for myself. The problem is that for some reason GTK2 is unable to parse received message containing an empty string which leads to segmentation fault. The ugly but working solution is to send a message with some unique text which should be replaced again to empty string after the message has been received, to simulate the same behaviour.

Revision history for this message
Sparhawk (sparhawkthesecond) wrote :

Thank you Wojciech! I can confirm that this patch fixes the bug on my system. I tested both `shutter --select` and `shutter --window`, and shutter no longer segfaults. Thanks for the fix!

Revision history for this message
Michael Kogan (michael-kogan) wrote :

Ii also confirm the fix and included it into Arch's Shutter package.

Revision history for this message
Pastafarianist (pastafarianist) wrote :

@michael-kogan you may also want to check out this:

https://github.com/Pastafarianist/shutter/commit/380c313840dd223e5b6c35720a79c338780f42d6

This is also a fix for the same issue, but a cleaner one, IMO.

Revision history for this message
Michael Kogan (michael-kogan) wrote :

Cool, I will have a look asap! In the mean time: I was thinking of creating a fork implementing all the patches currently available here on Launchpad. The only problem is that I don't even know Perl, so I wouldn't be able to review them. Maybe you are interested in applying the patches in your forked repo? I collected most of them in Shutter's AUR package: https://aur.archlinux.org/packages/shutter/

Revision history for this message
Michael Kogan (michael-kogan) wrote :

Tested it now (and included into the package), it works flawlessly, now there are no crashes even if you launch the second instance without any options. Thanks for the patch!

Revision history for this message
Michael Kogan (michael-kogan) wrote :

Applied patch fixing this in rev.1284.

Changed in shutter:
status: In Progress → Fix Committed
Changed in shutter:
milestone: misc → 0.94
Changed in shutter:
status: Fix Committed → Fix Released
Revision history for this message
chapeaurouge (fred-blaise) wrote :

It looks like this is the issue I am running into (on opensuse), yet I am running 0.94 r1290. Reading all the above, I'd have assumed the fix was made upstream? Thanks.

```
shutter -s
WARNING: gnome-web-photo is missing --> screenshots of websites will be disabled!

(shutter:14314): Unique-DBus-WARNING **: Error while sending message: Message recipient disconnected from message bus without replying

INFO: There is already another instance of Shutter running!
```
[and it crashes the 1st instance]

Revision history for this message
Michael Kogan (michael-kogan) wrote :

Yep, it is borked again, but reverting the patch which initially fixed it doesn't help either. Seems like a new problem with old symptoms.

Revision history for this message
Neil Hanlon (hanlon-neil) wrote :

Seeing this still with `0.93.1 Rev.1278` on debian stable (stretch)

Revision history for this message
jnko (joern-koerner) wrote :

I did a little bit debugging in the last 15 minutes and found the cause of this crash.
(Shutter 0.94, Rev 1290 running on Archlinux)

Shutter crashes when starting a second instance at line 345

 $app->send_message( 11, uris => \@escaped_filenames );

Simply comment this and it won't crash anymore. I didn't dive into the code yet but reading shutter command line help and that part of the code I just don't see what 'uris' should be passed to shutter at this point. But this is surely related to me since I'm not a perl monk at all.

        #escape all filenames, see Bug #737428
        my @escaped_filenames;
        foreach my $file (@init_files) {
            push @escaped_filenames, Gnome2::VFS->escape_string($file);
        }
        #$app->send_message( 11, uris => \@escaped_filenames );
    }

    print "\nINFO: There is already another instance of Shutter running!\n";

    #Create the single application instance and wait for other requests

Revision history for this message
jnko (joern-koerner) wrote :

Well the above "patch" was too early, sorry.
Shutter crashes every time $app->send_message() is being called and it will be called with different $cmdid for each argument passed to it.

Also I checked this against a Debian install and surprise: No problems at all.

Seems like the root cause is somewhere else. Anyway I'll try to investigate further

Revision history for this message
Michael Kogan (michael-kogan) wrote :

Could it be due to an older Perl version in Debian?

Changed in shutter:
status: Fix Released → Confirmed
Revision history for this message
Michael Kogan (michael-kogan) wrote :

A user in the AUR reported that he investigated this issue further and suspects the source of error to be in the C code somewhere in the libraries used by Shutter, most probably in libunique or perl-gtk2-unique. See here for the original comment: https://aur.archlinux.org/packages/shutter/?comments=all

Revision history for this message
Michael Kogan (michael-kogan) wrote :

I found a patch for perl-gtk2-unique which fixes the issue for me (on Arch Linux): https://anonscm.debian.org/cgit/pkg-perl/packages/libgtk2-unique-perl.git/tree/debian/patches/fix_segfault_2nd_instance

The patch is included in the libgtk2-unique-perl-0.05-3: http://changelogs.ubuntu.com/changelogs/pool/universe/libg/libgtk2-unique-perl/libgtk2-unique-perl_0.05-3/changelog

Could please somebody confirm that libgtk2-unique-perl-0.05-3 fixes the Shutter crash in Ubuntu?

Revision history for this message
Michael Kogan (michael-kogan) wrote :

Reported a bug asking to backport -3 to Ubuntu 16.04: https://bugs.launchpad.net/ubuntu/+source/libgtk2-unique-perl/+bug/1748891

Changed in shutter:
status: Confirmed → In Progress
Revision history for this message
Eli Sodeglo (elisdg) wrote :

@Photon, thank you!!! the mentioned additional line in libgtk2-unique (#28) is working on debian9.3

Revision history for this message
HolyK (sitezreg) wrote :
Download full text (3.6 KiB)

Confirming the same issue on Fedora 27 with shutter 0.93.1

// First instance starts - OK

// Second start throws this
WARNING: gnome-web-photo is missing --> screenshots of websites will be disabled!

(shutter:5439): Unique-DBus-WARNING **: Error while sending message: Message recipient disconnected from message bus without replying

INFO: There is already another instance of Shutter running!

// And the first one crashes as well with this:
Segmentation fault (core dumped)

// Debug of the first one
(gdb) run /usr/bin/shutter
Starting program: /usr/bin/perl /usr/bin/shutter
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
WARNING: gnome-web-photo is missing --> screenshots of websites will be disabled!

GdkPixbuf-LOG **: gdk_pixbuf_from_pixdata() called on: at /usr/bin/shutter line 520, <DATA> line 19.
GdkPixbuf-LOG **: Encoding raw at /usr/bin/shutter line 520, <DATA> line 19.
GdkPixbuf-LOG **: Dimensions: 16 x 16 at /usr/bin/shutter line 520, <DATA> line 19.
GdkPixbuf-LOG **: Rowstride: 64, Length: 1048 at /usr/bin/shutter line 520, <DATA> line 19.
GdkPixbuf-LOG **: Copy pixels == false at /usr/bin/shutter line 520, <DATA> line 19.
GdkPixbuf-LOG **: gdk_pixbuf_from_pixdata() called on: at /usr/bin/shutter line 520, <DATA> line 19.
GdkPixbuf-LOG **: Encoding raw at /usr/bin/shutter line 520, <DATA> line 19.
GdkPixbuf-LOG **: Dimensions: 16 x 16 at /usr/bin/shutter line 520, <DATA> line 19.
GdkPixbuf-LOG **: Rowstride: 64, Length: 1048 at /usr/bin/shutter line 520, <DATA> line 19.
GdkPixbuf-LOG **: Copy pixels == false at /usr/bin/shutter line 520, <DATA> line 19.
[New Thread 0x7fffdc9a5700 (LWP 6348)]
[New Thread 0x7fffd7fff700 (LWP 6349)]
[New Thread 0x7fffd77fe700 (LWP 6350)]
File::Glob::glob() will disappear in perl 5.30. Use File::Glob::bsd_glob() instead. at /usr/bin/shutter line 8199.
[New Thread 0x7fffd6b76700 (LWP 6351)]
[New Thread 0x7fffd5b50700 (LWP 6352)]
GdkPixbuf-LOG **: gdk_pixbuf_from_pixdata() called on: at /usr/bin/shutter line 4505.
GdkPixbuf-LOG **: Encoding raw at /usr/bin/shutter line 4505.
GdkPixbuf-LOG **: Dimensions: 14 x 14 at /usr/bin/shutter line 4505.
GdkPixbuf-LOG **: Rowstride: 56, Length: 808 at /usr/bin/shutter line 4505.
GdkPixbuf-LOG **: Copy pixels == false at /usr/bin/shutter line 4505.
GdkPixbuf-LOG **: gdk_pixbuf_from_pixdata() called on: at /usr/bin/shutter line 4505.
GdkPixbuf-LOG **: Encoding raw at /usr/bin/shutter line 4505.
GdkPixbuf-LOG **: Dimensions: 14 x 14 at /usr/bin/shutter line 4505.
GdkPixbuf-LOG **: Rowstride: 56, Length: 808 at /usr/bin/shutter line 4505.
GdkPixbuf-LOG **: Copy pixels == false at /usr/bin/shutter line 4505.
[Thread 0x7fffd77fe700 (LWP 6350) exited]
[Thread 0x7fffd5b50700 (LWP 6352) exited]
[Thread 0x7fffd6b76700 (LWP 6351) exited]

Thread 1 "perl" received signal SIGSEGV, Segmentation fault.
0x00007ffff6788d71 in __strlen_avx2 () from /lib64/libc.so.6

// Debug of the second one:
(gdb) run /usr/bin/shutter
Starting program: /usr/bin/perl /usr/bin/shutter
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
WARNING: gnome-web-photo is missing -...

Read more...

Revision history for this message
Michael Kogan (michael-kogan) wrote :

Please ask the maintainers of Feodra's perl-Gtk2-Unique package to include the follwing patch: https://anonscm.debian.org/cgit/pkg-perl/packages/libgtk2-unique-perl.git/tree/debian/patches/fix_segfault_2nd_instance

Revision history for this message
Michael Kogan (michael-kogan) wrote :

It looks like the perl-gtk2-unique bug has been patched in Debian, Arch, will be fixed in the upcoming Ubuntu 18.04 and a report for Fedora 27 also exists. Therefore I think that the time has come to solemnly close it. Please open a new bug in case you are running a patched perl-gtk2-unique and still experience second instance crashes in Shutter.

Changed in shutter:
status: In Progress → Fix Released
Revision history for this message
MagicVince (vincent-mabillot) wrote :

In debian strech (stable) the bug is always here, maybe the perl-gtk2-unique wasn't upgrade or backport (making an appimage could be an alternative solution?)

Revision history for this message
Michael Kogan (michael-kogan) wrote :

Yes, stretch doesn't have the fixed version 0.05-3, it still ships version 0.05-2. Please report this bug in the Debian bug tracker and request to backport 0.05-3 to stretch.

Revision history for this message
Manuel Razzari (manael) wrote :

In case it helps someone else, here's "workaround" steps to install the patched library from source.
This fixed the bug for me in Ubuntu 16.04.

apt install libunique-dev
wget https://github.com/GNOME/perl-Gtk2-Unique/archive/master.zip
unzip master.zip
cd perl-Gtk2-Unique-master
perl Makefile.PL
make
make test
make install

Revision history for this message
Adam Bolte (boltronics) wrote :

Or better yet, from a temporary directory:

sudo apt-get install git-buildpackage
sudo apt-get build-dep libgtk2-unique-perl
git clone https://salsa.debian.org/perl-team/modules/attic/libgtk2-unique-perl.git
cd libgtk2-unique-perl
gbp buildpackage
dpkg -i ../libgtk2-unique-perl_*.deb

This keeps your system clean from unpackaged system files.

It's also worth noting that the link to the fix_segfault_2nd_instance patch in the previous comments is broken but appears to have been moved here: https://salsa.debian.org/perl-team/modules/attic/libgtk2-unique-perl/blob/master/debian/patches/fix_segfault_2nd_instance

Revision history for this message
Roberto Villegas (ville1ero) wrote :

Thanks for this fix!!!
https://bugs.launchpad.net/shutter/+bug/731874/comments/14

It works for me even on:
shutter 0.94.3 Rev.1306
Fedora release 31 (Thirty One)
Sun 17 May 2020 02:22:58 PM CDT

vim /bin/shutter
  326 #send $cmdid
  327 if ( defined $cmdid && defined $extra ) {
  328 if (!$extra) {
  329 ###Quick fix to avoid segmentation fault in some environments.
  330 $extra = "text=>null";
  331 }
  332 $app->send_message( $cmdid, text => $extra );
  333 }
...
  495 else {###
  496 #my $arg = defined $message->get ? $message->get_text : "";
  497 #&evt_take_screenshot( 'global_keybinding', $cmd, undef, $arg );
  498 my $extra = $message->get_text;
  499 if ( $extra eq "text=>null" ) {
  500 $extra = '';
  501 }
  502 &evt_take_screenshot( 'global_keybinding', $cmd, undef, $extra );
  503 }
  504 }

Revision history for this message
Michael Kogan (michael-kogan) wrote :

This should be fixed in Fedora with perl-gtk2-unique 0.05-23 and above (current version in Fedora 31 is 0.05-26), see changelog in https://fedora.pkgs.org/30/fedora-armhfp/perl-Gtk2-Unique-0.05-26.fc30.armv7hl.rpm.html

Did you still see this issue without the workaround you cited?

Revision history for this message
Rodrigo Araujo (araujorm) wrote :

@michael-kogan: confirmed just now that it's not fixed in Fedora 32, still crashes with shutter-0.94.3-2.fc32.noarch and perl-Gtk2-Unique-0.05-29.fc32.x86_64; should one open a bug report in Fedora Bugzilla?

Revision history for this message
Michael Kogan (michael-kogan) wrote :

You can try, but most likely people will say that it's an upstream issue. :) Is there any error output during the crash?

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.