-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8338197: ubsan: ad_x86.hpp:6417:11: runtime error: shift exponent 100 is too large for 32-bit type 'unsigned int' #26890
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
👋 Welcome back bulasevich! A progress list of the required criteria for merging this PR into |
❗ This change is not yet ready to be integrated. |
@bulasevich The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
… is too large for 32-bit type 'unsigned int'
1f91d49
to
7e8c282
Compare
Webrevs
|
fprintf(fp_hpp, " _mask <<= n;\n"); | ||
fprintf(fp_hpp, " int max_shift = 8 * sizeof(_mask) - 1;\n"); | ||
fprintf(fp_hpp, " _mask <<= (n < max_shift) ? n : max_shift;\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sizeof(_mask) is know - it is sizeof(uint).
Lines 760-768 should be cleaned: <= 32
checks are redundant because of check at line 758. This is leftover from SPARC code (not clean) removal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point - I removed the redundant code.
As for sizeof(_mask)
, shouldn’t it just be max_shift = 31
or _mask <<= (n < 32) ? n : 31;
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, if sizeof(uint)
is 32 bits on all our platforms.
Hmm, may be we should use uint32_t
for _mask
here. Then we can use 32 and 31 without confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean to use _mask <<= (n < 32) ? n : 31;
I didn't realize we already had code to handle masks for large shifts. So I think the main problem is that _maxcycleused is not being set to the max value of 100. There is a secondary problem that we don't really need values that high, if the units are in pipeline stages. |
This reworks the recent update #24696 to fix a UBSan issue on aarch64. The problem now reproduces on x86_64 as well, which suggests the previous update was not optimal.
The issue reproduces with a HeapByteBufferTest jtreg test on a UBSan-enabled build. Actually the trigger is
XX:+OptoScheduling
option used by test (by default OptoScheduling is disabled on most x86 CPUs). With the option enabled, the failure can be reproduced with a simplejava -version
run.This fix is in ADLC-generated code. For simplicity, the examples below show the generated fragments.
The problems is that shift count
n
may be too large here:The recent change attempted to cap the shift amount at one call site:
However, there is another site where
Pipeline_Use_Cycle_Mask::operator<<=
can be called with a too-large shift count:Fix: cap the shift inside
Pipeline_Use_Cycle_Mask::operator<<=
so all call sites are safe:Note: on platforms where PipelineForm::_maxcycleused > 32 (e.g., ARM32), the Pipeline_Use_Cycle_Mask implementation already handles large shifts, so no additional check is needed:
Progress
Issue
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/26890/head:pull/26890
$ git checkout pull/26890
Update a local copy of the PR:
$ git checkout pull/26890
$ git pull https://git.openjdk.org/jdk.git pull/26890/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 26890
View PR using the GUI difftool:
$ git pr show -t 26890
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/26890.diff
Using Webrev
Link to Webrev Comment