RFR: 8258382: Fix optimization-unstable code involving pointer overflow

Hao Sun github.com+16932759+shqking at openjdk.java.net
Fri Dec 25 04:10:58 UTC 2020


On Thu, 24 Dec 2020 17:59:42 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

>> Optimization-unstable code refers to code that is unexpectedly discarded
>> by compiler optimizations due to undefined behavior in the program.
>> 
>> We applied a static checker called STACK (prototype from SOSP'13 paper
>> [1]) to OpenJDK source code and found the following eight sites of
>> potential unstable code.
>> 
>> Removing undefined behaviors would make the code stable.
>> 
>> [1] https://css.csail.mit.edu/stack/
>> 
>> --------
>> Note that we tested locally Jtreg tests ( tier1 and jdk::tier3) were passed on Linux x86/aarch64 machines after apply this patch.
>
> Changes requested by kbarrett (Reviewer).

> I think there are somewhere between two and four distinct issues here
> that should be dealt with in separate bugs and PRs (the number depends
> on how the compiler folks might like things done). Their only relation
> is that all were detected by the STACK tool. But they are in very
> different parts of the code and probably ought to be reviewed by folks
> from different teams.

Thanks for your suggestion. 
I will put the other 6 issues involving signed integer overflow into another PR (https://bugs.openjdk.java.net/browse/JDK-8258946), and continue to use this PR to fix the pointer overflow checks.

> src/hotspot/share/gc/parallel/psPromotionLAB.hpp line 121:
> 
>> 119:     assert(_start_array != NULL, "Sanity");
>> 120:     HeapWord* obj = top();
>> 121:     // Pointer overflow check is needed here.
> 
> The comment mentions pointer overflow checking, but that's not what's
> being checked for anymore.  It's just checking whether there is space
> for the desired object.  It's just that the check is now being done
> safely and correctly, where it wasn't before, but that's not interesting.
> I don't think any comment is needed anymore; the updated code (with
> my other suggestions) is obvious.

Will remove in next revision. Thanks.

> src/hotspot/share/gc/parallel/psPromotionLAB.inline.hpp line 37:
> 
>> 35:   HeapWord* obj = top();
>> 36:   // Pointer overflow check is needed here.
>> 37:   if (end() >= obj && size <= (size_t)(end() - obj)) {
> 
> Same suggestions here as for the corresponding changes to the .hpp file.

Got it. Thanks.

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

PR: https://git.openjdk.java.net/jdk/pull/1886


More information about the hotspot-dev mailing list