Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Fixing use of mutex() to avoid subtle bug - #798

Merged
Stefan J. Wernli (swernli) merged 3 commits into
mainfrom
swernli/mutex-fix
Aug 17, 2021
Merged

Fixing use of mutex() to avoid subtle bug#798
Stefan J. Wernli (swernli) merged 3 commits into
mainfrom
swernli/mutex-fix

Conversation

@swernli

Copy link
Copy Markdown
Collaborator

This change fixes what seems to be a subtle bug in the syncrhonization mechanisms for the simulator. In particular, we have seen intermediate failures in the simulator tests that seem to be the result of a simulator thread stepping on another thread. As Robin Kuzmin (@kuzminrobin) pointed out in #710 (comment), this could be due to the fact that the mutex access method, mutex() has the same signature as the standard constructor for mutex. This could mean that if the compilation environment has a using namespace std; anwhere in it that the calls to mutex() would allocate a fresh mutex rather than access the member mutex, meaning none of the threads are synchronized as expected. This avoid the problem by renaming the accessor to getmutex().

This change fixes what seems to be a subtle bug in the syncrhonization mechanisms for the simulator. In particular, we have seen intermediate failures in the simulator tests that seem to be the result of a simulator thread stepping on another thread. As @kuzminrobin pointed out in #710 (comment), this could be due to the fact that the mutex access method, `mutex()` has the same signature as the standard constructor for mutex. This could mean that if the compilation environment has a `using namespace std;` anwhere in it that the calls to `mutex()` would allocate a fresh mutex rather than access the member mutex, meaning none of the threads are synchronized as expected. This avoid the problem by renaming the accessor to `getmutex()`.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants