Add bound checking to accelerated intrinsics#23937
Conversation
19bbb96 to
b2e97b6
Compare
|
After recognizedCallTransformer: Block 2 is split into Block 2 and 3. A check is added at the end of block 2 to make sure the input array is big enough for the inflate operation. If so, the check in block 6 checks the length of the output array. If that is also good, the fast path version of inflate is called in block 5. If either check fails, it jumps to block 4. Block 4 is the slow path and stays as a call out until the very end. This path should only be taken if the AbstractStringBuilder race condition is hit and messes up the array sizes. |
|
After recognizedCallTransformer: This is somewhat similar to how
|
|
The bulk of this change are common changes. But, there are some small codegen changes affecting Power, X, Z and Arm. So I need to tag a bunch of people here. @hzongaro Can you take a look at the Common/X changes? |
zl-wang
left a comment
There was a problem hiding this comment.
High-level comment: directly adding BNDChk node vs. waiting for slowPath getting to it eventually. which one is better? maybe there are difficulties in creating the exception range(s) for the metaData?
| TR::Compilation *comp = cg->comp(); | ||
| TR::MethodSymbol *methodSymbol = node->getSymbol()->getMethodSymbol(); | ||
| static const bool disableCRC32 = feGetEnv("TR_aarch64DisableCRC32") != NULL; | ||
| static const bool disableStringIntrinsicFlagChk = feGetEnv("TR_DisableStringIntrinsicFlagChk") != NULL; |
There was a problem hiding this comment.
a bracket around the boolean expression is preferable and more readable.
There was a problem hiding this comment.
I can change this.
| TR::RecognizedMethod rm = node->getSymbol()->castToMethodSymbol()->getMandatoryRecognizedMethod(); | ||
|
|
||
| bool isILGenPass = !getLastRun(); | ||
| static const bool disableStringIntrinsicFlagChk = feGetEnv("TR_DisableStringIntrinsicFlagChk") != NULL; |
| bool disableCAEInlining = !cg->getSupportsInlineUnsafeCompareAndExchange(); | ||
| static bool disableOSW = feGetEnv("TR_noPauseOnSpinWait") != NULL; | ||
| static const bool disableStringIntrinsicFlagChk = feGetEnv("TR_DisableStringIntrinsicFlagChk") != NULL; | ||
|
|
| } | ||
| } | ||
|
|
||
| static const bool disableStringIntrinsicFlagChk = feGetEnv("TR_DisableStringIntrinsicFlagChk") != NULL; |
| bool disableCASInlining = !cg->getSupportsInlineUnsafeCompareAndSet(); | ||
| bool disableCAEInlining = !cg->getSupportsInlineUnsafeCompareAndExchange(); | ||
|
|
||
| static const bool disableStringIntrinsicFlagChk = feGetEnv("TR_DisableStringIntrinsicFlagChk") != NULL; |
|
For the For the |
Prior to JDK25, due to a race condition in AbstractStringBuilder, it is possible for some accelerated String intrinsics to perform an out of bounds array access. This applies to: java/lang/StringLatin1.inflate([BI[CII)V java/lang/StringLatin1.indexOf([BI[BII)I java/lang/StringUTF16.indexOf([BI[BII)I To address this, bound checking has been added such that the safe slow path code is performed in the rares cases that an out of bounds array access may occur. Former behavior is restored via the TR_DisableStringIntrinsicFlagChk envvar. As the problem does not exist in JDK25, the bound checking is not added in JDK25 and onward. Issue: eclipse-openj9#23880 Signed-off-by: jimmyk <jimmyk@ca.ibm.com>
Prior to JDK25, due to a race condition in AbstractStringBuilder, it is possible for some accelerated String intrinsics to perform an out of bounds array access. This applies to:
To address this, bound checking has been added such that the safe slow path code is performed in the rares cases that an out of bounds array access may occur.
Former behavior is restored via the
TR_DisableStringIntrinsicFlagChkenvvar. As the problem does not exist in JDK25, the bound checking is not added in JDK25 and onward.Depends on:
eclipse-omr/omr#8255
Issue with more details here:
#23880
Original Issue the problem was found is here:
#23353