[ https://issues.apache.org/jira/browse/THRIFT-1618?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14158285#comment-14158285 ]
ASF GitHub Bot commented on THRIFT-1618: ---------------------------------------- GitHub user dhelder opened a pull request: https://github.com/apache/thrift/pull/235 THRIFT-1618: synchronize access to hashtable in FieldMetaData You can merge this pull request into a Git repository by running: $ git pull https://github.com/dhelder/thrift THRIFT-1618 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/thrift/pull/235.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #235 ---- commit b7a0158fbaf9c2e2b82e021711ad12eacfdcfc09 Author: David Helder <da...@twitter.com> Date: 2014-10-03T16:50:14Z THRIFT-1618: synchronize access to hashtable in FieldMetaData ---- > static structMap in FieldMetaData is not thread safe and can lead to deadlocks > ------------------------------------------------------------------------------ > > Key: THRIFT-1618 > URL: https://issues.apache.org/jira/browse/THRIFT-1618 > Project: Thrift > Issue Type: Bug > Components: Java - Compiler, Java - Library > Affects Versions: 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8 > Environment: jdk 1.6 > Reporter: Mike Rettig > Priority: Critical > Attachments: ThriftDeadlock.java > > > Generated thrift structs use static initializers to add metadata to the > static 'structMap' field in FieldMetaData. Since the thrift structs may be > separate classes, the static initializers can be executed on different > threads. The addStructMetaDataMap method does not synchronize access and uses > a standard HashMap which is not thread safe. This can lead to corruption of > the structMap and in some cases deadlocks due to corrupt entries in the map > during a put operation. > The easy fix is to use a thread safe map for the structMap. > Another fix is to just retrieve the field directly from the class in the > 'getStructMetaDataMap' using reflection. > I've confirmed the deadlock in 0.2. I looked at the 0.8 code and confirmed > the bug is still present. -- This message was sent by Atlassian JIRA (v6.3.4#6332)