Skip to content

Fix unchecked_map destructor.#3723

Merged
clemahieu merged 1 commit intonanocurrency:developfrom
clemahieu:unchecked_map_shutdown
Feb 8, 2022
Merged

Fix unchecked_map destructor.#3723
clemahieu merged 1 commit intonanocurrency:developfrom
clemahieu:unchecked_map_shutdown

Conversation

@clemahieu
Copy link
Copy Markdown
Contributor

Fix an issue with unchecked_map::~unchecked_map where the condition variable signal can be missed since the object mutex isn't acquired while setting stopped=true.

@clemahieu clemahieu added the bug label Feb 8, 2022
@clemahieu clemahieu added this to the V24.0 milestone Feb 8, 2022
@clemahieu clemahieu requested a review from dsiganos February 8, 2022 14:08
@theohax
Copy link
Copy Markdown
Contributor

theohax commented Feb 8, 2022

In practice I doubt this can actually bite us, but yeah, the proper way of announcing changes via CVs is under the mutex indeed, even if the change is atomic like this one. Just curious, have you seen this cause issues?

theohax
theohax previously approved these changes Feb 8, 2022
@dsiganos
Copy link
Copy Markdown
Contributor

dsiganos commented Feb 8, 2022

@theohax In practice, it would bite us on node shutdown, the node could deadlock on shutdown.

@clemahieu
Copy link
Copy Markdown
Contributor Author

If the working thread is between these two lines when stopped is set to true and the condition variable in notified, it will neither detect the stopped flag nor detect the condition variable notification.

	while (!stopped)
	{
		if (!buffer.empty ())

dsiganos
dsiganos previously approved these changes Feb 8, 2022
thsfs
thsfs previously approved these changes Feb 8, 2022
…ariable signal can be missed since the object mutex isn't acquired while setting stopped=true. Converts unchecked_map::stopped to a non-atomic bool since it needs a mutex anyway.
@clemahieu clemahieu dismissed stale reviews from thsfs and dsiganos via d0089a3 February 8, 2022 14:48
@clemahieu clemahieu force-pushed the unchecked_map_shutdown branch from fe9e60d to d0089a3 Compare February 8, 2022 14:48
@clemahieu clemahieu merged commit 7ea11f8 into nanocurrency:develop Feb 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants