You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Andrey Yakushev (JIRA)" <ji...@apache.org> on 2008/01/16 15:02:34 UTC
[jira] Created: (HARMONY-5395) [drlvm]
vm.classloading.ClassCastTest hangs
[drlvm] vm.classloading.ClassCastTest hangs
-------------------------------------------
Key: HARMONY-5395
URL: https://issues.apache.org/jira/browse/HARMONY-5395
Project: Harmony
Issue Type: Bug
Components: DRLVM
Environment: revision 612006
Linux x86_64
Reporter: Andrey Yakushev
[drlvm] vm.classloading.ClassCastTest stably hangs on first iteration
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
Re: [jira] Updated: (HARMONY-5395) [drlvm] vm.classloading.ClassCastTest hangs
Posted by Xiao-Feng Li <xi...@gmail.com>.
Ilya, I am afraid you don't really understand atomic operation
semantics. You patch is largely wrong. Please don't play around with
atomic operations blindly unless you really understand what you are
doing.
Thanks,
xiaofeng
On Jan 20, 2008 7:24 AM, Ilya Berezhniuk (JIRA) <ji...@apache.org> wrote:
>
> [ https://issues.apache.org/jira/browse/HARMONY-5395?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
>
> Ilya Berezhniuk updated HARMONY-5395:
> -------------------------------------
>
> Attachment: atomics.patch
>
> I've found in HARMONY-5304 that GC behavior is hardly depends on atomics implementation.
>
> I gontinued playing with atomics. I corrected port_atomic_cas* functions for linux and implemented cas32, and replaced all apr_atomic_cas* in GC_GEN with port_atomic_cas* calls. This did not help with this bug - the hand still appeared.
>
> Then I corrected several places in GC_GEN where atomic_cas* were used, and test does not hang now.
> Probably this patch can lead to hangups in other tests/suites because of some places where atomics are still used incorrectly.
>
> The patch I've got is in attachment.
> It is not complete yet - I did not correct Windows atomics in PORT, so the patch is for Linux only.
>
> I'm going to correct Windows implementation too, and probably get rid of APR atomics at all. It will involve atomic_inc, atomic_dec etc.
>
> BTW, these changes for Linux should improve atomics performance, because in current environment APR atomics compiled into unefficient code with MOVs under mutex.
>
> > [drlvm] vm.classloading.ClassCastTest hangs
> > -------------------------------------------
> >
> > Key: HARMONY-5395
> > URL: https://issues.apache.org/jira/browse/HARMONY-5395
> > Project: Harmony
> > Issue Type: Bug
> > Components: DRLVM
> > Environment: revision 612006 release mode
> > Linux x86_64
> > Reporter: Andrey Yakushev
> > Attachments: atomics.patch
>
> >
> >
> > [drlvm] vm.classloading.ClassCastTest stably hangs on first iteration
>
> --
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
>
>
--
http://xiao-feng.blogspot.com
Re: [jira] Updated: (HARMONY-5395) [drlvm] vm.classloading.ClassCastTest hangs
Posted by Xiao-Feng Li <xi...@gmail.com>.
Ilya, I am afraid you don't really understand atomic operation
semantics. You patch is largely wrong. Please don't play around with
atomic operations blindly unless you really understand what you are
doing.
Thanks,
xiaofeng
On Jan 20, 2008 7:24 AM, Ilya Berezhniuk (JIRA) <ji...@apache.org> wrote:
>
> [ https://issues.apache.org/jira/browse/HARMONY-5395?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
>
> Ilya Berezhniuk updated HARMONY-5395:
> -------------------------------------
>
> Attachment: atomics.patch
>
> I've found in HARMONY-5304 that GC behavior is hardly depends on atomics implementation.
>
> I gontinued playing with atomics. I corrected port_atomic_cas* functions for linux and implemented cas32, and replaced all apr_atomic_cas* in GC_GEN with port_atomic_cas* calls. This did not help with this bug - the hand still appeared.
>
> Then I corrected several places in GC_GEN where atomic_cas* were used, and test does not hang now.
> Probably this patch can lead to hangups in other tests/suites because of some places where atomics are still used incorrectly.
>
> The patch I've got is in attachment.
> It is not complete yet - I did not correct Windows atomics in PORT, so the patch is for Linux only.
>
> I'm going to correct Windows implementation too, and probably get rid of APR atomics at all. It will involve atomic_inc, atomic_dec etc.
>
> BTW, these changes for Linux should improve atomics performance, because in current environment APR atomics compiled into unefficient code with MOVs under mutex.
>
> > [drlvm] vm.classloading.ClassCastTest hangs
> > -------------------------------------------
> >
> > Key: HARMONY-5395
> > URL: https://issues.apache.org/jira/browse/HARMONY-5395
> > Project: Harmony
> > Issue Type: Bug
> > Components: DRLVM
> > Environment: revision 612006 release mode
> > Linux x86_64
> > Reporter: Andrey Yakushev
> > Attachments: atomics.patch
>
> >
> >
> > [drlvm] vm.classloading.ClassCastTest stably hangs on first iteration
>
> --
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
>
>
--
http://xiao-feng.blogspot.com
[jira] Commented: (HARMONY-5395) [drlvm]
vm.classloading.ClassCastTest hangs
Posted by "Xiao-Feng Li (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-5395?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12560766#action_12560766 ]
Xiao-Feng Li commented on HARMONY-5395:
---------------------------------------
Ilya, I am afraid you don't really understand atomic operation
semantics. You patch is largely wrong. Please don't play around with
atomic operations blindly unless you really understand what you are
doing.
Thanks,
xiaofeng
--
http://xiao-feng.blogspot.com
> [drlvm] vm.classloading.ClassCastTest hangs
> -------------------------------------------
>
> Key: HARMONY-5395
> URL: https://issues.apache.org/jira/browse/HARMONY-5395
> Project: Harmony
> Issue Type: Bug
> Components: DRLVM
> Environment: revision 612006 release mode
> Linux x86_64
> Reporter: Andrey Yakushev
> Attachments: atomics.patch
>
>
> [drlvm] vm.classloading.ClassCastTest stably hangs on first iteration
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (HARMONY-5395) [drlvm][Linux64 gcc bug]
vm.classloading.ClassCastTest hangs
Posted by "Xiao-Feng Li (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-5395?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Xiao-Feng Li updated HARMONY-5395:
----------------------------------
Issue Type: Sub-task (was: Bug)
Parent: HARMONY-5416
> [drlvm][Linux64 gcc bug] vm.classloading.ClassCastTest hangs
> ------------------------------------------------------------
>
> Key: HARMONY-5395
> URL: https://issues.apache.org/jira/browse/HARMONY-5395
> Project: Harmony
> Issue Type: Sub-task
> Components: DRLVM
> Environment: revision 612006 release mode
> Linux x86_64
> Reporter: Andrey Yakushev
> Attachments: atomics.patch
>
>
> Update: this is a Linux64 gcc bug. Related issues grouped to HARMONY-5416.
> =====================
> [drlvm] vm.classloading.ClassCastTest stably hangs on first iteration
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (HARMONY-5395) [drlvm]
vm.classloading.ClassCastTest hangs
Posted by "Ilya Berezhniuk (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-5395?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ilya Berezhniuk updated HARMONY-5395:
-------------------------------------
Attachment: atomics.patch
I've found in HARMONY-5304 that GC behavior is hardly depends on atomics implementation.
I gontinued playing with atomics. I corrected port_atomic_cas* functions for linux and implemented cas32, and replaced all apr_atomic_cas* in GC_GEN with port_atomic_cas* calls. This did not help with this bug - the hand still appeared.
Then I corrected several places in GC_GEN where atomic_cas* were used, and test does not hang now.
Probably this patch can lead to hangups in other tests/suites because of some places where atomics are still used incorrectly.
The patch I've got is in attachment.
It is not complete yet - I did not correct Windows atomics in PORT, so the patch is for Linux only.
I'm going to correct Windows implementation too, and probably get rid of APR atomics at all. It will involve atomic_inc, atomic_dec etc.
BTW, these changes for Linux should improve atomics performance, because in current environment APR atomics compiled into unefficient code with MOVs under mutex.
> [drlvm] vm.classloading.ClassCastTest hangs
> -------------------------------------------
>
> Key: HARMONY-5395
> URL: https://issues.apache.org/jira/browse/HARMONY-5395
> Project: Harmony
> Issue Type: Bug
> Components: DRLVM
> Environment: revision 612006 release mode
> Linux x86_64
> Reporter: Andrey Yakushev
> Attachments: atomics.patch
>
>
> [drlvm] vm.classloading.ClassCastTest stably hangs on first iteration
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (HARMONY-5395) [drlvm]
vm.classloading.ClassCastTest hangs
Posted by "Andrey Yakushev (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-5395?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Andrey Yakushev updated HARMONY-5395:
-------------------------------------
Environment:
revision 612006 release mode
Linux x86_64
was:
revision 612006
Linux x86_64
> [drlvm] vm.classloading.ClassCastTest hangs
> -------------------------------------------
>
> Key: HARMONY-5395
> URL: https://issues.apache.org/jira/browse/HARMONY-5395
> Project: Harmony
> Issue Type: Bug
> Components: DRLVM
> Environment: revision 612006 release mode
> Linux x86_64
> Reporter: Andrey Yakushev
>
> [drlvm] vm.classloading.ClassCastTest stably hangs on first iteration
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (HARMONY-5395) [drlvm][Linux64 gcc bug]
vm.classloading.ClassCastTest hangs
Posted by "Chunrong Lai (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-5395?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12561938#action_12561938 ]
Chunrong Lai commented on HARMONY-5395:
---------------------------------------
I'd also like to share some code examples we did to workaround Linux64 GCC bugs.
They are basically same style (value of)(pointer type cast)(taken address of variable)
(1) Problematic code: *(int*) &hashcode = hashcode_gen(p_obj);
Updated code: hashcode = (POINTER_SIZE_INT)hashcode_gen(p_obj);
(2) Problematic code: Partial_Reveal_Object *cur_obj = *(Partial_Reveal_Object **)start_pos;
//statement is in an inlined function where start_pos is passed in as (&new_object)
Updated code: Partial_Reveal_Object *cur_obj = (Partial_Reveal_Object *)(*start_pos);
(3) Problematic code: Stack_Top new_top = *(Stack_Top*)&temp;
temp = (POINTER_SIZE_INT)atomic_casptr((volatile void**)&stack->top, *(void**)&new_top, *(void**)&cur_top);
Updated code: temp = (POINTER_SIZE_INT)atomic_casptr((volatile void**)&stack->top, (void*)temp, (void*)cur_top);
> [drlvm][Linux64 gcc bug] vm.classloading.ClassCastTest hangs
> ------------------------------------------------------------
>
> Key: HARMONY-5395
> URL: https://issues.apache.org/jira/browse/HARMONY-5395
> Project: Harmony
> Issue Type: Sub-task
> Components: DRLVM
> Environment: revision 612006 release mode
> Linux x86_64
> Reporter: Andrey Yakushev
> Attachments: atomics.patch
>
>
> Update: this is a Linux64 gcc bug. Related issues grouped to HARMONY-5416.
> =====================
> [drlvm] vm.classloading.ClassCastTest stably hangs on first iteration
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (HARMONY-5395) [drlvm]
vm.classloading.ClassCastTest hangs
Posted by "Xiao-Feng Li (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-5395?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12560770#action_12560770 ]
Xiao-Feng Li commented on HARMONY-5395:
---------------------------------------
More suggestions:
1. Please check if it's APR implementation problem. If it is, please write a correct version of atomic implementation, and put into atomics header file for all Harmony code to use.
2. Please don't consider performance issue before you can make it correct.
Thanks.
> [drlvm] vm.classloading.ClassCastTest hangs
> -------------------------------------------
>
> Key: HARMONY-5395
> URL: https://issues.apache.org/jira/browse/HARMONY-5395
> Project: Harmony
> Issue Type: Bug
> Components: DRLVM
> Environment: revision 612006 release mode
> Linux x86_64
> Reporter: Andrey Yakushev
> Attachments: atomics.patch
>
>
> [drlvm] vm.classloading.ClassCastTest stably hangs on first iteration
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (HARMONY-5395) [drlvm]
vm.classloading.ClassCastTest hangs
Posted by "Xiao-Feng Li (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-5395?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12560914#action_12560914 ]
Xiao-Feng Li commented on HARMONY-5395:
---------------------------------------
||- 1) Change from APR CAS* operations to PORT atomics.
||- Now APR atomics are not atomics at all. APR sources contain several implementations for CAS*, and in our environment worse case is compiled.
||- However, replacing APR atomics with (corrected) PORT atomics does not fix the problem. So I guess the problem is not in APR.
In this case, you can have a separate JIRA with a patch, suggesting to remove APR atomics in Harmony at all. Any occurrence could lead to problem if not cleaned up completely.
||- 2) When I've simply replaced APR atomics with current PORT atomics, GC started to hang right in gc_metadata_initialize (specifically in sync_stack_push).
||- I've carefully inspected disassembly for these functions and found that PORT atomics are inlined incorrectly because of some problems in PORT atomics implementation.
||- That's why I've corrected PORT atomics.
In this case, please do as what I suggested above, and with correct PORT atomics implementations in your patch. But please comment accurately in your patch if the issue comes from gcc 64bit bug or it is really PORT implementation bug. If it's gcc bug, better to keep the original version as well, but use #ifdef for workaround version for gcc. At least we should put some comments there to explain.
||- 3) The changes in GC were made to ensure that 'new' value read from memory _after_ CAS* operation is actually new.
||- Using the value returned by CAS* function garantees that, while second simple read from the same address is less reliable.
||- All the changes in GC are in this direction.
You should check if all the variables are defined as volatile. If the variable is defined as volatile, then it should be always read from memory. If gcc 64bit can't compile into correct version, that's a serious problem of gcc, so I really doubt it.
> [drlvm] vm.classloading.ClassCastTest hangs
> -------------------------------------------
>
> Key: HARMONY-5395
> URL: https://issues.apache.org/jira/browse/HARMONY-5395
> Project: Harmony
> Issue Type: Bug
> Components: DRLVM
> Environment: revision 612006 release mode
> Linux x86_64
> Reporter: Andrey Yakushev
> Attachments: atomics.patch
>
>
> [drlvm] vm.classloading.ClassCastTest stably hangs on first iteration
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (HARMONY-5395) [drlvm][Linux64 gcc bug]
vm.classloading.ClassCastTest hangs
Posted by "Xiao-Feng Li (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-5395?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Xiao-Feng Li updated HARMONY-5395:
----------------------------------
Summary: [drlvm][Linux64 gcc bug] vm.classloading.ClassCastTest hangs (was: [drlvm] vm.classloading.ClassCastTest hangs)
> [drlvm][Linux64 gcc bug] vm.classloading.ClassCastTest hangs
> ------------------------------------------------------------
>
> Key: HARMONY-5395
> URL: https://issues.apache.org/jira/browse/HARMONY-5395
> Project: Harmony
> Issue Type: Bug
> Components: DRLVM
> Environment: revision 612006 release mode
> Linux x86_64
> Reporter: Andrey Yakushev
> Attachments: atomics.patch
>
>
> [drlvm] vm.classloading.ClassCastTest stably hangs on first iteration
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (HARMONY-5395) [drlvm]
vm.classloading.ClassCastTest hangs
Posted by "Ilya Berezhniuk (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-5395?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12560874#action_12560874 ]
Ilya Berezhniuk commented on HARMONY-5395:
------------------------------------------
Xiao-Feng,
Thanks for your comments.
Did you mean that GC part of the patch is incorrect, or some other parts too?
Aniway, let me clarify major changes from this patch.
1) Change from APR CAS* operations to PORT atomics.
Now APR atomics are not atomics at all. APR sources contain several implementations for CAS*, and in our environment worse case is compiled.
However, replacing APR atomics with (corrected) PORT atomics does not fix the problem. So I guess the problem is not in APR.
2) When I've simply replaced APR atomics with current PORT atomics, GC started to hang right in gc_metadata_initialize (specifically in sync_stack_push).
I've carefully inspected disassembly for these functions and found that PORT atomics are inlined incorrectly because of some problems in PORT atomics implementation.
That's why I've corrected PORT atomics.
3) The changes in GC were made to ensure that 'new' value read from memory _after_ CAS* operation is actually new.
Using the value returned by CAS* function garantees that, while second simple read from the same address is less reliable.
All the changes in GC are in this direction.
This part of the patch in least evident, but without these changes the test still hangs.
Of course, not all GC changes are needed. I'll try to find specific change in GC which cures the test.
> [drlvm] vm.classloading.ClassCastTest hangs
> -------------------------------------------
>
> Key: HARMONY-5395
> URL: https://issues.apache.org/jira/browse/HARMONY-5395
> Project: Harmony
> Issue Type: Bug
> Components: DRLVM
> Environment: revision 612006 release mode
> Linux x86_64
> Reporter: Andrey Yakushev
> Attachments: atomics.patch
>
>
> [drlvm] vm.classloading.ClassCastTest stably hangs on first iteration
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (HARMONY-5395) [drlvm]
vm.classloading.ClassCastTest hangs
Posted by "Xiao-Feng Li (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-5395?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12561022#action_12561022 ]
Xiao-Feng Li commented on HARMONY-5395:
---------------------------------------
Btw, Ilya, since we found Linux64 gcc compiler indeed has various bugs, you probably can dig out one case of atomic operation by understanding if its generated assembly really has wrong instructions, if that helps.
For your reference, some known wrong instructions generated by Linux64 gcc are related to local variable processing. That is, if a local variable is taken its address, gcc probably will not able to deal with it correctly. For example:
foo(){
int a = 0;
tar( &a);
//a might still be 0 without taking back the value assigned in tar().
char b = 'c';
*(char*)(&a) = b;
//a might still be 0.
}
If this is the case, some address-taken operations in atomic operation might have wrongly generated code.
This is bad to deal with a buggy compiler. It's not really bad to have a buggy compiler, but it's bad to have such kind of naiive bug in it. Hope this could help your debugging.
> [drlvm] vm.classloading.ClassCastTest hangs
> -------------------------------------------
>
> Key: HARMONY-5395
> URL: https://issues.apache.org/jira/browse/HARMONY-5395
> Project: Harmony
> Issue Type: Bug
> Components: DRLVM
> Environment: revision 612006 release mode
> Linux x86_64
> Reporter: Andrey Yakushev
> Attachments: atomics.patch
>
>
> [drlvm] vm.classloading.ClassCastTest stably hangs on first iteration
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (HARMONY-5395) [drlvm][Linux64 gcc bug]
vm.classloading.ClassCastTest hangs
Posted by "Xiao-Feng Li (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-5395?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Xiao-Feng Li updated HARMONY-5395:
----------------------------------
Description:
Update: this is a Linux64 gcc bug. Related issues grouped to HARMONY-5416.
=====================
[drlvm] vm.classloading.ClassCastTest stably hangs on first iteration
was:[drlvm] vm.classloading.ClassCastTest stably hangs on first iteration
> [drlvm][Linux64 gcc bug] vm.classloading.ClassCastTest hangs
> ------------------------------------------------------------
>
> Key: HARMONY-5395
> URL: https://issues.apache.org/jira/browse/HARMONY-5395
> Project: Harmony
> Issue Type: Bug
> Components: DRLVM
> Environment: revision 612006 release mode
> Linux x86_64
> Reporter: Andrey Yakushev
> Attachments: atomics.patch
>
>
> Update: this is a Linux64 gcc bug. Related issues grouped to HARMONY-5416.
> =====================
> [drlvm] vm.classloading.ClassCastTest stably hangs on first iteration
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.