JDK-8167200 : AArch64: Broken stack pointer adjustment in interpreter
Type:Bug
Component:hotspot
Sub-Component:runtime
Priority:P4
Status:Resolved
Resolution:Fixed
CPU:aarch64
Submitted:2016-10-05
Updated:2021-02-01
Resolved:2016-10-06
The Version table provides details related to the release that this issue/RFE will be addressed.
Unresolved : Release in which this issue/RFE will be addressed. Resolved: Release in which this issue/RFE has been resolved. Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.
This is a thinko in the template interpreter.
AArch64 has two stack pointers: the system SP and the expression SP. The expression SP must always point to an address greater than or equal to the system SP.
When we allocate a new monitor in the interpreter we move the contents of the entire operand stack and then insert a monitor beneath the operand stack. So, we need two more words (the size of a monitor). The expression SP is adjusted to allow for this, and we then do a comparison to see if the system SP needs also to be moved. This is wrong: whenever we allocate a monitor we should also adjust the system SP. The bug here is that we might decide not to allow any more space in the system stack but later push several items onto the expression stack. In this case the expression SP might be lower than the system SP, and method arguments are corrupted.
The attached test case demonstrates this with a spurious NullPointerException or perhaps a VM crash with a segfault.