tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 49985] Lazy initialization without any synchronization - data race in AstInteger, AstFloatingPoint, AstString
Date Fri, 01 Oct 2010 08:06:20 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=49985

Sergey Vorobyev <sergeyvorobyev@google.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |

--- Comment #2 from Sergey Vorobyev <sergeyvorobyev@google.com> 2010-10-01 04:06:16
EDT ---
First and most obviously, two or more Long/BigInteger objects could be
allocated. It's not dangerous, but not good.

Second consider following:

Thread1:
protected Number getInteger() {
        if (this.number == null) {
            try {
->              this.number = new Long(this.image); // this.number isn't null,
but not fully complete.

Thread2:
protected Number getInteger() {
        if (this.number == null) { // break, because this.number isn't null
already.
            ...
        }
->      return number; // publish not fully complete object link.
    }

For more reasons see
http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html
(It's about dcl, but about lazy initialization generally two. First example
become to this code exactly)

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message