Skip to content

Segfault inside reconnect_monitor #1607

Closed

Description

@igor725

Git commit reference
d4befa7c6205de3b1a393cb6f7c8101dde5b7860

Describe the bug
Something happened with my Internet connection during shard reconnection:

[2026-07-07 01:13:33] INFO: Reconnecting shard 0
[2026-07-07 04:16:58] INFO: Reconnecting shard 0
[2026-07-07 04:17:18] INFO: Exception when reconnecting shard 0: getaddrinfo error: Temporary failure in name resolution

Then I got the nullptr dereference segfault.

To Reproduce
Steps to reproduce the behavior:

  1. Break your DNS server connection?
  2. Get a segfault

Expected behavior
No segfault.

Screenshots

Image

System Details:

  • OS: Arch Linux

Additional context
I'm sticking to the last v10.1.5 release, but technically should be reproducible on master too since from what I've seen there was no changes in this part of src/cluster.cpp, the exception handler still sets shard to nullptr and the part above has no if(old == nullptr) check inside.

Activity

  1. braindigitalis commented on Jul 7, 2026

    @braindigitalis
    Contributor

    thanks for the report! looks like an easy fix.

    we would welcome a pr if you feel like contributing this fix yourself.

    note that it should still continue to retry until the connection returns.

  2. igor725 commented on Jul 7, 2026

    @igor725
    ContributorAuthor

    thanks for the report! looks like an easy fix.

    we would welcome a pr if you feel like contributing this fix yourself.

    note that it should still continue to retry until the connection returns.

    I'm not really familiar with the codebase, I only started using this library like a week ago but from what I gathered it should not delete the old shard in the exception catch block because I see it deleting it inside the try block? My solution would be to hold that new discord_client outside of try-catch block in local variable and delete it instead of old one if exception was caught and leave old untouched. The new shard would get installed only if discrod_client constructor and ->run() call succeeded with no exception. This way it can try to reuse old shard data on next reconnect attempt. If it's fine by you then I'll prepare the PR.

  3. braindigitalis commented on Jul 7, 2026

    @braindigitalis
    Contributor

    that sounds sane to me!

  4. igor725 commented on Jul 7, 2026

    @igor725
    ContributorAuthor

    Alright, then I get to it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions