grialion / rpcpp

RPC++ is a tool for Discord RPC (Rich Presence) to let your friends know about your Linux system
MIT License
17 stars 4 forks source link

free(): invalid size #3

Closed timfvb closed 1 year ago

timfvb commented 1 year ago

Connects, after a short time the error message:

free(): invalid size
zsh: IOT instruction (core dumped)  rpcpp
grialion commented 1 year ago

Same bug as #1, I wonder if it's a bug in Xlib, probably not though.

I got that one time too, not sure what fixed it. If you still have the issue, please could you tell me more information about your environment (distro, kernel, ram) and Xorg/X11 version?

timfvb commented 1 year ago

Manjaro Gnome

insertagamertag commented 1 year ago

This is still happening for me unfortunately. I am using a wl-roots based window manager on an arch install. I am also on wayland are there any fixes available yet? I'd love to use this!

grialion commented 1 year ago

This is still happening for me unfortunately. I am using a wl-roots based window manager on an arch install. I am also on wayland are there any fixes available yet? I'd love to use this!

Could you post your debug logs?

rpcpp --debug

It might help identifying where it crashes. I don't think the window manager is causing it, but it could be Wayland... Also, are you using vanilla Discord? (Also the code is really messy, especially the X11 parts, I'm pretty sure that's where calling free fails. I could rewrite this but I may just end up archiving the project.)

insertagamertag commented 1 year ago

this is the output:

    2023-01-14T20:03:03Z DEBUG: Created usage thread
    2023-01-14T20:03:03Z DEBUG: Threads started.
    Connected to Discord.
    2023-01-14T20:03:03Z DEBUG: Waiting for usages to load...
    2023-01-14T20:03:06Z DEBUG: Starting RPC loop.
    free(): invalid size
    [1]    285701 IOT instruction (core dumped)  rpcpp --debug

I am looking at the code and I think it's the issue in the x11 libraries because I'm running wayland. I'll tinker with this some more and reach you out if I find anything useful. also thanks for answering this soon geez 👍🏽

EDIT: yes I use vanilla discord

EDIT 2: So I made a "dummy" fix by deleting the lines with XFree function which works but the window name and usage stats don't get updated at all and it only works after I switch to discord window. any other window like blender or firefox do not get recognized

EDIT 3: ChatGPT gave me some useful direction for getting the window names under wayland. Will try to work it out today

grialion commented 1 year ago

So you say that XFree messes it up? The documentation says:

[...] The function returns Success if it executes successfully. To free the resulting data, use XFree().

I do that exactly, to prevent memory leak issues. With the latest commit f49a224 I added a null check to prevent calling XFree with a nullptr. I'm also behind the latest Discord updates, they added URL support, so "theming" and richer community features, application expansions would be possible, I created another issue for that: #4

grialion commented 1 year ago

As far as I can see, it perfectly works under Wayland with XWayland enabled (it was default for me), I'll close this issue.

insertagamertag commented 1 year ago

As far as I can see this resolved every issue I had before. Glad to have someone with more skills in c++ than me.

Thank you for your contributions to the community!