[PATCH] D49355: Thread safety analysis: Allow lock upgrading and downgrading

Petr Hosek via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 3 20:00:52 PDT 2018


phosek added a comment.

This change broke the acquire+release case. Concretely, in Flutter we have this code: https://github.com/flutter/engine/blob/master/lib/ui/isolate_name_server/isolate_name_server.h#L26. This worked fine previously, but after this change we're getting an error in https://github.com/flutter/engine/blob/master/lib/ui/isolate_name_server/isolate_name_server_natives.cc#L19 and many other places like this one:

  ../../third_party/flutter/lib/ui/isolate_name_server/isolate_name_server_natives.cc:19:33: error: releasing mutex 'name_server->mutex_' that was not held [-Werror,-Wthread-safety-analysis]
    Dart_Port port = name_server->LookupIsolatePortByName(name);
                                  ^
  ../../third_party/flutter/lib/ui/isolate_name_server/isolate_name_server_natives.cc:24:1: error: mutex 'name_server->mutex_' is still held at the end of function [-Werror,-Wthread-safety-analysis]
  }
  ^
  ../../third_party/flutter/lib/ui/isolate_name_server/isolate_name_server_natives.cc:19:33: note: mutex acquired here
    Dart_Port port = name_server->LookupIsolatePortByName(name);

Would it be possible revert this change? The old logic was "all acquires; then all releases" and the new logic is "all releases; then all acquires" but I think this needs fancier logic with actual bookkeeping to detect the upgrade case without breaking the acquire+release case.


Repository:
  rC Clang

https://reviews.llvm.org/D49355





More information about the cfe-commits mailing list