RFR: JDK-8270308: Amalloc aligns size but not return value (take 2) [v4]

Thomas Stuefe stuefe at openjdk.java.net
Sun Jul 25 05:27:13 UTC 2021


On Sat, 24 Jul 2021 20:50:37 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

> This looks much better. But I think you missed a place.
> 
> If AmallocWords is called with a non-64bit-aligned value (it could be only 32bit aligned on a 32bit platform), and it calls grow(), grow will call the chunk allocator with that length, which fails the precondition because it's not BytesPerLong aligned. I think grow() needs to call ARENA_ALIGN on the length on 32bit platforms.

You are right. I even spelled it out in my last comment, but then did not fix it.

I added a test, saw that it fires on 32-bit, then fixed Arena::grow(). I also limited all new tests to 32-bit to save some cycles on 64-bit.

One remaining worry I have is that when mixing Amalloc and AmallocWords now we align correctly, that is fine. But if the Arena cannot handle gaps - e.g. HandleArea - difficult to analyze crashes can happen on 32-bit. The original cause would be that the author mixes Amalloc and AmallocWords for an Arena where he should stick to one alignment only.

My first patch filled alignment gaps in debug with a pattern, to trip off the analyzer. What do you think, should I do this here too?

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

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


More information about the hotspot-dev mailing list