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

Andrew Haley aph at openjdk.org
Mon Dec 12 14:01:01 UTC 2022


On Mon, 12 Dec 2022 12:47:12 GMT, Andrew Haley <aph at openjdk.org> wrote:

>> This patch fixes the remaining null pointer dereference bugs that I know of.
>> 
>> For the main bug, C2 was using a null reference to indicate an uninitialized `Node_List`. I replaced the null reference with a static sentinel.
>> 
>> I also turned on `-fsanitize=null` and found and fixed a bunch of other null pointer dereferences. With this,I have run a full bootstrap and tier1 tests with `-fsanitize=null` enabled.
>> 
>> I have checked that the code generated by GCC is not worse in any significant way, so I don't expect to see any performance regressions.
>> 
>> I'd like to enable `-fsanitize=null` in debug builds to prevent regressions in this area. What do you think?
>
> Andrew Haley has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Align temp buffer used by offset_of().

src/hotspot/share/utilities/globalDefinitions_gcc.hpp line 151:

> 149: #define offset_of(klass,field)                          \
> 150: []() {                                                  \
> 151:   char space[sizeof (klass)] ATTRIBUTE_ALIGNED(16);     \

So I aligned this, and it constant folds everything nicely.
I have a nagging worry in the back of my mind that on some platforms this might be over-aligned, which would be another instancde of unspecified behaviour, but i don't think we have any supported targets where this might be a problem.

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

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


More information about the hotspot-dev mailing list