[K42-discussion] race condition in clustered object call on unoptimized build
Bryan S Rosenburg
rosnbrg at us.ibm.com
Fri Feb 17 11:28:53 EST 2006
Raymond Fingas <fingas at eecg.toronto.edu> wrote on 02/16/2006 01:46:13 PM:
> David said that you wanted to see an example of the problem. This is a
> simple example with commented assembly output provided:
>
> uval badgcc(NullObject** no){
> return DREF(no)->Function();
> }
Thanks, Raymond. It doesn't get any simpler than that.
> Our GCC version is:
>
> powerpc-linux-g++ (GCC) 3.3.3 20031029 (prerelease)
I've verified that this version of the compiler (I haven't tried any other
versions), when presented with:
(expression)->Function();
will evaluate (expression) twice no matter how complicated it is, as long
as it doesn't have side effects. I still find this behavior surprising,
but that's what it is.
The good news is that our DREF bug is easily fixed with a strategic
"volatile" attribute. No inline asm required. I'm changing the
definition of DREF in lib/libc/cobj/ObjectRefs.H to:
#define DREF(OBJ) (*((typeof(**OBJ) * volatile *)(OBJ)))
Would you please verify that that fixes the problems you discovered?
Thanks again for tracking this problem down.
- Bryan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://ozlabs.org/pipermail/k42-discussion/attachments/20060216/2abd8f45/attachment.htm
More information about the K42-discussion
mailing list