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

8346383: Cannot use DllMain in libdt_socket for static builds #22789

Closed
wants to merge 2 commits into from

Conversation

magicus
Copy link
Member

@magicus magicus commented Dec 17, 2024

To be able to properly support static builds on Windows in JDK-8346377, we cannot use DllMain, for two reasons:

  1. This is not called for statically linked libraries, and
  2. There are multiple DllMain definitions throughout the JDK native libraries, causing name collisions.

While it could have been possible to keep the DllMain function for non-static builds and just use an alternative solution for static builds, I think it is preferable to have a single solution that works as well for both static and dynamic builds.

On top of this, the existing solution was contrary to Microsoft recommendations, which state: "The WSACleanup function typically leads to protocol-specific helper DLLs being unloaded. As a result, the WSACleanup function should not be called from the DllMain function in a application DLL. This can potentially cause deadlocks. "


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8346383: Cannot use DllMain in libdt_socket for static builds (Bug - P3)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/22789/head:pull/22789
$ git checkout pull/22789

Update a local copy of the PR:
$ git checkout pull/22789
$ git pull https://git.openjdk.org/jdk.git pull/22789/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 22789

View PR using the GUI difftool:
$ git pr show -t 22789

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/22789.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 17, 2024

👋 Welcome back ihse! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@magicus
Copy link
Member Author

magicus commented Dec 17, 2024

I'm not sure what tests to run for this change, apart from tier1. I am open to suggestions.

@openjdk
Copy link

openjdk bot commented Dec 17, 2024

@magicus 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:

8346383: Cannot use DllMain in libdt_socket for static builds

Reviewed-by: dholmes, sspitsyn

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 229 new commits pushed to the master branch:

  • 13a1775: 8344146: Remove temporary font file tracking code.
  • 61dc07c: 8346869: [AIX] Add regression test for handling 4 Byte aligned doubles in structures
  • 13e1ea5: 8346038: [REDO] - [C1] LIR Operations with one input should be implemented as LIR_Op1
  • 7c883c2: 8347605: Use spec tag to refer to IEEE 754 standard
  • 4e0ffda: 8346972: Test java/nio/channels/FileChannel/LoopingTruncate.java fails sometimes with IOException: There is not enough space on the disk
  • e0f2f4b: 8313396: Portable implementation of FORBID_C_FUNCTION and ALLOW_C_FUNCTION
  • b0c131e: 8345368: java/io/File/createTempFile/SpecialTempFile.java fails on Windows Server 2025
  • a7915bb: 8346468: SM cleanup of common test library
  • f67b703: 8347427: JTabbedPane/8134116/Bug8134116.java has no license header
  • 062f2dc: 8347554: [BACKOUT] C2: implement optimization for series of Add of unique value
  • ... and 219 more: https://git.openjdk.org/jdk/compare/dbffe33251da4472945d97ab54c7e3354d7f42d2...master

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 master branch, type /integrate in a new comment.

@openjdk
Copy link

openjdk bot commented Dec 17, 2024

@magicus The following label will be automatically applied to this pull request:

  • serviceability

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.

@openjdk openjdk bot added the serviceability serviceability-dev@openjdk.org label Dec 17, 2024
@magicus magicus marked this pull request as ready for review December 17, 2024 13:15
@openjdk openjdk bot added the rfr Pull request is ready for review label Dec 17, 2024
@mlbridge
Copy link

mlbridge bot commented Dec 17, 2024

Webrevs

@magicus
Copy link
Member Author

magicus commented Jan 10, 2025

Can I get any reviewers for this?

Copy link
Contributor

@sspitsyn sspitsyn left a comment

Choose a reason for hiding this comment

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

This looks good but needs copyright year updates.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jan 11, 2025
Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

Exactly when will WSACleanup get called via the atexit handler versus when it gets called today? I suspect it is sooner than when DllMain with DLL_PROCESS_DETACH would be called. In which case do we now risk tearing down socket support whilst it may still be in use?

@magicus
Copy link
Member Author

magicus commented Jan 13, 2025

My understanding is that it is later. But I am also not sure if this is well-specified or just an implementation detail. I'd say our code is broken if we rely on anything working between DLL_PROCESS_DETACH and atexit handlers are called. I seriously doubt that is the case.

@magicus magicus requested a review from sspitsyn January 13, 2025 13:27
@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Jan 13, 2025
Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

I will click approve but I think we need to keep a careful eye out for odd network related failures during shutdown.

Thanks

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jan 13, 2025
@magicus
Copy link
Member Author

magicus commented Jan 13, 2025

/integrate

@openjdk
Copy link

openjdk bot commented Jan 13, 2025

Going to push as commit d3a7ac2.
Since your change was applied there have been 229 commits pushed to the master branch:

  • 13a1775: 8344146: Remove temporary font file tracking code.
  • 61dc07c: 8346869: [AIX] Add regression test for handling 4 Byte aligned doubles in structures
  • 13e1ea5: 8346038: [REDO] - [C1] LIR Operations with one input should be implemented as LIR_Op1
  • 7c883c2: 8347605: Use spec tag to refer to IEEE 754 standard
  • 4e0ffda: 8346972: Test java/nio/channels/FileChannel/LoopingTruncate.java fails sometimes with IOException: There is not enough space on the disk
  • e0f2f4b: 8313396: Portable implementation of FORBID_C_FUNCTION and ALLOW_C_FUNCTION
  • b0c131e: 8345368: java/io/File/createTempFile/SpecialTempFile.java fails on Windows Server 2025
  • a7915bb: 8346468: SM cleanup of common test library
  • f67b703: 8347427: JTabbedPane/8134116/Bug8134116.java has no license header
  • 062f2dc: 8347554: [BACKOUT] C2: implement optimization for series of Add of unique value
  • ... and 219 more: https://git.openjdk.org/jdk/compare/dbffe33251da4472945d97ab54c7e3354d7f42d2...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jan 13, 2025
@openjdk openjdk bot closed this Jan 13, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jan 13, 2025
@openjdk
Copy link

openjdk bot commented Jan 13, 2025

@magicus Pushed as commit d3a7ac2.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@magicus magicus deleted the dll-main-in-libdt_socket branch January 13, 2025 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated serviceability serviceability-dev@openjdk.org
Development

Successfully merging this pull request may close these issues.

3 participants