RFR: JDK-8294902: Undefined Behavior in C2 regalloc with null references [v6]

Andrew Haley aph at openjdk.org
Mon Dec 5 11:40:05 UTC 2022


On Sun, 4 Dec 2022 15:08:43 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

> > Just noticed this PR, and have only skimmed through it. I have an idea for an alternative way to write `offset_of` that I _think_ might be better. I'm going to try it out and report back. That doesn't have to hold you up if you want to proceed.
> 
> That idea for an alternative `offset_of` implementation didn't pan out. And I wasn't able to make disabling the `-Winvalid-offsetof` warning within that macro work. But now I'm wondering why it is being changed? If I take your changes except backout the `offset_of` change, and build with `-fsanitize=null` (for now by co-opting the `--enable-asan` config option, since there's more to it than just adding that option to `--with-extra-cxxflags`), that works (with gcc11.3). So what is the `offset_of` change about?

I saw the warning trigger, or I wouldn't have known that there was any problem. I've been using gcc HEAD to try to get the fullest set of warnings.

I'm pretty sure that

`(size_t)((intx)&(((klass*)16)->field) - 16)`

is no more well defined than

`(size_t)((intx)&(((klass*)0)->field))`

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

PR: https://git.openjdk.org/jdk/pull/10920


More information about the hotspot-dev mailing list