diamondburned / dissent

Tiny native Discord app
https://flathub.org/apps/details/so.libdb.dissent
GNU General Public License v3.0
1.23k stars 39 forks source link

Crash when opening direct message from bot. #154

Open ScanuNicco opened 11 months ago

ScanuNicco commented 11 months ago

I am the developer of a custom Discord bot that will send DMs containing buttons to people who use it. When I try to open the dm from the development version that bot, gtkcord4 crashes. Interestingly, the dm channel from the production version of the bot does not cause gtkcord4 to crash. I am on Fedora 38 with KDE, and gtkcord4 is installed as a Flatpak.

2023/09/11 16:58:55 failed to read user.css: open /home/nscanu/.var/app/xyz.diamondb.gtkcord4/config/gtkcord4/user.css: no such file or directory
2023/09/11 16:58:55 State: WidgetHandler: binding to *window.loginWindow...
2023/09/11 16:58:56 connected: READY
2023/09/11 16:58:56 icon: unknown icon "forum-dark.png"
2023/09/11 16:58:56 Warning: Adwaita: Using GtkSettings:gtk-application-prefer-dark-theme with libadwaita is unsupported. Please use AdwStyleManager:color-scheme instead.
2023/09/11 16:59:00 loading message view for 1055353746823073842
2023/09/11 16:59:00 State: WidgetHandler: binding to *message.View...
2023/09/11 16:59:00 Discord API: GET /api/v9/channels/1055353746823073842/messages
2023/09/11 16:59:00 State: WidgetHandler: binding to *composer.View...
2023/09/11 16:59:00 message.View.MarkRead: marked 1150515063984230461 as read, last read 1150515063984230461
2023/09/11 16:59:00 message.View.MarkRead: marked 1150515063984230461 as read, last read 1150515063984230461
2023/09/11 16:59:00 message.View.MarkRead: marked 1150515063984230461 as read, last read 1150515063984230461
2023/09/11 16:59:00 message.View.MarkRead: marked 1150515063984230461 as read, last read 1150515063984230461
2023/09/11 16:59:01 message.View.MarkRead: marked 1150515063984230461 as read, last read 1150515063984230461
2023/09/11 16:59:01 message.View.MarkRead: marked 1150515063984230461 as read, last read 1150515063984230461
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: closure error: unexpected panic caught: runtime error: invalid memory address or nil pointer dereference

Closure added at:
        github.com/diamondburned/gotk4/pkg/glib/v2.TimeoutAdd at /run/build/gtkcord4/vendor/github.com/diamondburned/gotk4/pkg/glib/v2/glib.go:30358
        github.com/diamondburned/gtkcord4/internal/message.(*View).load.func1.3 at /run/build/gtkcord4/internal/message/view.go:367
        github.com/diamondburned/gotkit/gtkutil.Async.func1.1 at /run/build/gtkcord4/vendor/github.com/diamondburned/gotkit/gtkutil/gtkutil.go:334
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x166d749]

goroutine 1 [running, locked to thread]:
github.com/diamondburned/gotk4/pkg/core/closure.(*FuncStack).Panicf(0xc0002c25a0, {0x23e7dd3, 0x1b}, {0xc00055ed30, 0x1, 0x1})
        /run/build/gtkcord4/vendor/github.com/diamondburned/gotk4/pkg/core/closure/funcstack.go:104 +0x928
github.com/diamondburned/gotk4/pkg/core/closure.(*FuncStack).TryRepanic(0xc000b1aa20?)
        /run/build/gtkcord4/vendor/github.com/diamondburned/gotk4/pkg/core/closure/funcstack.go:122 +0xc5
panic({0x203b060?, 0x4271f30?})
        /usr/lib/sdk/golang/src/runtime/panic.go:914 +0x21f
github.com/yuin/goldmark/ast.(*CodeSpan).Parent(0x27?)
        <autogenerated>:1 +0x9
github.com/yuin/goldmark/ast.ensureIsolated({0x26e2430, 0x0})
        /run/build/gtkcord4/vendor/github.com/yuin/goldmark/ast/ast.go:184 +0x24
github.com/yuin/goldmark/ast.(*BaseNode).AppendChild(0xc000af0d80, {0x26e16b0, 0xc000af0d80}, {0x26e2430, 0x0})
        /run/build/gtkcord4/vendor/github.com/yuin/goldmark/ast/ast.go:311 +0x36
github.com/yuin/goldmark/parser.(*parser).parseBlock(0xc000b16a00, {0x26dd638?, 0xc000e12d20}, {0x26e16b0, 0xc000af0d80}, {0x26dd940, 0xc0003b3880})
        /run/build/gtkcord4/vendor/github.com/yuin/goldmark/parser/parser.go:1192 +0x2c7
github.com/yuin/goldmark/parser.(*parser).Parse.func2({0x26e16b0?, 0xc000af0d80?})
        /run/build/gtkcord4/vendor/github.com/yuin/goldmark/parser/parser.go:864 +0x3d
github.com/yuin/goldmark/parser.(*parser).walkBlock(0x2136b00?, {0x26e16b0, 0xc000af0d80}, 0xc00055f220)
        /run/build/gtkcord4/vendor/github.com/yuin/goldmark/parser/parser.go:1115 +0x79
github.com/yuin/goldmark/parser.(*parser).walkBlock(0xc0007ffa70?, {0x26e1470, 0xc000b1a870}, 0xc00055f220)
        /run/build/gtkcord4/vendor/github.com/yuin/goldmark/parser/parser.go:1113 +0x4c
github.com/yuin/goldmark/parser.(*parser).Parse(0xc000b16a00, {0x26dd418, 0xc0003b39d0}, {0xc00078f478, 0x1, 0x7f6f26b94368?})
        /run/build/gtkcord4/vendor/github.com/yuin/goldmark/parser/parser.go:863 +0x1f3
github.com/diamondburned/ningen/v3/discordmd.ParseWithMessage({0xc0007ffa70, 0x2a, 0x30}, {{0x26c8898, 0xc0001c8000}, {0x26d2f70, 0xc00019a960}, {0x26c9400, 0xc0000137d0}, {0x26c9f60, ...}, ...}, ...)
        /run/build/gtkcord4/vendor/github.com/diamondburned/ningen/v3/discordmd/md.go:39 +0x47c
github.com/diamondburned/gtkcord4/internal/message.(*Content).Update(0xc000fbc0c0, 0xc000b1c480, {0x0, 0x0, 0xc000b1c480?})
        /run/build/gtkcord4/internal/message/content.go:278 +0x13a5
github.com/diamondburned/gtkcord4/internal/message.(*message).update(0xc00108af10, {0x26d9a80, 0xc00108af00}, 0xc000b1c480)
        /run/build/gtkcord4/internal/message/message.go:85 +0x6d
github.com/diamondburned/gtkcord4/internal/message.(*collapsedMessage).Update(0xc00108af00, 0xc000b1c480)
        /run/build/gtkcord4/internal/message/message.go:334 +0x39
github.com/diamondburned/gtkcord4/internal/message.(*View).load.func1.3.1(0x20c27c0?)
        /run/build/gtkcord4/internal/message/view.go:341 +0xfa
github.com/diamondburned/gtkcord4/internal/message.(*View).load.func1.3.2()
        /run/build/gtkcord4/internal/message/view.go:369 +0x32
github.com/diamondburned/gotk4/pkg/core/glib._gotk4_sourceFunc(0x14da)
        /run/build/gtkcord4/vendor/github.com/diamondburned/gotk4/pkg/core/glib/glib.go:340 +0xd9
github.com/diamondburned/gotk4/pkg/gio/v2._Cfunc_g_application_run(0x60ad190, 0x1, 0x60b2820)
        _cgo_gotypes.go:13789 +0x4b
github.com/diamondburned/gotk4/pkg/gio/v2.(*Application).Run.func3(0xc0004a6100?, 0x8?, 0x60b2820?)
        /run/build/gtkcord4/vendor/github.com/diamondburned/gotk4/pkg/gio/v2/gio.go:41611 +0x67
github.com/diamondburned/gotk4/pkg/gio/v2.(*Application).Run(0xc000139f38, {0xc0000360f0?, 0x1, 0x1})
        /run/build/gtkcord4/vendor/github.com/diamondburned/gotk4/pkg/gio/v2/gio.go:41611 +0x20b
github.com/diamondburned/gotkit/app.(*Application).Run(0xc000142480, {0xc0000360f0, 0x1, 0x1})
        /run/build/gtkcord4/vendor/github.com/diamondburned/gotkit/app/app.go:272 +0x14f
github.com/diamondburned/gotkit/app.(*Application).RunMain(0x26cc320?)
        /run/build/gtkcord4/vendor/github.com/diamondburned/gotkit/app/app.go:277 +0x28
main.main()
        /run/build/gtkcord4/main.go:60 +0x5d8

If it helps, here is the function from my bot responsible for sending the buttons:

    async sendControls(client) {
        const userObj = await client.users.fetch(this.target.id);
        const userDM = await userObj.createDM();
        const row = new ActionRowBuilder()
            .addComponents(
                new ButtonBuilder()
                    .setCustomId('foundRide')
                    .setLabel('I Found a Ride!')
                    .setStyle(ButtonStyle.Primary),
                new ButtonBuilder()
                    .setCustomId('cancelReq')
                    .setLabel('Cancel this Request')
                    .setStyle(ButtonStyle.Danger),
            );
        const controls = await userDM.send({content: "**Handy Control Panel:** Ride request for `" + this.destName + "`", components: [row]});
        return controls.id;
    }
diamondburned commented 11 months ago

Agh, more Markdown parser bugs! I've been trying to figure out that part, but I must've made some really funny mistake.

Could you try sending me what the full message in raw Markdown was?

ScanuNicco commented 11 months ago

The message contains the following text

**Handy Control Panel:** Ride request for `Vigo Bowl`

Along with two clickable buttons, which I suspect are the source of the crash. I'm not sure if it's possible to copy the source for those.

diamondburned commented 11 months ago

Can you check this again with the latest nightly build?