Skip to content

StackTraceCleaner does not handle infinite cause chains #747

Open
@dsommerich

Description

Example

import com.google.common.truth.Truth;
import org.junit.jupiter.api.Test;

public class TruthTest {
    @Test
    void test() {
        Truth.assertThat(new EvilThrowable()).isSameInstanceAs(new RuntimeException());
    }

    static class EvilThrowable extends Throwable {
        @Override
        public synchronized Throwable getCause() {
            return new EvilThrowable();
        }
    }
}

This example does not terminate, it just spins forever.

I beleive this is because StackTraceCleaner does not implement any kind of hard limit (which is the only way I can think of of how to fix this).

I know this is a very specific edge case, it came up while trying to test code that does a similar thing (traverse a Throwable's causes) with a malicious/very broken implementation of a Throwable.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    P4not scheduledtype=enhancementMake an existing feature better

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions