fix: avoid unsafe UTF-16 fast paths on aarch64 JDK 8 - #7852
Open
xuzhaorui wants to merge 1 commit into
Open
Conversation
|
xuzhaorui seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What this PR does / why we need it?
On AArch64 with Oracle JDK 8, C2 can miscompile unaligned
Unsafeaccesses used by the UTF-16 parsing and writing fast paths. This can make repeated parsing offalseproduce an incorrect value and can corrupt repeated UTF-16 string serialization.This change disables only the affected fast paths on that runtime and keeps the existing optimized paths for other environments.
Summary of your change
AARCH64_JDK8runtime detection for JDK 8 AArch64, excluding Android, GraalVM, and OpenJ9.IOUtils.isALSE(char[])andnotALSE(char[])on the affected runtime.Related: #7834. This PR focuses on the boolean parsing and UTF-16 string serialization paths reported in #7838; it does not change the other Unsafe access sites covered by #7834.
本地环境为 x86_64 + JDK 17,无法直接复现 AArch64 + JDK 8 的 C2 错误;因此回归测试在当前环境验证行为不回退,目标平台上的安全分支由运行时检测启用。
Validation:
./mvnw -pl core test— 7990 tests passed../mvnw -pl core -Dfastjson2.creator=reflect -Dtest=Issue7838Test test— 2 tests passed../mvnw -pl core -Dtest=Issue7838Test test— 2 tests passed../mvnw -pl core validate— passed with 0 Checkstyle violations.No documentation changes are needed.
Please indicate you've done the following: