Integrated: 7902870: Infinite loop in AgentServer

Naoto Sato naoto at openjdk.java.net
Tue Mar 30 22:41:28 UTC 2021


In AgentServer.java, there is this piece of code:

---
             private void decode() throws IOException {
                 byteBuffer.flip();
                 CoderResult cr;
                 while ((cr = decoder.decode(byteBuffer, charBuffer, false)) != CoderResult.UNDERFLOW) {
                     writeCharBuffer();
                 }
                 byteBuffer.compact();
             }
---

The while loop only exits if the decode() returns UNDERFLOW, which may not be true in some occasions, because the encoding used here and the output from the agent VM may differ, decode() may return malformed/unmapped error. Then it will become an infinite loop here.

-------------

Commit messages:
 - Added fallback to Charset.defaultCharset()
 - Fixed an infinite loop in AgentServer due to an encoding mismatch.

Changes: https://git.openjdk.java.net/jtreg/pull/6/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jtreg&pr=6&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-7902870
  Stats: 8 lines in 1 file changed: 6 ins; 0 del; 2 mod
  Patch: https://git.openjdk.java.net/jtreg/pull/6.diff
  Fetch: git fetch https://git.openjdk.java.net/jtreg pull/6/head:pull/6

PR: https://git.openjdk.java.net/jtreg/pull/6


More information about the jtreg-dev mailing list