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

8255980: G1 Service thread register_task can be used after shutdown #1093

Closed
wants to merge 1 commit into from

Conversation

kstefanj
Copy link
Contributor

@kstefanj kstefanj commented Nov 6, 2020

Please review this change to improve the service thread task handling during shutdown.

This problem isn't currently visible, but with upcoming changes there is a race where tasks might be added to the service thread after it has been shut down. This becomes problematic because the task queue at that point consists of invalid objects. They are invalid because the tasks are currently stack-allocated on the service thread. This change both allocates the tasks handled by the service thread dynamically and add a check to avoid adding tasks when the service thread has been shut down. Just doing the dynamic allocation would be enough, but there is no reason to add tasks after the thread is shut down.

I've tested this fix together with my concurrent uncommit changes which highlight the problem, and also run tier1 and tier2 for sanity.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Testing

Linux x64 Linux x86 Windows x64 macOS x64
Build ✔️ (5/5 passed) ✔️ (2/2 passed) ✔️ (2/2 passed) ✔️ (2/2 passed)
Test (tier1) ✔️ (9/9 passed) ✔️ (9/9 passed) ✔️ (9/9 passed) ✔️ (9/9 passed)

Issue

  • JDK-8255980: G1 Service thread register_task can be used after shutdown

Reviewers

Download

$ git fetch https://git.openjdk.java.net/jdk pull/1093/head:pull/1093
$ git checkout pull/1093

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Nov 6, 2020

👋 Welcome back sjohanss! 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 added the rfr label Nov 6, 2020
@openjdk
Copy link

@openjdk openjdk bot commented Nov 6, 2020

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

  • hotspot-gc

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 hotspot-gc label Nov 6, 2020
@mlbridge
Copy link

@mlbridge mlbridge bot commented Nov 6, 2020

Webrevs

Copy link
Contributor

@tschatzl tschatzl left a comment

Since ServiceThread is never deleted (as owned by G1CollectedHeap) this sufficiently keeps alive the task queue so that the code can query it and the tasks in there.

Lgtm.

@openjdk
Copy link

@openjdk openjdk bot commented Nov 9, 2020

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

8255980: G1 Service thread register_task can be used after shutdown

Reviewed-by: tschatzl, ayang

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

  • d99e1f6: 8255991: Shenandoah: Apply 'weak' LRB on cmpxchg and xchg
  • c7551c3: 8256014: Eliminate the warning about serialization in non-public API of Swing
  • 2d6c28d: 6847157: java.lang.NullPointerException: HDC for component at sun.java2d.loops.Blit.Blit
  • 3ce09c0: 8255920: J2DBench should support CS_PYCC color profile
  • 2c8f4e2: 8255799: AArch64: CPU_A53MAC feature may be set incorrectly
  • 2cad836: 8255575: java.awt.color.ICC_ColorSpace is not thread-safe
  • a53b12d: 8255722: Create a new test for rotated blit
  • f39a2c8: 8256015: Shenandoah: Add missing Shenandoah implementation in WB_isObjectInOldGen
  • ed7526a: 8247872: Upgrade HarfBuzz to the latest 2.7.2
  • 6a183fb: 8255562: delete UseRDPCForConstantTableBase
  • ... and 22 more: https://git.openjdk.java.net/jdk/compare/d3c43c28165d703570ba96e9c557927f23478947...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 ready label Nov 9, 2020
G1RemSetSamplingTask* _remset_task;
G1PeriodicGCTask* _periodic_gc_task;
Copy link
Member

@albertnetymk albertnetymk Nov 9, 2020

Choose a reason for hiding this comment

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

I would prefer them being embedded directly, G1RemSetSamplingTask _remset_task;, since they share the same lifespan with the enclosing object. No strong opinion; up to you.

Copy link
Contributor Author

@kstefanj kstefanj Nov 9, 2020

Choose a reason for hiding this comment

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

Me too, but then I would have to move the declaration of the tasks into the header. Now the above forward declaration is enough and I preferred that even more :)

@kstefanj
Copy link
Contributor Author

@kstefanj kstefanj commented Nov 9, 2020

/integrate

@openjdk openjdk bot closed this Nov 9, 2020
@openjdk openjdk bot added integrated and removed ready rfr labels Nov 9, 2020
@openjdk
Copy link

@openjdk openjdk bot commented Nov 9, 2020

@kstefanj Since your change was applied there have been 33 commits pushed to the master branch:

  • dd8e4ff: 8255711: Fix and unify hotspot signal handlers
  • d99e1f6: 8255991: Shenandoah: Apply 'weak' LRB on cmpxchg and xchg
  • c7551c3: 8256014: Eliminate the warning about serialization in non-public API of Swing
  • 2d6c28d: 6847157: java.lang.NullPointerException: HDC for component at sun.java2d.loops.Blit.Blit
  • 3ce09c0: 8255920: J2DBench should support CS_PYCC color profile
  • 2c8f4e2: 8255799: AArch64: CPU_A53MAC feature may be set incorrectly
  • 2cad836: 8255575: java.awt.color.ICC_ColorSpace is not thread-safe
  • a53b12d: 8255722: Create a new test for rotated blit
  • f39a2c8: 8256015: Shenandoah: Add missing Shenandoah implementation in WB_isObjectInOldGen
  • ed7526a: 8247872: Upgrade HarfBuzz to the latest 2.7.2
  • ... and 23 more: https://git.openjdk.java.net/jdk/compare/d3c43c28165d703570ba96e9c557927f23478947...master

Your commit was automatically rebased without conflicts.

Pushed as commit 79b7909.

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

@kstefanj kstefanj deleted the 8255980-service-fix branch Nov 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-gc integrated
3 participants