[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-compiler-dev
Subject:    Integrated: 8324809: compiler can crash with SOE while proving if two recursive types are disjoint
From:       Vicente Romero <vromero () openjdk ! org>
Date:       2024-05-17 14:19:09
Message-ID: kiLLxSyLkyuIu5Vl1FsJqFmFZKGvIFCXQY0uUrcXByc=.3c7e4b17-720e-4df2-bb9b-961527ed7a8f () github ! com
[Download RAW message or body]

On Sat, 11 May 2024 22:18:12 GMT, Vicente Romero <vromero@openjdk.org> wrote:

> javac is crashing with SOE while compiling code like:
> 
> 
> class Criteria<B extends Builder<? extends Criteria>> {
> public <D extends Builder<E>, E extends Criteria<D>> D builder() {
> return (D) new Builder<>();
> }
> 
> }
> 
> class Builder<C extends Criteria<? extends Builder<C>>> {}
> 
> 
> here while attributing: `return (D)new Builder<>();` the compiler is trying to \
> prove that: `Builder<C>` is castable to `D`, then as the upper bound of `D` is \
> `Builder<E>`, we need to check if `Builder<C>` is castable to `Builder<E>`. Then \
> the next step is to try to check if type variables C and E are disjoint. During \
> this process is when the compiler gets out of resources given that 
> E <: Criteria<D>
> D <: Builder<E> here we have E again and we start over in an infinite loop,
> 
> Here the proposal is to detect cycles in the type arguments graph and accept these \
> type of casts if we find a cycle and thus can't prove if two types are disjoint, 
> TIA

This pull request has now been integrated.

Changeset: 39a55e97
Author:    Vicente Romero <vromero@openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/39a55e97799b5328da85aaa66c8d23175b305691
                
Stats:     57 lines in 2 files changed: 50 ins; 0 del; 7 mod

8324809: compiler can crash with SOE while proving if two recursive types are \
disjoint

Reviewed-by: mcimadamore

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

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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic