Project

General

Profile

Task #2123

Use RAII for file-static data

Added by Mark Abraham over 2 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
core library
Target version:
Difficulty:
uncategorized
Close

Description

Various functionality (notably file and error handling) uses file-static thread-MPI mutexes and data structures. Several of these leak, requiring suppressions for tools like valgrind.

We should use std::lock_guard<MutexType> to implement exception-safe mutex locks that are local to a scope and easier to maintain. We could use std::mutex, but it is simple to implement a type that uses that interface that is implemented by our trusted thread-MPI machinery.

The open_files linked list can be initialized lazily in a type that correctly constructs and destructs so that it doesn't leak and remains thread safe.

Associated revisions

Revision c70211cf (diff)
Added by Mark Abraham over 2 years ago

Use gmx::Mutex and gmx::lock_guard to fix some issues

Refactored a few uses of raw thread-MPI mutexes to fix known leaks, so
valgrind and LeakSanitizer become more useful.

Discovered that the thread-MPI trylock behaviour has always been buggy
on Windows, and cannot be fixed so that the return code is consistent
across the two current implementations in the case where the calling
thread might already own the lock. Fortunately, we don't use trylocks
anywhere, and the problematic case is unlikely to occur, but the
limitation is now documented.

Added unit tests for whichever mutex implementation we are using, now
and in the future. These cover the above case.

Found bugs in _where, which presumably wasn't an issue if it only
ran when handling errors. But it runs multiple times per MD step.

Refs #2122
Refs #2123

Change-Id: If1b2f092c569f47d67ce39e6decb56f04cea314a

History

#1 Updated by Gerrit Code Review Bot over 2 years ago

Gerrit received a related patchset '1' for Issue #2123.
Uploader: Mark Abraham ()
Change-Id: gromacs~master~If1b2f092c569f47d67ce39e6decb56f04cea314a
Gerrit URL: https://gerrit.gromacs.org/6474

#2 Updated by Gerrit Code Review Bot over 2 years ago

Gerrit received a related patchset '1' for Issue #2123.
Uploader: Mark Abraham ()
Change-Id: gromacs~master~I07088349bd3c3b881b0d773efef864460089fddf
Gerrit URL: https://gerrit.gromacs.org/6475

#3 Updated by Mark Abraham over 2 years ago

  • Status changed from New to Closed

I think I did all I meant to do here

Also available in: Atom PDF