RFR: 8341178: TypeRawPtr::add_offset may be "miscompiled" due to UB [v2]

Kim Barrett kbarrett at openjdk.org
Wed Oct 9 14:57:38 UTC 2024


On Tue, 8 Oct 2024 18:32:54 GMT, Dean Long <dlong at openjdk.org> wrote:

>> Oh, you are right. And TypeRawPtr::make asserts the PTR is neither Constant nor Null. Which makes
>> both switch cases under modification here supposedly unreachable. That would explain why I never hit
>> either after running lots of tests. All of the change proposed here can be eliminated, and instead change
>> both cases to fall through to the default ShouldNotReachHere(). (And that would be another way to
>> remove the -Wzero-as-null-pointer-constant warning that was how I got here in the first place. :) )
>
> There's TypeRawPtr::make(enum PTR ptr) which doesn't allow Constant or Null, but we are using TypeRawPtr::make(address bits) here.
> We may need to keep the Constant case.  I wouldn't be surprised if there was a way to trigger that path using Unsafe.

Yeah, keeping it makes sense.  I've removed the TypePtr::Null case, allowing that one to default to
ShuoldNotReachHere().

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/21324#discussion_r1793675908


More information about the hotspot-compiler-dev mailing list