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

8268165: AsyncLogging will crash if rotate() fails #4332

Closed
wants to merge 2 commits into from

Conversation

@navyxliu
Copy link
Contributor

@navyxliu navyxliu commented Jun 3, 2021

LogFileOutput::rotate() may leave _stream NULL because os::fopen() may return NULL due to space or inode limitations. AsyncLogWriter::write() calls LogFileOutput::write_blocking() without null check. Null check is added to prevent from crashing.


Progress

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

Issue

  • JDK-8268165: AsyncLogging will crash if rotate() fails

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/4332/head:pull/4332
$ git checkout pull/4332

Update a local copy of the PR:
$ git checkout pull/4332
$ git pull https://git.openjdk.java.net/jdk pull/4332/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 4332

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/4332.diff

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Jun 3, 2021

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

Loading

@openjdk
Copy link

@openjdk openjdk bot commented Jun 3, 2021

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

  • hotspot-runtime

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.

Loading

@navyxliu
Copy link
Contributor Author

@navyxliu navyxliu commented Jun 3, 2021

/summary LogFileOutput::rotate() may leave _stream NULL because os::fopen() may return NULL due to space or inode limitations. AsyncLogWriter::write() calls LogFileOutput::write_blocking() without null check. Null check is added to prevent from crashing.

Loading

@openjdk
Copy link

@openjdk openjdk bot commented Jun 3, 2021

@navyxliu Setting summary to LogFileOutput::rotate() may leave _stream NULL because os::fopen() may return NULL due to space or inode limitations. AsyncLogWriter::write() calls LogFileOutput::write_blocking() without null check. Null check is added to prevent from crashing.

Loading

@mlbridge
Copy link

@mlbridge mlbridge bot commented Jun 3, 2021

Webrevs

Loading

@navyxliu
Copy link
Contributor Author

@navyxliu navyxliu commented Jun 6, 2021

hi, @YaSuenag,
Could you take a look at this? It's an error-handling patch.

thanks,
--lx

Loading

Copy link
Member

@YaSuenag YaSuenag left a comment

Looks good.

I wonder why we use semaphore instead of mutex for _rotation_semaphore, but it's not yours.

Loading

@openjdk
Copy link

@openjdk openjdk bot commented Jun 7, 2021

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

8268165: AsyncLogging will crash if rotate() fails

LogFileOutput::rotate() may leave _stream NULL because os::fopen() may return NULL due to space or inode limitations.  AsyncLogWriter::write() calls LogFileOutput::write_blocking() without null check.  Null check is added to prevent from crashing.

Reviewed-by: ysuenaga

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

  • 341f676: 8267908: linux: thread_native_entry can scribble on stack frame
  • f40c89e: 8267209: Child threads should defer logging to after child-parent handshake
  • ae986bc: 8266749: AArch64: Backtracing broken on PAC enabled systems
  • 36c4e5f: 8267187: Remove deprecated constructor for Log
  • fc08af5: 8174222: LambdaMetafactory: validate inputs and improve documentation
  • 5e557d8: 8266967: debug.cpp utility find() should print Java Object fields.
  • c7c77fd: 8255557: Decouple GCM from CipherCore
  • e546ae2: 8268296: ScopedMemoryAccess build error with readonly filesystems
  • 81600dc: 8191441: (Process) add Readers and Writer access to java.lang.Process streams
  • 7e55569: 8261549: Adjust memory size in MTLTexurePool.m
  • ... and 36 more: https://git.openjdk.java.net/jdk/compare/20b631278c0c89ccd9c16f2a29d47eb8414aacd5...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.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@YaSuenag) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

Loading

@openjdk openjdk bot added the ready label Jun 7, 2021
@navyxliu
Copy link
Contributor Author

@navyxliu navyxliu commented Jun 7, 2021

Looks good.

I wonder why we use semaphore instead of mutex for _rotation_semaphore, but it's not yours.

Thanks for reviewing it.

I can try to answer this. Synchronous logging writing may happen anywhere and anytime.
hotspot's mutex requires Thread::current(). We can't assume that in very early stage or very late stage, or it will fail this assertion.

  assert(current != NULL, "Thread::current() called on detached thread");

eg. this logsite is invoked after delete thread;.
https://github.com/openjdk/jdk/blob/master/src/hotspot/share/runtime/threadSMR.cpp#L1027

Semaphore doesn't have this constraint.

Loading

@YaSuenag
Copy link
Member

@YaSuenag YaSuenag commented Jun 7, 2021

I can try to answer this. Synchronous logging writing may happen anywhere and anytime.
hotspot's mutex requires Thread::current(). We can't assume that in very early stage or very late stage, or it will fail this assertion.

  assert(current != NULL, "Thread::current() called on detached thread");

eg. this logsite is invoked after delete thread;.
https://github.com/openjdk/jdk/blob/master/src/hotspot/share/runtime/threadSMR.cpp#L1027

Semaphore doesn't have this constraint.

Ah, I see. Thanks!

Loading

@navyxliu
Copy link
Contributor Author

@navyxliu navyxliu commented Jun 8, 2021

/integrate

Loading

@openjdk openjdk bot added the sponsor label Jun 8, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Jun 8, 2021

@navyxliu
Your change (at version 20c08df) is now ready to be sponsored by a Committer.

Loading

@YaSuenag
Copy link
Member

@YaSuenag YaSuenag commented Jun 8, 2021

/sponsor

Loading

@openjdk openjdk bot closed this Jun 8, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Jun 8, 2021

@YaSuenag @navyxliu Since your change was applied there have been 48 commits pushed to the master branch:

  • fd91b2a: 8265440: IGV: make node selection more visible
  • 81bad59: 8257774: G1: Trigger collect when free region count drops below threshold to prevent evacuation failures
  • 341f676: 8267908: linux: thread_native_entry can scribble on stack frame
  • f40c89e: 8267209: Child threads should defer logging to after child-parent handshake
  • ae986bc: 8266749: AArch64: Backtracing broken on PAC enabled systems
  • 36c4e5f: 8267187: Remove deprecated constructor for Log
  • fc08af5: 8174222: LambdaMetafactory: validate inputs and improve documentation
  • 5e557d8: 8266967: debug.cpp utility find() should print Java Object fields.
  • c7c77fd: 8255557: Decouple GCM from CipherCore
  • e546ae2: 8268296: ScopedMemoryAccess build error with readonly filesystems
  • ... and 38 more: https://git.openjdk.java.net/jdk/compare/20b631278c0c89ccd9c16f2a29d47eb8414aacd5...master

Your commit was automatically rebased without conflicts.

Pushed as commit 8105478.

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

Loading

@mlbridge
Copy link

@mlbridge mlbridge bot commented Jun 8, 2021

Mailing list message from David Holmes on hotspot-runtime-dev:

Xin, Yasumasa,

Please note that non-trivial changes in hotspot code require two reviews
before integration. [1]

Thanks,
David

[1] https://wiki.openjdk.java.net/display/HotSpot/Pushing+a+HotSpot+change

On 8/06/2021 5:23 pm, Xin Liu wrote:

Loading

1 similar comment
@mlbridge
Copy link

@mlbridge mlbridge bot commented Jun 8, 2021

Mailing list message from David Holmes on hotspot-runtime-dev:

Xin, Yasumasa,

Please note that non-trivial changes in hotspot code require two reviews
before integration. [1]

Thanks,
David

[1] https://wiki.openjdk.java.net/display/HotSpot/Pushing+a+HotSpot+change

On 8/06/2021 5:23 pm, Xin Liu wrote:

Loading

@YaSuenag
Copy link
Member

@YaSuenag YaSuenag commented Jun 8, 2021

Sorry, I will be careful.

Loading

@navyxliu
Copy link
Contributor Author

@navyxliu navyxliu commented Jun 8, 2021

hi, David,
I see. I read through that wiki. I will stick with two-reviewers rules in the future.

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants