diff --git a/CHANGELOG.md b/CHANGELOG.md index 60ab5ecd9..3b65396c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ - Pass scrollViewWillEndDragging delegation through in ASIGListAdapterDataSource for IGListKit integration. [#796](https://github.com/TextureGroup/Texture/pull/796) - Fix UIResponder handling with view backing ASDisplayNode. [Michael Schneider](https://github.com/maicki) [#789] (https://github.com/TextureGroup/Texture/pull/789/) - Optimized thread-local storage by replacing pthread_specific with C11 thread-local variables. [Adlai Holler](https://github.com/Adlai-Holler) [#811] (https://github.com/TextureGroup/Texture/pull/811/) +- Fixed a thread-sanitizer warning in ASTextNode. [Adlai Holler](https://github.com/Adlai-Holler) [#830] (https://github.com/TextureGroup/Texture/pull/830/) ## 2.6 - [Xcode 9] Updated to require Xcode 9 (to fix warnings) [Garrett Moon](https://github.com/garrettmoon) diff --git a/Source/ASTextNode.mm b/Source/ASTextNode.mm index ccbed9c07..a0662516e 100644 --- a/Source/ASTextNode.mm +++ b/Source/ASTextNode.mm @@ -63,10 +63,13 @@ @interface ASTextNodeRendererKey : NSObject @property (assign, nonatomic) CGSize constrainedSize; @end -@implementation ASTextNodeRendererKey +@implementation ASTextNodeRendererKey { + std::mutex _m; +} - (NSUInteger)hash { + std::lock_guard _l(_m); #pragma clang diagnostic push #pragma clang diagnostic warning "-Wpadded" struct { @@ -86,7 +89,14 @@ - (BOOL)isEqual:(ASTextNodeRendererKey *)object return YES; } - return _attributes == object.attributes && CGSizeEqualToSize(_constrainedSize, object.constrainedSize); + // NOTE: Skip the class check for this specialized, internal Key object. + + // Lock both objects, avoiding deadlock. + std::lock(_m, object->_m); + std::lock_guard lk1(_m, std::adopt_lock); + std::lock_guard lk2(object->_m, std::adopt_lock); + + return _attributes == object->_attributes && CGSizeEqualToSize(_constrainedSize, object->_constrainedSize); } @end