Skip to content

Conversation

@dfuch
Copy link
Member

@dfuch dfuch commented Feb 7, 2025

Hi,

Please find here a change that fixes a potential race condition in SSLTube.SSLSubscriptionWrapper.
Typically the race may get triggered if the demand increased by request() is not exhausted by the time
the subscription is switched by setSubscription.

Some synchronization is required to present a consistent view of the subscripton state, so that pending demand can be consistently transferred to the new the subscription.

This mostly affects HTTP/1.1 over TLS since each new exchange will cause the subscription to be switched to the new exchange. The race condition is elusive and hard to reproduce. when it occurs, it mostly causes tests to fail in jtreg timeout as the demand from upstream may not be transferred properly.

Some additional logging has been added to the DigestEchoClient.java test class (which is used by DigestEchoClientSSL) to help diagnosability of intermittent failures in these tests.


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-8349662: SSLTube SSLSubscriptionWrapper has potential races when switching subscriptions (Bug - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 23515

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Feb 7, 2025

👋 Welcome back dfuchs! 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.

@openjdk
Copy link

openjdk bot commented Feb 7, 2025

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

8349662: SSLTube SSLSubscriptionWrapper has potential races when switching subscriptions

Reviewed-by: jpai

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

  • 8e85829: 8349213: G1: Clearing bitmaps during collection set merging not claimed by region
  • 1a8212e: 8348678: [PPC64] C2: unaligned vector load/store is ok
  • 41bdc47: 8208377: Soft hyphens render if not using TextLayout
  • df654a9: 8349752: Tier1 build failure caused by JDK-8349178
  • 527489c: 8349284: Make libExplicitAttach work on static JDK
  • f11a737: 8349475: Test tools/javac/api/TestJavacTaskWithWarning.java writes files in src dir
  • b737f7f: 8349501: Relocate supporting classes in security/testlibrary to test/lib/jdk tree
  • 84b32cb: 8349178: runtime/jni/atExit/TestAtExit.java should be supported on static JDK
  • ab66c82: 8349639: jfr/event/gc/detailed/TestShenandoahEvacuationInformationEvent.java fails to compile after JDK-8348610
  • f74c4df: 8349580: Do not use address in MemTracker top level functions
  • ... and 16 more: https://git.openjdk.org/jdk/compare/86cec4ea2c2c56f03b23be44caade49b922cd3c6...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 openjdk bot added the rfr Pull request is ready for review label Feb 7, 2025
@openjdk
Copy link

openjdk bot commented Feb 7, 2025

@dfuch The following labels will be automatically applied to this pull request:

  • net
  • security

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.

@openjdk openjdk bot added security security-dev@openjdk.org net net-dev@openjdk.org labels Feb 7, 2025
@dfuch
Copy link
Member Author

dfuch commented Feb 7, 2025

/label remove security

@openjdk openjdk bot removed the security security-dev@openjdk.org label Feb 7, 2025
@openjdk
Copy link

openjdk bot commented Feb 7, 2025

@dfuch
The security label was successfully removed.

@mlbridge
Copy link

mlbridge bot commented Feb 7, 2025

Webrevs

Flow.Subscription sub = delegate;
if (sub != null && n > 0) {
sub.request(n);
final long demand = n;
Copy link
Member

Choose a reason for hiding this comment

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

Hello Daniel, is this demand variable necessary? From what I see, we could just keep using n wherever we use demand in this method. I think that would also avoid the confusion between demanded and this demand variables that are used in this method.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK

BodyPublisher reqBody = BodyPublishers.ofString(body);
HttpRequest.Builder builder = HttpRequest.newBuilder(uri).version(clientVersion)
URI baseReq = URI.create(uri + "?iteration=" + i + ",async=" + async
+ ",addHeaders=" + addHeaders + ",preemptive=" + preemptive
Copy link
Member

Choose a reason for hiding this comment

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

Should this (and the other places where we are updating the request URI) use & instead of ,, for request query parameter delimiting or is this just changed for better logging (on the server side)?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is just a change so that we can better follow out what belong to which request in the logs (whether client & server). The query is not used/parsed anywhere - it's just there for better diagnosis when the test fails.

if (error != null) throw error;
if (error != null) {
if (failed != null) error.addSuppressed(failed);
throw error;
Copy link
Member

Choose a reason for hiding this comment

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

Do you think an additional error != failed check would be needed here, before calling addSuppressed() or is that not a concern here?

Copy link
Member Author

Choose a reason for hiding this comment

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

error is a brand new AsssertionError created by the tracker. It simply can't be the same exception as failed.

Copy link
Member

Choose a reason for hiding this comment

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

You are right - I missed that error is declared and assigned just one line above this and that can only be an AssertionError.

Copy link
Member

@jaikiran jaikiran left a comment

Choose a reason for hiding this comment

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

These changes look reasonable to me.

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

dfuch commented Feb 11, 2025

/integrate

@openjdk
Copy link

openjdk bot commented Feb 11, 2025

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

  • 964dd18: 8349515: [REDO] Framework for tracing makefile inclusion and parsing
  • 8e85829: 8349213: G1: Clearing bitmaps during collection set merging not claimed by region
  • 1a8212e: 8348678: [PPC64] C2: unaligned vector load/store is ok
  • 41bdc47: 8208377: Soft hyphens render if not using TextLayout
  • df654a9: 8349752: Tier1 build failure caused by JDK-8349178
  • 527489c: 8349284: Make libExplicitAttach work on static JDK
  • f11a737: 8349475: Test tools/javac/api/TestJavacTaskWithWarning.java writes files in src dir
  • b737f7f: 8349501: Relocate supporting classes in security/testlibrary to test/lib/jdk tree
  • 84b32cb: 8349178: runtime/jni/atExit/TestAtExit.java should be supported on static JDK
  • ab66c82: 8349639: jfr/event/gc/detailed/TestShenandoahEvacuationInformationEvent.java fails to compile after JDK-8348610
  • ... and 17 more: https://git.openjdk.org/jdk/compare/86cec4ea2c2c56f03b23be44caade49b922cd3c6...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Feb 11, 2025

@dfuch Pushed as commit 5ee44c1.

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

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 net net-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

2 participants