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
8299343: Windows: Invalid thread_native_entry declaration #11787
Conversation
👋 Welcome back kbarrett! A progress list of the required criteria for merging this PR into |
@kimbarrett 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. |
Webrevs
|
Why do we want/need this to be a C++ static member function? The thread entry points are always plain C functions. |
8299343 mentions how the Windows declaration is shaky due to the friend specification causing it to be initially declared extern implicitly, while it is later marked static at the definition, which makes it very likely to fail if flags such as |
As discussed in the bug report, it needs to be a static member function Of the various alternatives, this seems best to me. There's no difference And referring to the definitions for the other platforms as "plain C |
Perhaps, but the thread creation functions (_beginthreadex and pthread_create) are themselves plain C API's not C++. It seems to me that the fact a static C++ member function is equivalent to a static C++ non-member function here and both work, is itself the fortuitous accident. If there were indeed an issue with C++ versus C calling convention then we would need to switch to the C convention. I agree it is nicer from an encapsulation pov that these are member functions, but when we are using thread creation routines that are extra-lingua we have to expect to make some concessions. I don't object to the proposed approach as long as it works, but I would have gone for a different option that keeps these routines more C-like and provide a public os::win32 function for the thread entry code to use. |
A non-member C++ function (whether file-scoped or having external linkage) is I think a C++ function is not required to be ABI-compatible with a C function, MSVC has multiple function call ABIs, on which the function definition and |
// Thread start routine for all newly created threads | ||
static unsigned __stdcall thread_native_entry(Thread* thread) { | ||
// Called with the associated Thread* as the argument. |
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.
Nit: please terminate existing comment with a period - thanks.
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.
Done.
@kimbarrett 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 no new commits pushed to the ➡️ To integrate this PR with the above commit message to the |
Could we refactor the rest of the platform specific thread entry definitions to be static members too after this change? As Kim points out there is not really an actual difference between a static member and file scoped func in terms of calling convention, and the rest of the platforms have identical definitions and callsites to Windows too meaning such a change wouldn't affect them much either, all of them are defined in os_*.cpp and used solely for |
I prefer not. There is no general reason these thread entry routines should be part of the os::XXX classes. All the crud in the Windows version that required access to os::win32 is to address a win32 bug. |
Fair Point. I'm now a little curious as to why we couldn't make create_process_or_thread and Ept public though |
To get rid of the friend declaration there were two options - Kim prefers the one he presented. |
I concur with David, preferring not to do the suggested refactoring. Out of curiosity, I took a look at the referenced bug. Wow! That took some |
I preferred moving the function into the class to avoid widening the public |
Thanks for reviews @dholmes-ora and @iklam . |
/integrate |
Going to push as commit dfdbd0f. |
@kimbarrett Pushed as commit dfdbd0f. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Please review this change to the Windows version of thread_native_entry. It
is changed from being inconsistently declared (both file-scoped and external)
to consistently being a private static member function in os::win32. It's
signature is also changed to match where it's used, eliminating the need for a
function pointer cast.
Testing:
mach5 tier1
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/11787/head:pull/11787
$ git checkout pull/11787
Update a local copy of the PR:
$ git checkout pull/11787
$ git pull https://git.openjdk.org/jdk pull/11787/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 11787
View PR using the GUI difftool:
$ git pr show -t 11787
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/11787.diff