chatterino2 icon indicating copy to clipboard operation
chatterino2 copied to clipboard

Blocking a user through usercard then quickly closing it crashes the application

Open zneix opened this issue 2 years ago • 5 comments

This happens somewhere in src/widgets/dialogs/UserInfoPopup.cpp:473 lines 473, 519, basically this used in that context is no longer present.

zneix avatar Dec 12 '21 21:12 zneix

I suspect that this could happen in many other places which use NetworkRequest and can be deleted, this becomes an invalid pointer and SEGFAULT. We actually have a solution for this: NetworkRequest::caller(const QObject *parent):

    /// NetworkRequest makes sure that the `caller` object still exists when the
    /// callbacks are executed. Cannot be used with concurrent() since we can't
    /// make sure that the object doesn't get deleted while the callback is
    /// running.

Mm2PL avatar Dec 17 '21 23:12 Mm2PL

This will be solved when I refactor Helix to use a NetworkRequest-like builder :)

Mm2PL avatar Jun 05 '22 22:06 Mm2PL

This bug is also reproducible on chatterino7 builds (and any related forks) when Show 7TV Animated Profile Picture is enabled, as opposed to it relating specifically to blocking.

Imo the issue title should be renamed to reflect the issue more accurately, and for easier discoverability.

Event viewer says: Faulting module name: ntdll.dll Demo: https://i.alienpls.org/DFe.apng

usercard debug logs
chatterino.http: "GET 200 https://api.ivr.fi/twitch/subage/brian6932/brian6932"
chatterino.twitch: [TwitchChannel "brian6932" ] Opened
chatterino.twitch: [TwitchChannel "brian6932" ] Send message: ""
chatterino.http: "GET 200 https://api.twitch.tv/helix/users?login=brian6932"
chatterino.http: "GET 200 https://api.7tv.app/v2/users/brian6932"
chatterino.http: "GET 200 https://api.twitch.tv/helix/users/follows?to_id=84180052"

brian6932 avatar Sep 15 '22 02:09 brian6932

As zneix mentioned in his initial error report, the callbacks that come back from helix contains a raw pointer to the UserCard without holding a proper reference to it. We'd want to use shared_from_this and pass along:

  • a weak pointer to the UserInfoPopup so we can call reenableBlockCheckbox
  • a shared_pointer to the channel (so just pass along this->channel_) so we know where to send the error/success message
  • the username as a QString [weak = this->shared_from_this(), channel = this->channel_, userName = this->userName_]

Block https://github.com/Chatterino/chatterino2/blob/c6ebb70e05c4b8c4b220498afde17846c7874ba9/src/widgets/dialogs/UserInfoPopup.cpp#L553-L568 Unblock https://github.com/Chatterino/chatterino2/blob/c6ebb70e05c4b8c4b220498afde17846c7874ba9/src/widgets/dialogs/UserInfoPopup.cpp#L580-L595

pajlada avatar Sep 15 '22 08:09 pajlada

This bug is also reproducible on chatterino7 builds (and any related forks) when Show 7TV Animated Profile Picture is enabled, as opposed to it relating specifically to blocking.

That is a 7tv bug. Not our code.

Mm2PL avatar Sep 15 '22 09:09 Mm2PL

Fixed in https://github.com/Chatterino/chatterino2/pull/4711

pajlada avatar Mar 02 '24 14:03 pajlada