Skip to content

InheritanceVertex#isLibraryMethod stack overflows #1028

Description

@AutumnalModding

Describe the bug

Running illegal name removal on certain samples throws StackOverflowError.
Specifically, the issue is in: if (parent.isLibraryMethod(name, desc))
in the following block:

	public boolean isLibraryMethod(@Nonnull String name, @Nonnull String desc) {
		// Check against this definition
		if (!isPrimary && hasMethod(name, desc))
			return true;

		// Check parents.
		// If we extend a class with a library definition then it should be considered a library method.
		for (InheritanceVertex parent : getParents())
			if (parent.isLibraryMethod(name, desc))
				return true;

		// No library definition found, so its safe to rename.
		return false;
	}

To Reproduce

Steps to reproduce the behavior:

  1. Open this sample in Recaf
  2. Run illegal name removal
  3. Refer to logs for stack overflow

Exception

If applicable, add the exception/stacktrace.

01:17:24.485 [MappingGenerator/JavaFX Application Thread] ERROR: Failed to generate mappings
java.util.concurrent.CompletionException: java.lang.StackOverflowError
        at java.base/java.util.concurrent.CompletableFuture.wrapInCompletionException(CompletableFuture.java:323)
        at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:359)
        at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:364)
        at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1791)
        at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1781)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:511)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1450)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:2019)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:187)
Caused by: java.lang.StackOverflowError
        at software.coley.recaf.services.inheritance.InheritanceVertex.isLibraryMethod(InheritanceVertex.java:200)
        at software.coley.recaf.services.inheritance.InheritanceVertex.isLibraryMethod(InheritanceVertex.java:206)
        at software.coley.recaf.services.inheritance.InheritanceVertex.isLibraryMethod(InheritanceVertex.java:206)
        at software.coley.recaf.services.inheritance.InheritanceVertex.isLibraryMethod(InheritanceVertex.java:206)
        ...

Screenshots

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugYup, thats broken

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions