RFR: 8311648: Refactor the Arena/Chunk/ChunkPool interface [v7]
Thomas Stuefe
stuefe at openjdk.org
Wed Aug 9 07:41:59 UTC 2023
On Wed, 9 Aug 2023 07:00:13 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:
> Hi Johan,
>
> > Hi,
> > @tstuefe , @coleenp, I found the bug. The issue was that `Chunk::operator new` would implicitly call the constructor of `Chunk` and thus overwrite previous content of chunks taken from the pool. I forgot to call the constructor for chunks taken from the pool. I've rewritten `allocate_chunk` so that there are two allocation branches that both end with the constructor being called via placement new.
>
> I don't get this :-)
>
> What new call are you talking about? And in the current version, why should a constructor call be necessary if all we do is handing an existing - already initialized - chunk from and to the pool? Yes, it still carries _next from the pool, but that is soon to be overwritten when the Arena adds that chunk to its list (although setting _next to NULL in debug deliberately can't hurt).
Ah, I think I get it. I believe the real error is that when adding a chunk to the end of the Arena linked list, old code did not NULL-terminate the list since it relied on the Chunk being freshly initialized. IMHO, a slightly more robust and standard solution would be to explicitly NULL-terminate the list on add.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/14803#issuecomment-1670797155
More information about the hotspot-runtime-dev
mailing list