You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Pavel Pervov (JIRA)" <ji...@apache.org> on 2007/06/19 17:25:27 UTC

[jira] Created: (HARMONY-4238) [drlvm][kernel] Race conditions in statics initialization

[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.


[jira] Commented: (HARMONY-4238) [drlvm][kernel] Race conditions in statics initialization

Posted by "Vera Volynets (JIRA)" <ji...@apache.org>.
    [ 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.


[jira] Commented: (HARMONY-4238) [drlvm][kernel] Race conditions in statics initialization

Posted by "Pavel Pervov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-4238?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12506215 ] 

Pavel Pervov commented on HARMONY-4238:
---------------------------------------

The same holds true for reflection.

I'll fix this some time later if no one outruns me.

> [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.


[jira] Commented: (HARMONY-4238) [drlvm][kernel] Race conditions in statics initialization

Posted by "Pavel Pervov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-4238?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12506892 ] 

Pavel Pervov commented on HARMONY-4238:
---------------------------------------

Stuck login. It was me actually. :)

> [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.


[jira] Commented: (HARMONY-4238) [drlvm][kernel] Race conditions in statics initialization

Posted by "Pavel Pervov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-4238?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12506510 ] 

Pavel Pervov commented on HARMONY-4238:
---------------------------------------

This issue is more generic than HARMONY-4230 though.

> [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.


[jira] Updated: (HARMONY-4238) [drlvm][kernel] Race conditions in statics initialization

Posted by "Pavel Pervov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4238?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Pavel Pervov updated HARMONY-4238:
----------------------------------

    Environment:     (was: Windows)

> [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
>            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.