Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

com.oracle.svm.core.util.VMError$HostedError: should not reach here #518

Closed
dsyer opened this issue Jul 4, 2018 · 2 comments
Closed

com.oracle.svm.core.util.VMError$HostedError: should not reach here #518

dsyer opened this issue Jul 4, 2018 · 2 comments
Assignees

Comments

@dsyer
Copy link

dsyer commented Jul 4, 2018

This application is actually a tiny isolated part of the "func" application that I referred to in #497. The app there actually compiles now, but this one doesn't, so that's a bit weird?

The lines of code that start the stack trace for sure are using reflection in a way that is very hard to configure ahead of time, but this code path will never be hit in this application, so I thought the --report-unsupported-elements-at-runtime flag would be enough to get something runnable.

public class Autowires {

	private Bar bar;

	@Autowired
	public void setBar(Bar bar) {
		this.bar = bar;
	}

	public static void main(String[] args) {
		new Autowires().run();
	}

	private void run() {
		DefaultListableBeanFactory context = new DefaultListableBeanFactory();

		AutowiredAnnotationBeanPostProcessor post = new AutowiredAnnotationBeanPostProcessor();
		post.setBeanFactory(context);
		context.addBeanPostProcessor(post);
		context.registerBeanDefinition("bar",
				BeanDefinitionBuilder
						.genericBeanDefinition(Bar.class, () -> new Bar("bar"))
						.getRawBeanDefinition());
		context.autowireBean(this);
		System.err.println(context.getBean(Bar.class));
		System.err.println(bar);
	}

}

class Bar {

	private String value;

	public Bar() {
	}

	public Bar(String value) {
		this.value = value;
	}

	public String getValue() {
		return this.value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	@Override
	public String toString() {
		return "Foo [value=" + this.value + "]";
	}

}

It runs fine with regular Java:

$ java -cp target/classes/:target/graal-test-0.0.1-SNAPSHOT-shaded.jar Autowires
Foo [value=bar]
Foo [value=bar]

Then

$ mx native-image -H:Name=auto -H:ReflectionConfigurationFiles=${HOME}/dev/scratch/graal/reflect.json --report-unsupported-elements-at-runtime -cp /home/dsyer/dev/scratch/graal/target/classes/:/home/dsyer/dev/scratch/graal/target/graal-test-0.0.1-SNAPSHOT-shaded.jar Autowires
   classlist:     971.47 ms
       (cap):     977.65 ms
       setup:   1,817.68 ms
    analysis:   8,550.10 ms
error: Error encountered while parsing com.oracle.svm.reflect.proxies.Proxy_18_Proxy_proxyClassCache.get(java.lang.Object) 
Parsing context:
	parsing java.lang.reflect.Field.get(Field.java:393)
	parsing org.springframework.beans.TypeConverterDelegate.attemptToConvertStringToEnum(TypeConverterDelegate.java:328)
	parsing org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:254)
	parsing org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:117)
	parsing org.springframework.beans.TypeConverterSupport.doConvert(TypeConverterSupport.java:70)
	parsing org.springframework.beans.TypeConverterSupport.convertIfNecessary(TypeConverterSupport.java:52)
	parsing org.springframework.beans.factory.support.ConstructorResolver.resolvePreparedArguments(ConstructorResolver.java:777)
	parsing org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:410)
	parsing org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1264)
	parsing org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1113)
	parsing org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getSingletonFactoryBeanForTypeCheck(AbstractAutowireCapableBeanFactory.java:960)
	parsing org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryBean(AbstractAutowireCapableBeanFactory.java:834)
	parsing org.springframework.beans.factory.support.AbstractBeanFactory.getType(AbstractBeanFactory.java:635)
	parsing org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveNamedBean(DefaultListableBeanFactory.java:1025)
	parsing org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:339)
	parsing org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:334)
	parsing Autowires.run(Autowires.java:30)
	parsing Autowires.main(Autowires.java:16)
	parsing com.oracle.svm.reflect.proxies.Proxy_1_Autowires_main.invoke(Unknown Source)
	parsing java.lang.reflect.Method.invoke(Method.java:498)
	parsing com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:173)
	parsing com.oracle.svm.core.code.CEntryPointCallStubs.com_002eoracle_002esvm_002ecore_002eJavaMainWrapper_002erun_0028int_002corg_002egraalvm_002enativeimage_002ec_002etype_002eCCharPointerPointer_0029(generated:0)
Original error: org.graalvm.compiler.graph.GraalGraphError: com.oracle.svm.core.util.VMError$HostedError: should not reach here
	at node: 4|LoadField#proxyClassCache
	at org.graalvm.compiler.phases.common.CanonicalizerPhase$Instance.tryCanonicalize(CanonicalizerPhase.java:340)
	at org.graalvm.compiler.phases.common.CanonicalizerPhase$Instance.processNode(CanonicalizerPhase.java:262)
	at org.graalvm.compiler.phases.common.CanonicalizerPhase$Instance.processWorkSet(CanonicalizerPhase.java:241)
	at org.graalvm.compiler.phases.common.CanonicalizerPhase$Instance.run(CanonicalizerPhase.java:211)
	at org.graalvm.compiler.phases.common.CanonicalizerPhase.run(CanonicalizerPhase.java:125)
	at org.graalvm.compiler.phases.common.CanonicalizerPhase.run(CanonicalizerPhase.java:66)
	at org.graalvm.compiler.phases.BasePhase.apply(BasePhase.java:197)
	at org.graalvm.compiler.phases.BasePhase.apply(BasePhase.java:139)
	at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.parse(MethodTypeFlowBuilder.java:206)
	at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.apply(MethodTypeFlowBuilder.java:315)
	at com.oracle.graal.pointsto.flow.MethodTypeFlow.doParse(MethodTypeFlow.java:310)
	at com.oracle.graal.pointsto.flow.MethodTypeFlow.ensureParsed(MethodTypeFlow.java:300)
	at com.oracle.graal.pointsto.flow.MethodTypeFlow.addContext(MethodTypeFlow.java:107)
	at com.oracle.graal.pointsto.DefaultAnalysisPolicy$DefaultVirtualInvokeTypeFlow.onObservedUpdate(DefaultAnalysisPolicy.java:186)
	at com.oracle.graal.pointsto.flow.TypeFlow.notifyObservers(TypeFlow.java:347)
	at com.oracle.graal.pointsto.flow.TypeFlow.update(TypeFlow.java:389)
	at com.oracle.graal.pointsto.BigBang$2.run(BigBang.java:500)
	at com.oracle.graal.pointsto.util.CompletionExecutor.lambda$execute$0(CompletionExecutor.java:174)
	at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402)
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Caused by: com.oracle.svm.core.util.VMError$HostedError: should not reach here
	at com.oracle.svm.core.util.VMError.shouldNotReachHere(VMError.java:62)
	at com.oracle.svm.hosted.substitute.AnnotatedField.allowConstantFolding(AnnotatedField.java:78)
	at com.oracle.svm.hosted.ameta.AnalysisConstantFieldProvider.readConstantField(AnalysisConstantFieldProvider.java:57)
	at org.graalvm.compiler.nodes.util.ConstantFoldUtil.tryConstantFold(ConstantFoldUtil.java:47)
	at org.graalvm.compiler.nodes.java.LoadFieldNode.asConstant(LoadFieldNode.java:157)
	at org.graalvm.compiler.nodes.java.LoadFieldNode.canonical(LoadFieldNode.java:125)
	at org.graalvm.compiler.nodes.java.LoadFieldNode.canonical(LoadFieldNode.java:116)
	at org.graalvm.compiler.nodes.java.LoadFieldNode.canonical(LoadFieldNode.java:66)
	at org.graalvm.compiler.graph.spi.Canonicalizable$Unary.canonical(Canonicalizable.java:99)
	at org.graalvm.compiler.phases.common.CanonicalizerPhase$Instance.tryCanonicalize(CanonicalizerPhase.java:335)
	... 22 more

Error: Image building with exit status 1

@cstancu
Copy link
Member

cstancu commented Jul 5, 2018

@dsyer thanks for reporting. This is indeed weird. We'll look into it.

@peter-hofer
Copy link
Member

This appears to be the same problem as #784, which was fixed in our master branch (but the fix did not make it into 1.0-RC10).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants