[jboss-jira] [JBoss JIRA] (JASSIST-259) Concurrency issue in ProxyFactory
Shigeru Chiba (JIRA)
issues at jboss.org
Tue Jan 19 04:08:00 EST 2016
[ https://issues.jboss.org/browse/JASSIST-259?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13150344#comment-13150344 ]
Shigeru Chiba edited comment on JASSIST-259 at 1/19/16 4:07 AM:
----------------------------------------------------------------
You're right. I found [this commit|https://github.com/jboss-javassist/javassist/commit/bd1c47e0f555ada2d250a52f4a3b6697107486b0#diff-784aef550e16e266f5ecb6a3ce357fd1] introduced this bug.
A fix will be:
{code:java}
private Class createClass1() {
Class result = thisClass;
if (result == null) {
ClassLoader cl = getClassLoader();
synchronized (proxyCache) {
if (factoryUseCache)
createClass2(cl);
else
createClass3(cl);
result = thisClass;
// don't retain any unwanted references
thisClass = null;
}
}
// don't do thisClass = null
return result;
}
}
{code}
was (Author: chiba):
You're right. I found [this commit|https://github.com/jboss-javassist/javassist/commit/bd1c47e0f555ada2d250a52f4a3b6697107486b0#diff-784aef550e16e266f5ecb6a3ce357fd1] introduced this bug.
A fix will be:
{code:java}
private Class createClass1() {
Class result = thisClass;
if (result == null) {
ClassLoader cl = getClassLoader();
synchronized (proxyCache) {
if (factoryUseCache)
createClass2(cl);
else
createClass3(cl);
result = thisClass;
// don't retain any unwanted references
thisClass = null;
}
}
return result;
}
{code}
> Concurrency issue in ProxyFactory
> ---------------------------------
>
> Key: JASSIST-259
> URL: https://issues.jboss.org/browse/JASSIST-259
> Project: Javassist
> Issue Type: Bug
> Affects Versions: 3.12.0.GA
> Environment: AIX, IBM J9 VM (build 2.8, JRE 1.8.0 AIX ppc64-64 Compressed References 20150722_258693 (JIT enabled, AOT enabled)
> Reporter: Christian Beikov
> Assignee: Shigeru Chiba
> Priority: Critical
>
> Look at the following line to understand the issue
> https://github.com/jboss-javassist/javassist/blob/master/src/main/javassist/util/proxy/ProxyFactory.java#L435
> If there are 2 threads T1 and T2 at this line, T1 pauses and T2 runs through, on some systems T1 may encounter thisClass to be null after it wakes up again.
> This leads to Hibernate getting a null class in JavassistProxyFactory and trying to create an instance of that which fails with a NPE.
> Can anyone please confirm this issue? Maybe there is something in the JMM that I am not aware of that makes this code safe, but as far as I can tell, this looks like a real bug that just happens to uncover itself on an environment like J9 on AIX.
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
More information about the jboss-jira
mailing list