-
Notifications
You must be signed in to change notification settings - Fork 729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix erroneously large section size in ROM walk #18585
Conversation
If a ROM class has no methods, the CP NAS section should have size zero. Before, the section size would be calculated unconditionally based on the location of the J9ROMCLASS_ROMMETHODS of the ROM class. When the romMethods field is a null SRP, that would result in a negative pointer difference that would then wrap to a very large U_32 value. Signed-off-by: Christian Despres
Attn @mpirvu. I'm reasonably sure, but not totally confident, that the CP NAS section should have size zero when there are no ROM methods in a ROM class. |
count = (U_32)(((UDATA)firstMethod - (UDATA)srpCursor) / (sizeof(J9SRP) * 2)); | ||
} else { | ||
count = 0; | ||
} | ||
rangeValid = callbacks->validateRangeCallback(romClass, srpCursor, count * sizeof(J9SRP) * 2, userData); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most callbacks in this section of the walk still visit a section even if it's empty, so I kept that behaviour here. The one exception is the walk nest members SRPs
block immediately above this one, which doesn't walk the nest member SRP block if it has a zero count.
Arguably it makes more sense to skip sections that are empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For instance, this block
visits the enclosed inner classes SRP block even if it's empty, which has the odd consequence that the srpCursor
for that section will point to the enclosedInnerClasses
field of the ROM class, and not past the J9ROMClass
header section like you might expect. That's because J9ROMCLASS_ENCLOSEDINNERCLASSES
will return a pointer to enclosedInnerClasses
when that field is zero. I don't think this ever messes anything up, but its an odd behaviour to have.
Just to be explicit about the problem: when |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but I am not an expert in this area.
@TobiAjila Could you please review or delegate? Thanks
@cjjdespres Which tests showed erroneously large section size in ROM walk? |
jenkins test sanity.functional,sanity.openjdk plinux jdk21 |
I noticed the problem while I was testing the code that revealed #18568. I'm not aware of existing failing tests. |
|
If a ROM class has no methods, the CP NAS section should have size zero. Before, the section size would be calculated unconditionally based on the location of the
J9ROMCLASS_ROMMETHODS
of the ROM class. When theromMethods
field is a null SRP, that would result in a negative pointer difference that would then wrap to a very largeU_32
value.Signed-off-by: Christian Despres