1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Bug 509774 - StackOverflowError in IndexCPPSignatureUtil.getSignature

Change-Id: Ied4755f3bb3013460aae2584c3941b606102e55b
This commit is contained in:
Sergey Prigogin 2016-12-29 20:03:15 -08:00
parent 526f11aabd
commit b6c2d930f4

View file

@ -17,7 +17,9 @@ package org.eclipse.cdt.core.dom.ast;
import java.net.URI;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.WeakHashMap;
import org.eclipse.cdt.core.CCorePlugin;
@ -103,6 +105,13 @@ public class ASTTypeUtil {
}
private static final ThreadLocal<ResultCache> resultCache = new ThreadLocal<>();
private static final ThreadLocal<Set<IBinding>> fSourceFileOnlyCheckInProgress=
new ThreadLocal<Set<IBinding>>() {
@Override
protected Set<IBinding> initialValue() {
return new HashSet<>();
}
};
private ASTTypeUtil() {}
@ -852,13 +861,24 @@ public class ASTTypeUtil {
CCorePlugin.log(e);
}
} else {
IASTNode node = ASTInternal.getDeclaredInSourceFileOnly(binding);
if (node != null) {
IPath filePath = new Path(node.getTranslationUnit().getFilePath());
URI uri = UNCPathConverter.getInstance().toURI(filePath);
result.append('{');
result.append(uri.toString());
result.append('}');
// The ASTInternal.getDeclaredInSourceFileOnly method may call this method
// recursively for the same binding. Since a nested call is done to check if
// the binding has a declaration outside of the source file, inside the nested
// call we assume that the binding is not local to the source file.
// See http://bugs.eclipse.org/509774
if (fSourceFileOnlyCheckInProgress.get().add(binding)) {
try {
IASTNode node = ASTInternal.getDeclaredInSourceFileOnly(binding);
if (node != null) {
IPath filePath = new Path(node.getTranslationUnit().getFilePath());
URI uri = UNCPathConverter.getInstance().toURI(filePath);
result.append('{');
result.append(uri.toString());
result.append('}');
}
} finally {
fSourceFileOnlyCheckInProgress.get().remove(binding);
}
}
}
}