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

Bug #731874 reported by Photon on 2011-03-09
66
This bug affects 13 people
Affects Status Importance Assigned to Milestone
Shutter
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.

Photon (michael-kogan) wrote :
description: updated

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.

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
Photon (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
Photon (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
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
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.

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.

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
Sparhawk (sparhawkthesecond) wrote :

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

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 )

Photon (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
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.

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.

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!

Photon (michael-kogan) wrote :

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

@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.

Photon (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/

Photon (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!

Photon (michael-kogan) wrote :

Applied patch fixing this in rev.1284.

Changed in shutter:
status: In Progress → Fix Committed
Photon (michael-kogan) on 2017-08-14
Changed in shutter:
milestone: misc → 0.94
Photon (michael-kogan) on 2017-08-16
Changed in shutter:
status: Fix Committed → Fix Released
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]

Photon (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.

Neil Hanlon (hanlon-neil) wrote :

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

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

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

Photon (michael-kogan) wrote :

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

Changed in shutter:
status: Fix Released → Confirmed
Photon (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

Photon (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?

Photon (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
Eli Sodeglo (elisdg) wrote :

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

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...

Photon (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

Photon (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
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers