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

Backport #10540 to jetty-10.0.x Fixed deadlock in class initialization. #10545

Merged
merged 2 commits into from
Sep 18, 2023

Conversation

joakime
Copy link
Contributor

@joakime joakime commented Sep 18, 2023

Backport of PR #10540 for jetty-10.0.x

  • Thread T1 may initialize HttpTester.Message that extends MutableHttpFields, so grabs the lock for the initialization of class MutableHttpFields.
  • Thread T2 may initialize HttpFields, so grabs the lock for HttpFields and initializes field EMPTY, which calls new MutableHttpFields.
  • To initialize MutableHttpFields, T1 must initialize HttpFields, but sees that its lock is taken and waits.
  • To initialize HttpFields, T2 must create an instance and therefore initialize MutableHttpFields, but sees that its lock is taken and waits.
  • Deadlock.

The solution is to use another class, EmptyHttpFields, to initialize HttpFields.EMPTY, so that there is no deadlock.

* Thread T1 may initialize HttpTester.Message that extends MutableHttpFields, so grabs the lock for the initialization of class MutableHttpFields.
* Thread T2 may initialize HttpFields, so grabs the lock for HttpFields and initializes field EMPTY, which calls new MutableHttpFields.
* To initialize MutableHttpFields, T1 must initialize HttpFields, but sees that its lock is taken and waits.
* To initialize HttpFields, T2 must create an instance and therefore initialize MutableHttpFields, but sees that its lock is taken and waits.
* Deadlock.

The solution is to use another class, EmptyHttpFields, to initialize HttpFields.EMPTY, so that there is no deadlock.

Signed-off-by: Simone Bordet <[email protected]>
@joakime joakime added the Bug For general bugs on Jetty side label Sep 18, 2023
@joakime joakime added this to the 10.0.x milestone Sep 18, 2023
@joakime joakime self-assigned this Sep 18, 2023
Signed-off-by: Joakim Erdfelt <[email protected]>
@joakime joakime merged commit 43eb08b into jetty-10.0.x Sep 18, 2023
2 checks passed
@joakime joakime deleted the fix/10.0.x/httpfields-deadlock branch September 18, 2023 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants