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

8297424: java/net/httpclient/AsyncExecutorShutdown.java fails in AssertionError due to misplaced assert #11332

Closed
wants to merge 4 commits into from

Conversation

dfuch
Copy link
Member

@dfuch dfuch commented Nov 23, 2022

The ResponseSubscribers.HttpResponseInputStream class has an assert that has been observed firing (rarely) when running the java/net/httpclient/AsyncExecutorShutdown.java test.

After a thorough analysis of the code and the log failure I am convinced that the issue is due to a misplaced assert.
If cancellation happens asynchronously while the subscriber is being subscribed with the lower layers of the stack, the HttpResponseInputStream might get closed and the LAST_LIST buffer might be offered after closed == false has been observed by the onSubscribed method, but before the assertion has been checked. The assertion assumes that the queue must be empty, but it might not if close has been called and the LAST_LIST buffer has been offered.

Moving the assert from within the synchronized block, to ensure that the observed value of closed is consistent with the state of the queue, should fix it. I have tagged the bug as noreg-hard, I'm not sure it would be fair to say that AsyncExecutorShutdown.java can be used to verify the fix.


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-8297424: java/net/httpclient/AsyncExecutorShutdown.java fails in AssertionError due to misplaced assert

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 11332

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 23, 2022

👋 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 openjdk bot changed the title 8297424 8297424: java/net/httpclient/AsyncExecutorShutdown.java fails in AssertionError due to misplaced assert Nov 23, 2022
@openjdk openjdk bot added the rfr Pull request is ready for review label Nov 23, 2022
@openjdk
Copy link

openjdk bot commented Nov 23, 2022

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

  • net

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 net net-dev@openjdk.org label Nov 23, 2022
@mlbridge
Copy link

mlbridge bot commented Nov 23, 2022

Webrevs

@jaikiran
Copy link
Member

Hello Daniel, the change where we move the assert into the synchronized block looks fine to me. Looking at the code I think the check to see that the buffers can accomodate at least 2 elements (when onSubscribe is called) looks correct to me because the buffers will be initialized in the constructor of HttpResponseInputStream with a capacity of at least 2. So the assert itself looks correct.

This PR also has changes in the Stream class. Some of those changes are typo related fixes, so that's fine. However, it also has other functional changes. Is that intentional and related?

@dfuch
Copy link
Member Author

dfuch commented Nov 25, 2022

This PR also has changes in the Stream class. Some of those changes are typo related fixes, so that's fine. However, it also has other functional changes. Is that intentional and related?

These are changes I made when investigating the fix, and they are not related. The pendingResponseSubscriber is a temporary field that holds the subscriber value until the responseSubscriber is handled and subscribed by the schedule loop. It is a bit confusing to see a non null pendingResponseSubscriber after it has been handled by that loop. Practically, setting it to null or leaving it assigned at this point should have no effect on the behavior of this class... Hmmm... except I see ternary operators that first look at the subscriber and then at the pending subscriber. So this change now introduce a potential race condition if they are executed concurrently with the schedule loop. Good observation. I will revert that.

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.

Thank you Daniel. The latest changes look good to me.

@openjdk
Copy link

openjdk bot commented Nov 28, 2022

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

8297424: java/net/httpclient/AsyncExecutorShutdown.java fails in AssertionError due to misplaced assert

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

  • 4e8e853: 6788481: CellEditorListener.editingCanceled is never called
  • 692bedb: 8297106: Remove the -Xcheck:jni local reference capacity checking
  • 05128c2: 8286185: The Java manpage can be more platform inclusive
  • d450314: 8297276: Remove thread text from Subject.current
  • cdf9ed0: 8297528: java/io/File/TempDirDoesNotExist.java test failing on windows-x64
  • 105d9d7: 8295351: java/lang/Float/Binary16Conversion.java fails with "Unexpected result of converting"
  • a80552e: 8236919: Refactor com.sun.tools.javac.main.CommandLine into a reusable module for other JDK tools
  • a249a52: 8296754: AutoCreateSharedArchive in JDK 20 is not compatible with JDK 19
  • 405b188: 8297570: jdk/jfr/threading/TestDeepVirtualStackTrace.java fails with -XX:-UseTLAB

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
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 ready Pull request is ready to be integrated label Nov 28, 2022
@dfuch
Copy link
Member Author

dfuch commented Nov 29, 2022

/integrate

@openjdk
Copy link

openjdk bot commented Nov 29, 2022

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

  • 361b50e: 8292594: Use CSS custom properties for all fonts and colors
  • 42b60ed: 8297030: Reduce Default Keep-Alive Timeout Value for httpclient
  • 1301fb0: 8296470: Refactor VMError::report STEP macro to improve readability
  • 48017b1: 8296804: Document HttpClient configuration properties in java.net.http module-info
  • bd51b7e: 8296645: org.openjdk.bench.javax.tools.Javac leaves class files in current directory
  • b27a61e: 8297216: Search results omit some methods
  • 33dfc7d: 8296954: G1: Enable parallel scanning for heap region remset
  • 6f06f44: 8297242: Use-after-free during library unloading on Linux
  • 4e8e853: 6788481: CellEditorListener.editingCanceled is never called
  • 692bedb: 8297106: Remove the -Xcheck:jni local reference capacity checking
  • ... and 7 more: https://git.openjdk.org/jdk/compare/ba0a2521ba6d7db041580be7cda633311836b455...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Nov 29, 2022

@dfuch Pushed as commit 5d2772a.

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

@dfuch dfuch deleted the AsyncExecutorShutdown-8297424 branch November 29, 2022 14:31
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