RFR: 8300079: SIGSEGV in LibraryCallKit::inline_string_copy due to constant NULL src argument

Tobias Hartmann thartmann at openjdk.org
Fri Jan 20 12:14:15 UTC 2023


The `StringUTF16.compress` variant of `LibraryCallKit::inline_string_copy` does not properly handle a constant null `src` argument that can happen when the `char[] data` argument of `String::copyValueOf` is null:

https://github.com/openjdk/jdk/blob/7bf0d1465e73d83aae30f1cd9fd318af9e9c1b70/src/java.base/share/classes/java/lang/String.java#L4284-L4285 ->
https://github.com/openjdk/jdk/blob/7bf0d1465e73d83aae30f1cd9fd318af9e9c1b70/src/java.base/share/classes/java/lang/String.java#L301-L302 ->
https://github.com/openjdk/jdk/blob/7bf0d1465e73d83aae30f1cd9fd318af9e9c1b70/src/java.base/share/classes/java/lang/String.java#L4504-L4511

Although the intrinsified code is never executed because we throw a `NullPointerException` from (non-inlined) `rangeCheck`, we need to make sure a constant null is properly handled.

I manually inspected similar C2 intrinsics and found another potential issue in `LibraryCallKit::inline_mulAdd` where we should call `must_be_not_null` on `in` as well (even if it might not be possible with current code, let's better be safe than sorry).

All the other changes are simple refactorings for better readability.

Thanks,
Tobias

-------------

Commit messages:
 - Fixed wrong Value call
 - Fixed wrong refactoring
 - Enabled fix
 - Removed whitespace
 - 8300079: SIGSEGV in LibraryCallKit::inline_string_copy due to constant NULL src argument

Changes: https://git.openjdk.org/jdk/pull/12112/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=12112&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8300079
  Stats: 186 lines in 2 files changed: 62 ins; 32 del; 92 mod
  Patch: https://git.openjdk.org/jdk/pull/12112.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/12112/head:pull/12112

PR: https://git.openjdk.org/jdk/pull/12112


More information about the hotspot-compiler-dev mailing list