Skip to content

sbt throws a StackOverflowError when reporting a self-referencing exception. #7509

@facewindu

Description

@facewindu

steps

Use this reproducer and execute sbt failingTask.

problem

A java.lang.StackOverflowError is thrown. This could be avoided by handling the recursion in the Throwable cause, similarly to how the JDK handles this when printing stacktraces.

// Guard against malicious overrides of Throwable.equals by
// using a Set with identity equality semantics.
Set<Throwable> dejaVu = Collections.newSetFromMap(new IdentityHashMap<Throwable, Boolean>());

...

if (dejaVu.contains(this)) {
  s.println(prefix + caption + "[CIRCULAR REFERENCE: " + this + "]"); // <---- This gets the code out of the recursion
}

expectation

The build is resilient to such Throwables.

notes

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions