Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SVG in notifications results in a double free or corruption #512

Closed
lightdiscord opened this issue Apr 30, 2018 · 22 comments
Closed

SVG in notifications results in a double free or corruption #512

lightdiscord opened this issue Apr 30, 2018 · 22 comments
Labels

Comments

@lightdiscord
Copy link

When I display a notification with a PNG it works but when it is a SVG no notification is displayed.
In journalctl I have an error:

Apr 30 13:52:22 nixos org.freedesktop.Notifications[1132]: double free or corruption (out)

While the notification gets sent:

signal time=1525089139.442770 sender=org.freedesktop.DBus -> destination=:1.789 serial=2 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameAcquired
   string ":1.789"
signal time=1525089139.442782 sender=org.freedesktop.DBus -> destination=:1.789 serial=4 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameLost
   string ":1.789"
method call time=1525089140.924184 sender=:1.790 -> destination=:1.788 serial=6 path=/org/freedesktop/Notifications; interface=org.freedesktop.Notifications; member=GetServerInformation
method call time=1525089140.924710 sender=:1.790 -> destination=:1.788 serial=7 path=/org/freedesktop/Notifications; interface=org.freedesktop.Notifications; member=Notify
   string "notify-send"
   uint32 0
   string "/home/arnaud/Documents/papirus-icons/Papirus/64x64/apps/spotify-client.png"
   string "Hello world!"
   string "this is"
   array [
   ]
   array [
      dict entry(
         string "urgency"
         variant             byte 1
      )
   ]
   int32 -1
method call time=1525089142.006995 sender=:1.791 -> destination=:1.788 serial=6 path=/org/freedesktop/Notifications; interface=org.freedesktop.Notifications; member=GetServerInformation
method call time=1525089142.007305 sender=:1.791 -> destination=:1.788 serial=7 path=/org/freedesktop/Notifications; interface=org.freedesktop.Notifications; member=Notify
   string "notify-send"
   uint32 0
   string "/home/arnaud/Documents/papirus-icons/spotify-client.svg"
   string "Hello world!"
   string "this is"
   array [
   ]
   array [
      dict entry(
         string "urgency"
         variant             byte 1
      )
   ]
   int32 -1

Installation info

  • Version: 1.3.1
  • Install type: NixOS dunst derivation
  • Distro and version: NixOS (18.09pre137749.b5fd3a0bc70 (Jellyfish))
@bebehei
Copy link
Member

bebehei commented Apr 30, 2018

Just recently, I introduced unit tests in the icon loading methods and found the corresponding bug. In parallel somewhere in the gdk libraries the svg loading broke (?!) or it maybe got more strict. Therefore, gdk fails and dunst crashes.

As the fix is already in #496, I don't consider branching creating a special hotfix.

@bebehei bebehei added the Bug label Apr 30, 2018
@bebehei
Copy link
Member

bebehei commented Apr 30, 2018

As the fix is already in #496, I don't consider branching creating a special hotfix.

Oh wait. Stupid thinking of myself. 🙈

@tsipinakis We actually should create a hotfix and release 1.3.2 to make it available in downstream distros.

@bebehei
Copy link
Member

bebehei commented Apr 30, 2018

string "/home/arnaud/Documents/papirus-icons/spotify-client.svg"

@lightdiscord Out of curiosity, could you please provide this file?

@lightdiscord
Copy link
Author

lightdiscord commented Apr 30, 2018

@lightdiscord Out of curiosity, could you please provide this file?

@bebehei You can find here my local version and here the common one.

@tsipinakis
Copy link
Member

I cannot seem to reproduce this with the provided icon. @lightdiscord What version of gdk_pixbuf are you using?

@lightdiscord
Copy link
Author

According to this file, i'm using gdk_pixbuf at version 2.36.7

@bebehei
Copy link
Member

bebehei commented May 2, 2018

@tsipinakis A week ago, someone showed up in IRC and asked about a corruption error. The backtrace indicated clearly, that it was the mentioned g_free (instead of g_error_free). I assume, that something somewhere in the GDK libs broke and parses the SVGs more strict and/or fails. And I expect this error here to be the same one as the one in the IRC.

You could search around the changelog on the Gnome FTP Mirror for the corresponding bugreport. But actually, I think this is wasted energy. You could trace it back, but no matter if it's actually a problem of gdk pixbuf, dunst doesn't behave right either.

I think we should fix dunst first.

For completeness: With the given file, I can't reproduce it either. But as I said, I'm expecting the bug in the libraries (gdk-pixbuf2 2.36.12). The most effective job to find the actual issue would be bisecting the libs. But that's too much effort.


@lightdiscord Could you please compile the refactor-drawing branch manually and run it on your system and trigger the bad notification?

git clone https://github.com/dunst-project/dunst.git
cd dunst
git checkout refactor-drawing
make
killall dunst
./dunst -print
# -> trigger the notification

@tsipinakis
Copy link
Member

I think we should fix dunst first.

The fix is already in refactor-drawing and will land in master (hopefully soon) I'm still thinking it over if it's worth doing another patch release for this one.

In any case, I also expect this to be a bug somewhere in gdk but it's worth looking into IMO (at least finding out the error message it gives out when it fails)

@bebehei
Copy link
Member

bebehei commented May 2, 2018

Yes, I also think we should do a patch release. Getting a meaningful error message afterwards and then fixing it upstream is also in my mind.

@lightdiscord
Copy link
Author

lightdiscord commented May 2, 2018

With the refactor-drawing branch dunst doesn't crash with a svg icon, but the icon isn't displayed.

2018-05-02_20 45 47

@tsipinakis
Copy link
Member

Check the logs, there should be an error message on why it failed to load.

@lightdiscord
Copy link
Author

lightdiscord commented May 2, 2018

Check the logs

I can't find them

@tsipinakis
Copy link
Member

tsipinakis commented May 2, 2018

I can't find them

Huh, try the following

git pull --force (make sure you have the latest commits I pushed earlier)

make clean
make debug (enable all debug output)
strace ./dunst > log 2>&1  (run under strace to see what's going on under the hood and put everything in log)
#send notifications through

And post the log this should hopefully give enough information to figure this out.

Edit: Relevant code bit is here

dunst/src/icon.c

Lines 63 to 71 in 534b09c

if (is_readable_file(filename)) {
GError *error = NULL;
pixbuf = gdk_pixbuf_new_from_file(filename, &error);
if (!pixbuf) {
LOG_M("%s", error->message);
g_error_free(error);
}
}
return pixbuf;

The only condition in which it doesn't print an error is if it can't read the file for some reason which is what I'm suspecting currently (but then again it wouldn't crash without the patch?).

@lightdiscord
Copy link
Author

lightdiscord commented May 2, 2018

So many lines in logs.txt

I send a notification with the png then with the svg

@tsipinakis
Copy link
Member

tsipinakis commented May 2, 2018

So many logs yet not a single one from the debug output 😦

access("/home/arnaud/Documents/papirus-icons/spotify-client.svg", R_OK) = 0
openat(AT_FDCWD, "/home/arnaud/Documents/papirus-icons/spotify-client.svg", O_RDONLY) = 8

That theory is out at least. If you run dunst the same way without the redirects and strace (./dunst) is there really no output after sending a notification? (assuming you did make clean && make debug)

@lightdiscord
Copy link
Author

lightdiscord commented May 2, 2018

My bad, I forgot the debug.

Here is the log.txt

MESSAGE: Couldn't recognize the image file format for file '/home/arnaud/Documents/papirus-icons/spotify-client.svg'

🤔

@tsipinakis
Copy link
Member

tsipinakis commented May 2, 2018

That's what I was looking for and what we were suspecting from the beginning.

I've never used nix before so I have no clue how it works but digging around in their repo looks like gdk-pixbuf 2.36.12 is available in the staging branch. If it's not much of a bother can you install that (recompile dunst just in case) and test again to check if it's a library version issue?


@bebehei

Yes, I also think we should do a patch release

Given that we're in the middle of a big refactor that will probably take a bit before we're ready for another release I'd say I agree as well. I'll prepare a bugfix release this weekend.

@lightdiscord
Copy link
Author

I've never used nix before so I have no clue how it works but digging around in their repo looks like gdk-pixbuf 2.36.12 is available in the staging branch. If it's not much of a bother can you install that (recompile dunst just in case) and test again to check if it's a library version issue?

Doesn't seem to be working either with gdk-pixbuf 2.36.12.

@bebehei
Copy link
Member

bebehei commented May 2, 2018

Doesn't seem to be working either with gdk-pixbuf 2.36.12.

I don't want to be the smart ass here, but for me this smelled even before like a subdependency problem and, that it's not gdk-pixbuf2 alone.

The weirdest thing actually: librsvg requires gdk-pixbuf2 (and not the other way around) WTF!?.

@lightdiscord Does gdk-pixbuf-query-loaders --update-cache && killall dunst help you and show icons again?

@lightdiscord
Copy link
Author

lightdiscord commented May 3, 2018

Weird, there are no svg related lines when running the command gdk-pixbuf-query-loaders

@lightdiscord
Copy link
Author

lightdiscord commented May 3, 2018

Solved!

I export the GDK_PIXBUF_MODULE_FILE variable to the loaders.cache generated by librsvg and then run dunst.

I guess it's something related to how nix manage files.

@tsipinakis
Copy link
Member

It might be worth reporting this to nix as well. I doubt you'll be the first one to run into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants