Skip to content
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

Return from park immediately for non-positive time since epoch #20802

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

theresa-m
Copy link
Contributor

@theresa-m theresa-m commented Dec 10, 2024

If the deadline since epoch given to Unsafe.park is negative the calculation of mills could overflow. To prevent this set the return code to J9THREAD_TIMED_OUT for non-positive deadlines since they have always passed.

Related to: #17135

Comment on lines 53 to 55
/* Currently, the omrthread layer provides no direct support for absolute timeouts.
* Simulate the timeout by calculating the delta from the current time.
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please correct the indentation of lines 54, 55.

* Simulate the timeout by calculating the delta from the current time.
*/
PORT_ACCESS_FROM_VMC(vmThread);
if ()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this was added in error.

@@ -47,18 +47,23 @@ threadParkImpl(J9VMThread *vmThread, BOOLEAN timeoutIsEpochRelative, I_64 timeou
/* Trc_JCL_park_Entry(vmThread, timeoutIsEpochRelative, timeout); */
if ((0 != timeout) || (timeoutIsEpochRelative)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you're here, please remove the redundant parentheses:

	if ((0 != timeout) || timeoutIsEpochRelative) {

/*Trc_JCL_park_timeIsInPast(vmThread, timeNow);*/
if (millis <= 0) {
rc = J9THREAD_TIMED_OUT;
/*Trc_JCL_park_timeIsInPast(vmThread, timeNow);*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add spaces in the comment (see line 47):

					/* Trc_JCL_park_timeIsInPast(vmThread, timeNow); */

@keithc-ca
Copy link
Contributor

Rather than "negative" the description should say "non-positive", unless the intent was "negative" in which case the code needs to be corrected.

@theresa-m theresa-m changed the title Return from park immediately for negative time since epoch Return from park immediately for non-positive time since epoch Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants