You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Caused by: java.lang.StackOverflowError
at kotlin.jvm.JvmClassMappingKt.getJavaObjectType(JvmClassMapping.kt)
at kotlin.reflect.jvm.internal.KClassImpl.hashCode(KClassImpl.kt:296)
at de.fraunhofer.aisec.cpg.frontends.Language.hashCode(Language.kt:116)
at java.base/java.util.Arrays.hashCode(Arrays.java:4499)
at java.base/java.util.Objects.hash(Objects.java:133)
at de.fraunhofer.aisec.cpg.graph.types.Type.hashCode(Type.kt:189)
at de.fraunhofer.aisec.cpg.graph.types.ObjectType.hashCode(ObjectType.kt:117)
at java.base/java.util.Arrays.hashCode(Arrays.java:4499)
at java.base/java.util.Objects.hash(Objects.java:133)
at de.fraunhofer.aisec.cpg.graph.types.Type$Ancestor.hashCode(Type.kt:206)
at java.base/java.util.HashMap.hash(HashMap.java:338)
at java.base/java.util.HashMap.put(HashMap.java:610)
at java.base/java.util.HashSet.add(HashSet.java:221)
at de.fraunhofer.aisec.cpg.TypeManagerKt.getAncestors(TypeManager.kt:281)
at de.fraunhofer.aisec.cpg.TypeManagerKt.getAncestors(TypeManager.kt:261)
at de.fraunhofer.aisec.cpg.frontends.Language.isDerivedFrom(Language.kt:222)
at de.fraunhofer.aisec.cpg.TypeManagerKt.isDerivedFrom(TypeManager.kt:295)
at de.fraunhofer.aisec.cpg.frontends.Language.hasSignature(Language.kt:260)
at de.fraunhofer.aisec.cpg.graph.declarations.FunctionDeclaration.hasSignature(FunctionDeclaration.kt:128)
at de.fraunhofer.aisec.cpg.graph.declarations.FunctionDeclaration.hasSignature(FunctionDeclaration.kt:114)
at de.fraunhofer.aisec.cpg.passes.SymbolResolver.getInvocationCandidatesFromRecord(SymbolResolver.kt:802)
at de.fraunhofer.aisec.cpg.passes.SymbolResolver.getInvocationCandidatesFromParents(SymbolResolver.kt:817)
at de.fraunhofer.aisec.cpg.passes.SymbolResolver.getInvocationCandidatesFromParents(SymbolResolver.kt:831)
at de.fraunhofer.aisec.cpg.passes.SymbolResolver.getInvocationCandidatesFromParents(SymbolResolver.kt:831)
at de.fraunhofer.aisec.cpg.passes.SymbolResolver.getInvocationCandidatesFromParents(SymbolResolver.kt:831)
at de.fraunhofer.aisec.cpg.passes.SymbolResolver.getInvocationCandidatesFromParents(SymbolResolver.kt:831)
Absolutely, the class SymbolResolver is unreliable.
In this example, it analyze only one java file. My test code is that:
funmyAnalyze(): TranslationResult {
val builder =TranslationConfiguration.builder()
.sourceLocations(listOf(File("myTestJavaFile"))
.loadIncludes(false)
.debugParser(true)
.failOnError(true)
.useParallelFrontends(true).
.registerLanguage<JavaLanguage>()
.registerPass<SymbolResolver>()
val config = builder.build()
val analyzer =TranslationManager.builder().config(config).build()
return analyzer.analyze().get()
}
The java file is that:
/******************************************************************************* * This file is part of OpenNMS(R). * * Copyright (C) 2002-2014 The OpenNMS Group, Inc. * OpenNMS(R) is Copyright (C) 1999-2014 The OpenNMS Group, Inc. * * OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc. * * OpenNMS(R) is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published * by the Free Software Foundation, either version 3 of the License, * or (at your option) any later version. * * OpenNMS(R) is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with OpenNMS(R). If not, see: * http://www.gnu.org/licenses/ * * For more information contact: * OpenNMS(R) Licensing <license@opennms.org> * http://www.opennms.org/ * http://www.opennms.com/ *******************************************************************************/packageorg.opennms.netmgt.config;
importstaticorg.opennms.core.utils.InetAddressUtils.addr;
importstaticorg.opennms.core.utils.InetAddressUtils.toIpAddrBytes;
importjava.io.File;
importjava.io.FileInputStream;
importjava.io.FileWriter;
importjava.io.IOException;
importjava.io.InputStream;
importjava.io.InputStreamReader;
importjava.net.InetAddress;
importjava.util.ArrayList;
importjava.util.Collections;
importjava.util.List;
importorg.apache.commons.collections.ListUtils;
importorg.apache.commons.io.IOUtils;
importorg.opennms.core.utils.ConfigFileConstants;
importorg.opennms.core.xml.JaxbUtils;
importorg.opennms.netmgt.config.collectd.CollectdConfiguration;
importorg.opennms.netmgt.config.collectd.Collector;
importorg.opennms.netmgt.config.collectd.Package;
importorg.opennms.netmgt.config.poller.Monitor;
importorg.opennms.netmgt.filter.FilterDaoFactory;
importorg.opennms.netmgt.model.OnmsIpInterface;
importorg.opennms.netmgt.model.OnmsMonitoredService;
importorg.slf4j.Logger;
importorg.slf4j.LoggerFactory;
/** * This is the singleton class used to load the configuration for the OpenNMS * Collection Daemon from the collectd-configuration.xml file. * * A mapping of the configured URLs to the IP list they contain is built at * init() time so as to avoid numerous file reads. * * <strong>Note: </strong>Users of this class should make sure the * <em>init()</em> is called before calling any other method to ensure the * config is loaded before accessing other convenience methods. * * @author <a href="mailto:jamesz@opennms.com">James Zuo</a> * @author <a href="mailto:mike@opennms.org">Mike Davidson</a> * @author <a href="mailto:sowmya@opennms.org">Sowmya Nataraj</a> */publicclassCollectdConfigFactoryimplementsorg.opennms.netmgt.config.api.CollectdConfigFactory {
privatestaticfinalLoggerLOG = LoggerFactory.getLogger(CollectdConfigFactory.class);
publicstaticfinalStringSELECT_METHOD_MIN = "min";
privateCollectdConfigurationlocalCollectdConfig;
privatefinalObjectm_collectdConfigMutex = newObject();
privatefinalStringm_fileName;
privateList<Package> extendedPackages = Collections.emptyList();
privateList<Package> mergedPackages = Collections.emptyList();
privateList<Collector> extendedCollectors = Collections.emptyList();
privateList<Collector> mergedCollectors = Collections.emptyList();
publicCollectdConfigFactory() throwsIOException {
m_fileName = ConfigFileConstants.getFile(ConfigFileConstants.COLLECTD_CONFIG_FILE_NAME).getPath();
init(newFileInputStream(m_fileName));
}
/** * For testing purposes only. * * @param stream * @throws IOException */publicCollectdConfigFactory(InputStreamstream) throwsIOException {
m_fileName = null;
init(stream);
}
/** * <p>Constructor for CollectdConfigFactory.</p> * * @param stream a {@link java.io.InputStream} object. * @throws IOException */privatevoidinit(finalInputStreamstream) throwsIOException {
InputStreamReaderisr = null;
try {
isr = newInputStreamReader(stream);
CollectdConfigurationconfig = JaxbUtils.unmarshal(CollectdConfiguration.class, isr);
synchronized (m_collectdConfigMutex) {
this.localCollectdConfig = config;
}
} finally {
IOUtils.closeQuietly(isr);
}
this.setUpInternalData();
}
privatevoidsetUpInternalData() {
synchronized (this.m_collectdConfigMutex) {
this.mergedCollectors = ListUtils.union(localCollectdConfig.getCollectors(), this.extendedCollectors);
this.mergedPackages = ListUtils.union(localCollectdConfig.getPackages(), this.extendedPackages);
}
}
/** * Reload the config from the default config file * * @exception java.io.IOException * Thrown if the specified config file cannot be read/loaded * @throws java.io.IOException if any. */publicvoidreload() throwsIOException {
init(newFileInputStream(m_fileName));
}
/** * Saves the current in-memory configuration to disk and reloads * * @throws java.io.IOException if any. */publicvoidsaveCurrent() throwsIOException {
FilecfgFile = ConfigFileConstants.getFile(ConfigFileConstants.COLLECTD_CONFIG_FILE_NAME);
CollectdConfigurationconfig = null;
synchronized (m_collectdConfigMutex) {
config = localCollectdConfig;
}
FileWriterwriter = null;
try {
writer = newFileWriter(cfgFile);
JaxbUtils.marshal(config, writer);
} finally {
IOUtils.closeQuietly(writer);
}
reload();
}
/** * <p>getCollectdConfig</p> * * @return a {@link org.opennms.netmgt.config.collectd.CollectdConfiguration} object. */publicCollectdConfigurationgetLocalCollectdConfig() {
synchronized (m_collectdConfigMutex) {
returnlocalCollectdConfig;
}
}
@OverridepublicIntegergetThreads() {
returnthis.localCollectdConfig.getThreads();
}
/** * Returns true if collection package exists * * @param name * The package name to check * @return True if the package exists */publicbooleanpackageExists(Stringname) {
synchronized (m_collectdConfigMutex) {
for (finalPackagepkg : this.mergedPackages) {
if (pkg.getName().equals(name)) {
returntrue;
}
}
returnfalse;
}
}
/** * <p>getPackage</p> * * @param name a {@link java.lang.String} object. * @return a {@link org.opennms.netmgt.config.collectd.Package} object. */publicPackagegetPackage(finalStringname) {
synchronized (m_collectdConfigMutex) {
for (Packagepkg : this.mergedPackages) {
if (pkg.getName().equals(name)) {
returnpkg;
}
}
returnnull;
}
}
@OverridepublicList<Package> getPackages() {
returnthis.mergedPackages;
}
@OverridepublicList<Collector> getCollectors() {
returnthis.mergedCollectors;
}
/** * Returns true if collection domain exists * * @param name * The domain name to check * @return True if the domain exists */publicbooleandomainExists(finalStringname) {
synchronized (m_collectdConfigMutex) {
for (Packagepkg : this.mergedPackages) {
if ((pkg.getIfAliasDomain() != null)
&& pkg.getIfAliasDomain().equals(name)) {
returntrue;
}
}
returnfalse;
}
}
/** * Returns true if the specified service's interface is included by at least one * package which has the specified service and that service is enabled (set * to "on"). * * @param service * {@link OnmsMonitoredService} to check * @return true if Collectd config contains a package which includes the * specified interface and has the specified service enabled. */publicbooleanisServiceCollectionEnabled(finalOnmsMonitoredServiceservice) {
returnisServiceCollectionEnabled(service.getIpInterface(), service.getServiceName());
}
/** * Returns true if the specified interface is included by at least one * package which has the specified service and that service is enabled (set * to "on"). * * @param iface * {@link OnmsIpInterface} to lookup * @param svcName * The service name to lookup * @return true if Collectd config contains a package which includes the * specified interface and has the specified service enabled. */publicbooleanisServiceCollectionEnabled(finalOnmsIpInterfaceiface, finalStringsvcName) {
for (Packagewpkg : this.mergedPackages) {
// Does the package include the interface?if (interfaceInPackage(iface, wpkg)) {
// Yes, now see if package includes// the service and service is enabled//if (wpkg.serviceInPackageAndEnabled(svcName)) {
// Thats all we need to know...returntrue;
}
}
}
returnfalse;
}
/** * Returns true if the specified interface is included by at least one * package which has the specified service and that service is enabled (set * to "on"). * * @deprecated This function should take normal model objects instead of bare IP addresses * and service names. Use {@link #isServiceCollectionEnabled(OnmsIpInterface, String)} * instead. * * @param ipAddr * IP address of the interface to lookup * @param svcName * The service name to lookup * @return true if Collectd config contains a package which includes the * specified interface and has the specified service enabled. */publicbooleanisServiceCollectionEnabled(finalStringipAddr, finalStringsvcName) {
synchronized (m_collectdConfigMutex) {
for (Packagewpkg : this.mergedPackages) {
// Does the package include the interface?//if (interfaceInPackage(ipAddr, wpkg)) {
// Yes, now see if package includes// the service and service is enabled//if (wpkg.serviceInPackageAndEnabled(svcName)) {
// Thats all we need to know...returntrue;
}
}
}
returnfalse;
}
}
publicbooleaninterfaceInFilter(Stringiface, Packagepkg) {
Stringfilter = pkg.getFilter().getContent();
if (iface == null) returnfalse;
finalInetAddressifaceAddress = addr(iface);
booleanfilterPassed = false;
//// Get a list of IP address per package against the filter rules from// database and populate the package, IP list map.//LOG.debug("interfaceInFilter: package is {}. filter rules are {}", pkg.getName(), filter);
try {
finalList<InetAddress> ipList = FilterDaoFactory.getInstance().getActiveIPAddressList(filter);
filterPassed = ipList.contains(ifaceAddress);
if (!filterPassed) {
LOG.debug("interfaceInFilter: Interface {} passed filter for package {}?: false", iface, pkg.getName());
}
} catch (Throwablet) {
LOG.error("interfaceInFilter: Failed to map package: {} to an IP List with filter \"{}\"", pkg.getName(), pkg.getFilter().getContent(), t);
}
returnfilterPassed;
}
/** * This method is used to determine if the named interface is included in * the passed package definition. If the interface belongs to the package * then a value of true is returned. If the interface does not belong to the * package a false value is returned. * * <strong>Note: </strong>Evaluation of the interface against a package * filter will only work if the IP is already in the database. * * @deprecated This function should take normal model objects instead of bare IP * addresses. Move this implementation into {@link #interfaceInPackage(OnmsIpInterface, Package)}. * * @param iface * The interface to test against the package. * @return True if the interface is included in the package, false * otherwise. */publicbooleaninterfaceInPackage(finalStringiface, Packagepkg) {
booleanfilterPassed = interfaceInFilter(iface, pkg);
if (!filterPassed) {
returnfalse;
}
//// Ensure that the interface is in the specific list or// that it is in the include range and is not excluded//byte[] addr = toIpAddrBytes(iface);
booleanhas_range_include = pkg.hasIncludeRange(iface);
booleanhas_specific = pkg.hasSpecific(addr);
has_specific = pkg.hasSpecificUrl(iface, has_specific);
booleanhas_range_exclude = pkg.hasExcludeRange(iface);
booleanpackagePassed = has_specific || (has_range_include && !has_range_exclude);
if(packagePassed) {
LOG.info("interfaceInPackage: Interface {} passed filter and specific/range for package {}?: {}", iface, pkg.getName(), packagePassed);
} else {
LOG.debug("interfaceInPackage: Interface {} passed filter and specific/range for package {}?: {}", iface, pkg.getName(), packagePassed);
}
returnpackagePassed;
}
/** * This method is used to determine if the named interface is included in * the passed package definition. If the interface belongs to the package * then a value of true is returned. If the interface does not belong to the * package a false value is returned. * * <strong>Note: </strong>Evaluation of the interface against a package * filter will only work if the IP is already in the database. * * @param iface * The interface to test against the package. * @return True if the interface is included in the package, false * otherwise. */publicbooleaninterfaceInPackage(finalOnmsIpInterfaceiface, Packagepkg) {
returninterfaceInPackage(iface.getIpAddressAsString(), pkg);
}
@OverridepublicvoidsetExternalData(finalList<Package> packages, finalList<Collector> collectors) {
synchronized (this.m_collectdConfigMutex) {
this.extendedPackages = packages;
this.extendedCollectors = collectors;
this.setUpInternalData();
}
}
}
The text was updated successfully, but these errors were encountered:
Hi, we're currently about to refactor some things related to imports, types and their (local vs. fqn) naming. I could identify the problem causing your issue and just proposed a fix in #1559 but since this topic is rather complicated and potentially impacts other current developments, we need some more discussion. However, I hope that we can fix your issue soon
The stacktrace is that:
Absolutely, the class
SymbolResolver
is unreliable.In this example, it analyze only one java file. My test code is that:
The java file is that:
The text was updated successfully, but these errors were encountered: