-
Bug
-
Resolution: Fixed
-
P4
-
17, 20
-
b21
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8321966 | 17.0.11 | Aleksey Shipilev | P4 | Resolved | Fixed | b01 |
For all platforms, Atomic::PlatformAdd implements one of fetch_and_add and add_and_fetch in terms of the other, adding or subtracting (as appropriate) the result of the other operation and the addend.
That's incorrect when the destination type is a pointer type. When the destination type is a pointer type, AddImpl scales the addend by the size of the pointee type, and passes that scaled value to the platform layer. (This is described in the comment documenting PlatformAdd.) If the pointee type has size > 1, this will double-scale the addend.
Fortunately, at this time there are no uses of Atomic add operations with a pointer type whose pointee type's size > 1.
That's incorrect when the destination type is a pointer type. When the destination type is a pointer type, AddImpl scales the addend by the size of the pointee type, and passes that scaled value to the platform layer. (This is described in the comment documenting PlatformAdd.) If the pointee type has size > 1, this will double-scale the addend.
Fortunately, at this time there are no uses of Atomic add operations with a pointer type whose pointee type's size > 1.
- backported by
-
JDK-8321966 Atomic::add to pointer type may return wrong value
- Resolved