harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vera Volynets (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-4238) [drlvm][kernel] Race conditions in statics initialization
Date Thu, 21 Jun 2007 13:09:26 GMT

    [ https://issues.apache.org/jira/browse/HARMONY-4238?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12506891
] 

Vera Volynets commented on HARMONY-4238:
----------------------------------------

It is still race condition if the operation on the right of the assignment operator can return
different values for different calls.

In the example above native heap may be exausted at the time of race condition in this assignment
and one of calls to 'new' will return NULL, white the other will return normal object. It
is subject to race condition whether NULL or newly allocated object will be written to local
variable 'a'.

The described problem affects gcc also, so I'll change environment too.

> [drlvm][kernel] Race conditions in statics initialization
> ---------------------------------------------------------
>
>                 Key: HARMONY-4238
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4238
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>         Environment: Windows
>            Reporter: Pavel Pervov
>
> It is known problem on Windows - statics are compiled the way their initialization is
not thread safe.
> The construct like this:
> void bar() {
>     static A* a = new A();
>     a->foo();
> }
> may produce access violation.
> I suggest changing that code to
> void bar()
> {
>     static A a;
>     if(a == NULL) {
>         a = new A();
>     }
>     a->foo();
> }
> This may produce multiple initializations but if we can guarantee that second (and all
subsequent) initialization returns the same result - it is false-positive.
> I fixed one place described in HARMONY-4230 but about 4 more places are left in kernel
classes' natives which are sources of such race conditions.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message