Closed Bug 1098387 Opened 10 years ago Closed 2 years ago

offer GUARDED_BY() and equivalent macros for annotating thread safety and locking

Categories

(Core :: MFBT, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1207753

People

(Reporter: jesup, Unassigned)

Details

The next import of WebRTC.org code will include GUARDED_BY(a_critical_section) annotations. (on clang, devolves to __attribute__(guarded_by(a_critical_section)) )

This is derived from https://code.google.com/p/gperftools/source/browse/src/base/thread_annotations.h and modified in webrtc.org for clang (from GCC), so likely we could have it do both.

In the webrtc.org codebase, it's in webrtc/base/thread_annotations.h:
https://code.google.com/p/webrtc/source/browse/trunk/webrtc/base/thread_annotations.h

This would likely allow better analysis ala tsan and be better (and more maintainable) than 10 million AssertCurrentThreadOwns()s in the source.
I remember seeing something along these lines in a patch, that added macros annotating things for valgrind purposes (or its thread-safety-checking sub-variant).  Not sure if it landed or not, and I can't find it in open mfbt bugs right now, and I don't remember names well enough to search for it.  (But said names closely paralleled valgrind macro name concepts, so that'd be the way to search to find it, I think.)

These macros have been in use now going on 5 years in WebRTC.org we imported, and it would be great if we could use them or equivalents. This has probably been made easier by the fact that we now build using clang on all targets.

Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.