-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
8290059: Do not use std::thread in panama tests #9599
Conversation
👋 Welcome back jvernee! A progress list of the required criteria for merging this PR into |
@JornVernee The following labels 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 lists. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
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.
Looks good!
@JornVernee This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 47 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
@JornVernee thanks for doing this so quickly. I suggest undoing d7f0de2 in this change, too. If you update this PR I can run it through our Alpine test pipeline. |
@RealCLanger Note that I'm not setting the stack size of the thread in this patch. I'm just using the defaults. From the discussion on the bug, I don't think this sufficient to make the tests pass on Apline/MuslC. I avoided getting into that since I don't have ready access to an Alpine/MuslC testing environment atm. So, I've left setting the stack size on MuslC, and re-enabling the tests for someone that does. Hopefully this patch is enough to get that going easily. |
@mcimadamore Thanks for the comments. I've cleaned up the comments on the compiler switches (just removed them). I also realized there was an unused typedef for |
OK, thanks for clarifying that. @tstuefe, maybe you want to have a look after this fix is in? |
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.
Hi @JornVernee,
good job and thanks for doing it so quickly. Looks good, module the GetLastError comment.
About the stack size and Alpine, I am fine with doing the Aĺpine-specific fix in a follow-up, or you can do it as part of this change. Strictly speaking its not part of this bug report to adjust the stack size.
If you fix the GetLastError issue, I don't need another look.
Thanks, Thomas
test/lib/native/testlib_threads.h
Outdated
|
||
static void fatal(const char* message) { | ||
perror(message); | ||
exit(-1); |
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.
Won't work as intended for Windows APIs. I would print the result of GetLastError()
instead.
Alternatively I am fine fine with just omitting the error code, because I think the old tests did not handle errors either. Or did we catch std::thread exceptions somewhere?
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.
The intent was to exit the test with a non-zero exit code, in order to avoid any accidental false positives.
I could return the error code from GetLastError
and from the respective pthread apis as an exit code instead. Is that what you mean?
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.
FWIW, perror
just prints to stderr
: https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/perror-wperror?view=msvc-170
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.
Ah, I see what you mean now. The C standard library function perror
defines this to also print a textual description of errno
. https://en.cppreference.com/w/c/io/perror so that won't work for the Windows APIs.
I think the alternative would be to use FormatMessage
on Windows. I didn't really think that much into this.
Maybe it's clearer to use fputs
with stderr
here.
Helper* helper = (Helper*)ctxt; | ||
helper->proc(helper->context); | ||
return 0; | ||
} |
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'm curious, does this only exist because of the DWORD vs void* return value size of the native thread functions? I wondered why you don't just pass the test procedure to the thread start API directly.
About stdcall, does Oracle still build Windows 32bit?
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, this exists as an adapter from PROCEDURE to whatever callback type the OS API expects. I tried passing the procedure to the start API as well, but the compiler complains that the types don't match. Even if I make PROCEDURE return int
, it seems to want DWORD
explicitly.
This was taken from the old library code which uses _beginthreadex
. That one explicitly wants to use __stdcall
, so I just matched that. Looking again, it doesn't look like the same is required for CreateThread
[1]. I'll remove it for clarity.
[1] : https://docs.microsoft.com/en-us/previous-versions/windows/desktop/legacy/ms686736(v=vs.85)
|
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.
Build changes look good.
I took the name from the CompleteableFuture API [1], although in that case a future is returned on which a user can call
I can see this being useful in order to start many threads up front, and then join then all afterwards (to get them running concurrently). Though, I'd like to hold off on getting into that since the current tests don't need that functionality (it could be added, but stay unused). The library header can be freely amended later as well. |
I made some tentative changes based on the review comments:
Please take another look. |
No, sorry, the fact it both runs and joins is a critical aspect. |
I've looked into adding Adding that just feels like too much unneeded complexity at this moment, since there are no users that need it. So, |
But it is the functionality the tests are already using.
That's not an issue for the API to solve, that is an issue for the user of the API to solve. pthread_create doesn't involve any memory management.
Okay, that is fine. |
@tstuefe Do the changes I made look good? If so I'll go ahead and integrate. |
Looks still good. |
/integrate |
Going to push as commit 54a2c5a.
Your commit was automatically rebased without conflicts. |
@JornVernee Pushed as commit 54a2c5a. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
This patch removes the use of std::thread from the
java.lang.foreign
tests, and switches to the OS specific thread APIs, in order to change things such as the stack size on some platforms where this is required in the future (see the JBS issue).This is done by adding a small header-only library that exposes a function to run code in freshly spawned threads (
run_async
).Testing: Running the affected tests on platforms that implement the linker.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/9599/head:pull/9599
$ git checkout pull/9599
Update a local copy of the PR:
$ git checkout pull/9599
$ git pull https://git.openjdk.org/jdk pull/9599/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 9599
View PR using the GUI difftool:
$ git pr show -t 9599
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/9599.diff