Fix crash due to bad shift in indirect addressing mode on aarch64 (fixes #302) #303
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is fix for #302. The problem is that on aarch64, indirect loads and stores can accept and index and a shift, but the shift has to correspond to the size of the load/store operation (e.g. shift==2 for 32-bit operations and shift==3 for 64-bit operations). Usage of
sun.misc.Unsafe
can lead to address expressions which violate this requirement. They might for example request a shift of "1" for a 32-bit operation. In the release build, the generated code will nevertheless perform a 2-bit shift in such a situation which can lead to arbitrary crashes at a later time. In a debug build, the problem will be detected by the following assertion:Notice that this issue was resolved by a larger change in jdk9 (JDK-8154826: AArch64: take better advantage of base + shifted offset addressing mode) which completely reworked complex addressing modes.
This change only fixes the current issue in jdk8 by checking the shift amount against the size of the memory operation in the Matcher and rejects address modes where they don't conform.