1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 17:56:01 +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.net.URI;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.BitSet; import java.util.BitSet;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import org.eclipse.cdt.core.CCorePlugin; 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<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() {} private ASTTypeUtil() {}
@ -852,6 +861,13 @@ public class ASTTypeUtil {
CCorePlugin.log(e); CCorePlugin.log(e);
} }
} else { } else {
// 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); IASTNode node = ASTInternal.getDeclaredInSourceFileOnly(binding);
if (node != null) { if (node != null) {
IPath filePath = new Path(node.getTranslationUnit().getFilePath()); IPath filePath = new Path(node.getTranslationUnit().getFilePath());
@ -860,6 +876,10 @@ public class ASTTypeUtil {
result.append(uri.toString()); result.append(uri.toString());
result.append('}'); result.append('}');
} }
} finally {
fSourceFileOnlyCheckInProgress.get().remove(binding);
}
}
} }
} }
} else if (binding instanceof IType && owner instanceof ICPPFunction) { } else if (binding instanceof IType && owner instanceof ICPPFunction) {