-
Notifications
You must be signed in to change notification settings - Fork 542
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
[SUREFIRE-2058] Corrupted STDOUT by directly writing to native stream in forked JVM 1 with UTF-8 console logging #518
Conversation
Hi @zoltanmeze , we fixed buffer overflow in 8e30194 |
I believe it it a different issue, not throwing any
You can verify this with the two included unit tests. Test method naming is probably not the best, in the first it doesn't needs to be a new line character after a 2-bytes encoded character, it can be anything else. |
surefire-api/src/test/java/org/apache/maven/surefire/api/stream/AbstractStreamDecoderTest.java
Outdated
Show resolved
Hide resolved
494743e
to
8615d16
Compare
@zoltanmeze |
@zoltanmeze |
@Tibor17 No, everything good. That do-while looked suspicious to me, I don't think that condition is ever true. But didn't want to touch it. |
|
Channel channel = new Channel( s.toString().getBytes( UTF_8 ), s.length() ); | ||
|
||
Mock thread = new Mock( channel, new MockForkNodeArguments(), | ||
Collections.<Segment, ForkedProcessEventType>emptyMap() ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here can be static import of emptyMap()
without Generics.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Other test methods are also using explicit type arguments, so just used the same way.
For consistency replaced in all places in this class, see 0b1c564.
@zoltanmeze |
@Tibor17 |
@walterFor Is that somehow related to this issue? It doesn't look related. Can you create a ticket with reproducible steps? |
@zoltanmeze
should become
|
Hi @zoltanmeze |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zoltanmeze
I have qualified the problem with runMode
as a bug, see the comment. The outcome would be the same buffer overflow and the same meaning for this Jira.
…ing output buffer - shouldReadStringOverflowOnNewLine - ends up with 1 single byte (LF) remaining on input buffer - shouldReadStringOverflowOn4BytesEncodedSymbol - causing an infinite loop with 4 bytes left on input buffer
Overflow can happen even when output buffer has still some remaining space left
0b1c564
to
511b5c4
Compare
Done. See 511b5c4. Also rebased the branch onto latest master. I still think that BufferOverflowException on null runMode should be a separate issue/PR, it's not really related to SUREFIRE-2058. It's a bug in StreamEncoder, but 2058 is a StreamDecoder issue with no exception thrown. So it should be probably linked to SUREFIRE-2056 instead. If you change you mind I can pull that last commit into separate PR. |
@zoltanmeze |
511b5c4
to
2a72800
Compare
Let's run the CI build... |
@zoltanmeze |
Two cases are covered here:
Both cases are caused by the same issue, output buffer overflow in AbstractStreamDecoder#readString(Memento, int), because output char buffer is not cleared if it's not completely full.
Added unit tests:
Input buffer of 1026 bytes: 1023 x 1-byte + 1 x 2-bytes encoded character + new line (LF).
decodeString
returns an overflow, but it still force reads the 2-byte encoded character from input to output.readString
ends up with 1 remaining byte (LF) on input buffer causing channel to become corrupted.Input buffer of 1027 bytes: 1023 x 1 byte + 1 x 4-bytes encoded characters.
decodeString
returns an overflow, without reading anything from input buffer. This is causing an infinite loop inreadString
, it never exits.Tested locally with some private projects. In one of the project 1k corrupted channel messages on M6, 0 wtih these changes. Also tried just just printing out a ton of messages generated using RandomStringUtils#random.
Following this checklist to help us incorporate your
contribution quickly and easily:
for the change (usually before you start working on it). Trivial changes like typos do not
require a JIRA issue. Your pull request should address just this issue, without
pulling in other changes.
[SUREFIRE-XXX] - Fixes bug in ApproximateQuantiles
,where you replace
SUREFIRE-XXX
with the appropriate JIRA issue. Best practiceis to use the JIRA issue title in the pull request title and in the first line of the
commit message.
mvn clean install
to make sure basic checks pass. A more thorough check willbe performed on your pull request automatically.
mvn -Prun-its clean install
).If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.
I hereby declare this contribution to be licenced under the Apache License Version 2.0, January 2004
In any other case, please file an Apache Individual Contributor License Agreement.