Re: RFR: 8331320: ClassFile API OutOfMemoryError with certain class files [v2]

2024-05-02 Thread Paul Sandoz
On Thu, 2 May 2024 11:13:22 GMT, Adam Sotona  wrote:

>> Class files with specifically corrupted tableswitch or lookupswitch 
>> instructions in the bytecode cause OutOfMemoryError while parsing with 
>> Class-File API.
>> This patch performs additional checks to avoid OOME and adds relevant tests.
>> 
>> Please review.
>> 
>> Thank you,
>> Adam
>
> Adam Sotona has updated the pull request with a new target base due to a 
> merge or a rebase. The incremental webrev excludes the unrelated changes 
> brought in by the merge/rebase. The pull request contains two additional 
> commits since the last revision:
> 
>  - Merge branch 'master' into JDK-8331320-OOME
>  - 8331320: ClassFile API OutOfMemoryError with certain class files

Marked as reviewed by psandoz (Reviewer).

-

PR Review: https://git.openjdk.org/jdk/pull/19024#pullrequestreview-2036210957


Re: RFR: 8331320: ClassFile API OutOfMemoryError with certain class files [v2]

2024-05-02 Thread Adam Sotona
> Class files with specifically corrupted tableswitch or lookupswitch 
> instructions in the bytecode cause OutOfMemoryError while parsing with 
> Class-File API.
> This patch performs additional checks to avoid OOME and adds relevant tests.
> 
> Please review.
> 
> Thank you,
> Adam

Adam Sotona has updated the pull request with a new target base due to a merge 
or a rebase. The incremental webrev excludes the unrelated changes brought in 
by the merge/rebase. The pull request contains two additional commits since the 
last revision:

 - Merge branch 'master' into JDK-8331320-OOME
 - 8331320: ClassFile API OutOfMemoryError with certain class files

-

Changes:
  - all: https://git.openjdk.org/jdk/pull/19024/files
  - new: https://git.openjdk.org/jdk/pull/19024/files/7a3f37c1..914ae074

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk=19024=01
 - incr: https://webrevs.openjdk.org/?repo=jdk=19024=00-01

  Stats: 2966 lines in 194 files changed: 1373 ins; 409 del; 1184 mod
  Patch: https://git.openjdk.org/jdk/pull/19024.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/19024/head:pull/19024

PR: https://git.openjdk.org/jdk/pull/19024


Re: RFR: 8331320: ClassFile API OutOfMemoryError with certain class files

2024-04-30 Thread ExE Boss
On Tue, 30 Apr 2024 18:18:30 GMT, Paul Sandoz  wrote:

>> Class files with specifically corrupted tableswitch or lookupswitch 
>> instructions in the bytecode cause OutOfMemoryError while parsing with 
>> Class-File API.
>> This patch performs additional checks to avoid OOME and adds relevant tests.
>> 
>> Please review.
>> 
>> Thank you,
>> Adam
>
> src/java.base/share/classes/jdk/internal/classfile/impl/AbstractInstruction.java
>  line 320:
> 
>> 318: int low = code.classReader.readInt(ap + 4);
>> 319: int high = code.classReader.readInt(ap + 8);
>> 320: if (high < low || high - low > code.codeLength >> 2) {
> 
> May be its also an opportunity to reduce duplication e.g., replace line 316 
> with a call to `afterPadding()`

`BoundTableSwitchInstruction​::afterPadding()` is an instance method, and 
`BoundTableSwitchInstruction​::size(…)` is a static method, so this would 
require further refactoring.

-

PR Review Comment: https://git.openjdk.org/jdk/pull/19024#discussion_r1585700103


Re: RFR: 8331320: ClassFile API OutOfMemoryError with certain class files

2024-04-30 Thread Paul Sandoz
On Tue, 30 Apr 2024 15:31:02 GMT, Adam Sotona  wrote:

> Class files with specifically corrupted tableswitch or lookupswitch 
> instructions in the bytecode cause OutOfMemoryError while parsing with 
> Class-File API.
> This patch performs additional checks to avoid OOME and adds relevant tests.
> 
> Please review.
> 
> Thank you,
> Adam

src/java.base/share/classes/jdk/internal/classfile/impl/AbstractInstruction.java
 line 320:

> 318: int low = code.classReader.readInt(ap + 4);
> 319: int high = code.classReader.readInt(ap + 8);
> 320: if (high < low || high - low > code.codeLength >> 2) {

May be its also an opportunity to reduce duplication e.g., replace line 316 
with a call to `afterPadding()`

-

PR Review Comment: https://git.openjdk.org/jdk/pull/19024#discussion_r1585300727


RFR: 8331320: ClassFile API OutOfMemoryError with certain class files

2024-04-30 Thread Adam Sotona
Class files with specifically corrupted tableswitch or lookupswitch 
instructions in the bytecode cause OutOfMemoryError while parsing with 
Class-File API.
This patch performs additional checks to avoid OOME and adds relevant tests.

Please review.

Thank you,
Adam

-

Commit messages:
 - 8331320: ClassFile API OutOfMemoryError with certain class files

Changes: https://git.openjdk.org/jdk/pull/19024/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk=19024=00
  Issue: https://bugs.openjdk.org/browse/JDK-8331320
  Stats: 60 lines in 2 files changed: 59 ins; 0 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/19024.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/19024/head:pull/19024

PR: https://git.openjdk.org/jdk/pull/19024