Skip to content

ExceptionsHelper might enter infinite loops or fail with a stack overflow #42340

@jpountz

Description

@jpountz

Cycles in exceptions' causes or suppressions can trigger bugs, try to run eg. the following tests:

    public void testSuppressedCycle() {
        RuntimeException e1 = new RuntimeException();
        RuntimeException e2 = new RuntimeException();
        e1.addSuppressed(e2);
        e2.addSuppressed(e1);
        ExceptionsHelper.unwrapCorruption(e1);
    }

    public void testCauseCycle() {
        RuntimeException e1 = new RuntimeException();
        RuntimeException e2 = new RuntimeException(e1);
        e1.initCause(e2);
        ExceptionsHelper.unwrapCorruption(e1);
    }

The first one fails with a StackOverflowError and the second one enters an infinite loop. It occurred to me while giving another look at #41889 but this is a pre-existing issue.

cc @original-brownbear

Metadata

Metadata

Labels

:Distributed Indexing/StoreIssues around managing unopened Lucene indices. If it touches Store.java, this is a likely label.>bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions