Github user maoling commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/584#discussion_r205941687
  
    --- Diff: src/java/main/org/apache/zookeeper/server/DataTree.java ---
    @@ -478,7 +478,10 @@ public void createNode(final String path, byte data[], 
List<ACL> acl,
                     HashSet<String> list = ephemerals.get(ephemeralOwner);
                     if (list == null) {
                         list = new HashSet<String>();
    -                    ephemerals.put(ephemeralOwner, list);
    +                    HashSet<String> _list;
    +                    if ((_list = ephemerals.putIfAbsent(ephemeralOwner, 
list)) != null) {
    +                        list = _list;
    +                    }
                     }
                     synchronized (list) {
    --- End diff --
    
    Even if when `createNode` is called by multi-thread.this fix is also not 
thread-safe.
    Step1:One thread has acquired the `list` lock and enters into L487,add a 
element into  `list`
    Step2:But at the same time just after Step1, another thread enters into 
L483,the reference of `list` is pointed to the old `_list` object. It will 
cause thread-unsafe
    BTW: **Breaking Bad** is the best U.S.TV series


---

Reply via email to