RFR: 8359200: Memory corruption in MStack::push [v2]

Tobias Hartmann thartmann at openjdk.org
Thu Jun 12 11:41:54 UTC 2025


On Wed, 11 Jun 2025 19:18:34 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

>> src/hotspot/share/opto/block.cpp line 41:
>> 
>>> 39: 
>>> 40: void Block_Array::grow(uint i) {
>>> 41:   assert(i >= Max(), "must be an overflow");
>> 
>> Assert message here is misleading: it is more likely someone had called `grow` when they intended `maybe_grow`. See how it is done elsewhere:
>> 
>> 
>> void Node_Array::grow(uint i) {
>>   _nesting.check(_a); // Check if a potential reallocation in the arena is safe
>>   assert(i >= _max, "Should have been checked before, use maybe_grow?");
>
> Speaking of, we should probably move `_nesting.check(_a);` to `Node_Array::maybe_grow` as well.

>  Assert message here is misleading

Yes, good point. I had basically reverted to before [JDK-8336999](https://bugs.openjdk.org/browse/JDK-8336999) but your assert message is better. Fixed.

> Speaking of, we should probably move _nesting.check(_a); to Node_Array::maybe_grow as well.

Right, I did that already. See changes in `src/hotspot/share/opto/node.hpp`.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25751#discussion_r2142481527


More information about the hotspot-dev mailing list