Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 12 additions & 2 deletions Source/ASTextNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::mutex> _l(_m);
#pragma clang diagnostic push
#pragma clang diagnostic warning "-Wpadded"
struct {
Expand All @@ -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<std::mutex> lk1(_m, std::adopt_lock);
std::lock_guard<std::mutex> lk2(object->_m, std::adopt_lock);

return _attributes == object->_attributes && CGSizeEqualToSize(_constrainedSize, object->_constrainedSize);
}

@end
Expand Down