Skip to content

Possible issue with thread management (Helgrind) #1476

@fclivaz42

Description

@fclivaz42

Git commit reference
d46bd98 (V10.1.3)

Describe the bug
Running the basic ping/pong bot example through helgrind (valgrind --tool=helgrind) creates a gigantic log of data races and mutex/rwlock issues.

To Reproduce
Steps to reproduce the behavior:

  1. Compile the base program shown at https://dpp.dev/firstbot.html, without bot.on_log(). (I personally used the flags -ldpp -std=c++23 -g3)
  2. Run valgrind --tool=helgrind ./a.out
  3. Observe!

Expected behavior
Helgrind should not be outputting so many "possible data race", "write lock granted on mutex/rwlock which is currently wr-held by a different thread", and so on.

Screenshots
Not applicable, however I can attach both a log file as well as the sample code (without the token heh) that produced this error.

System Details:

  • OS: Arch Linux
  • Discord Client used for testing: N/A

Additional context
This seems to happen regardless of the OS. I also attempted it on Alpine Linux and i could recreate it as well.
Oddly enough, -fsanitize=thread does not complain at all.

Here's the program that I used to recreate this issue:

#include <dpp/dpp.h>

const std::string BOT_TOKEN = "insert token here";

int main() {
	dpp::cluster bot(BOT_TOKEN);

	bot.on_slashcommand([&bot](const dpp::slashcommand_t& event) {
		if (event.command.get_command_name() == "stop") {
			event.reply("Pong!");
			bot.shutdown(); // shutting the bot down also seems to throw a million issues!
		}
	});

	bot.on_ready([&bot](const dpp::ready_t& event) {
		(void)event;
		if (dpp::run_once<struct register_bot_commands>()) {
			bot.global_command_create(dpp::slashcommand("stop", "stop!", bot.me.id));
		}
	});

	bot.start(dpp::st_wait);
}

And the attached Valgrind log:

helgrind.log

Sorry if this seems a bit hectic? I could not find another mention of helgrind in the issues, so I decided to open one myself.

Have a nice day!

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