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

queue_runner uses this after destruction #13

Closed
Kirkezz opened this issue Apr 5, 2024 · 4 comments · Fixed by #10
Closed

queue_runner uses this after destruction #13

Kirkezz opened this issue Apr 5, 2024 · 4 comments · Fixed by #10
Assignees

Comments

@Kirkezz
Copy link
Contributor

Kirkezz commented Apr 5, 2024

I am using your library as follows:

int getPlayersCount() {
    static int id = 2;
    int result = -1;

    rconpp::rcon_client client(rcon_credentials.ip, rcon_credentials.port, rcon_credentials.password);
    if (client.connected) {
        auto response = client.send_data_sync("list", ++id, rconpp::data_type::SERVERDATA_EXECCOMMAND);
        /* ... */
        std::cout << response.data << std::endl;
    }

    return result;
}

The program crashes with segfault:
crash
I think the problem is that queue_runner uses this after the rcon_client object is destroyed.
With the following changes, segfault no longer occurs:
changes

@Jaskowicz1
Copy link
Owner

Huh, that is a bizarre one. the deconstructor of rcon_client should kill this queue_runner (as connected becomes false so the while should break).

If that does fix the issue though, I'll gladly add it! Thank you!!

@Kirkezz
Copy link
Contributor Author

Kirkezz commented Apr 5, 2024

I think the UB still persists here. The problem is that connected becomes false in the middle of a while loop. It also looks like queue_runner is not joinable in destructor.

@Jaskowicz1
Copy link
Owner

I think the UB still persists here. The problem is that connected becomes false in the middle of a while loop. It also looks like queue_runner is not joinable in destructor.

Hm, that's interesting... Odd why this never came up in testing 🤔

@Jaskowicz1
Copy link
Owner

ahhhhhh I'm so silly, I understand now.

@Jaskowicz1 Jaskowicz1 self-assigned this Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants