Skip to content

deadlock[BUG] #100

@wjr-z

Description

@wjr-z

Deadlock caused by reset
It is necessary to lock running during reset
Otherwise, if the thread is in the process of judging the end of running, but has not yet waited, the running has been modified and has been notified_ All, it will deadlock
The probability of deadlock is very low, but it may still occur.
On my local machine, a deadlock occurred when using GCC12.2 for testing

BS::thread_pool pool;
void func() {
	pool.pause();
	for (int i = 0; i < 32; ++i) {
		pool.push_task([]() {return 0; });
	}
	pool.unpause();
	for (int i = 0; i < 32; ++i) {
		pool.reset();
	}
	pool.wait_for_tasks();
}

int main() {
	for (int i = 0; i < 1e3; ++i) {
		func();
		printf("%d ", i);
	}
	printf("done\n");
	return 0;
}

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions