Skip to content

ObjectStamp cannot be cast IntegerStamp #497

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

Closed
dsyer opened this issue Jun 24, 2018 · 9 comments
Closed

ObjectStamp cannot be cast IntegerStamp #497

dsyer opened this issue Jun 24, 2018 · 9 comments
Assignees

Comments

@dsyer
Copy link

dsyer commented Jun 24, 2018

I have no idea what this means, or if there is a way for me to configure around it. Here's the error (when generating a native-image):

Caused by: java.lang.ClassCastException: org.graalvm.compiler.core.common.type.ObjectStamp cannot be cast to org.graalvm.compiler.core.common.type.IntegerStamp
	at org.graalvm.compiler.java.BytecodeParser.processReturnValue(BytecodeParser.java:2529)
	at org.graalvm.compiler.java.BytecodeParser.genReturn(BytecodeParser.java:2508)
	at com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.genReturn(SharedGraphBuilderPhase.java:349)
	at org.graalvm.compiler.java.BytecodeParser.processBytecode(BytecodeParser.java:4784)
	at org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3115)
	... 21 more
@mukel
Copy link
Member

mukel commented Jun 24, 2018

This seems to happen when "fixing" sub-word values for primitive return values (getting a reference instead). It could be some ill-formed bytecode... and there's been some related changes lately; Can you please provide more details? Graal version? And if possible a way to reproduce?

@dsyer
Copy link
Author

dsyer commented Jun 25, 2018

I was using rc2. You can reproduce using the "func" branch here: https://github.com/dsyer/spring-boot-micro-apps/tree/func. Follow the instructions in the README, but use com.example.func.FuncApplication instead of MicroApplication (which works).

@mukel
Copy link
Member

mukel commented Jun 29, 2018

Thanks for reporting, a fix is already being reviewed. It won't be out for RC3; you'll have to wait for RC4 or build SVM from source; there's no quick workaround. I'll close this issue when it's merged.
MicroApplication compiles and runs fine.
FuncApplication compiles but fails at runtime, here's the log:

mx native-image -Dio.netty.noUnsafe=true -H:Name=func -H:ReflectionConfigurationFiles=./playground/dsyer/spring-boot-micro-apps/graal.json --report-unsupported-elements-at-runtime -cp $CP com.example.func.FuncApplication

   classlist:   2,888.01 ms
       (cap):   1,468.78 ms
       setup:   2,607.46 ms
Jun 29, 2018 2:14:10 PM io.netty.util.internal.logging.Slf4JLogger info
INFO: Your platform does not provide complete low-level API for accessing direct buffers reliably. Unless explicitly requested, heap buffer will always be preferred to avoid potential system instability.
RecomputeFieldValue.ArrayIndexScale automatic substitution failed. The automatic substitution registration was attempted because a call to sun.misc.Unsafe.arrayIndexScale(Class) was detected in the static initializer of io.netty.util.internal.shaded.org.jctools.util.UnsafeRefArrayAccess. Add a RecomputeFieldValue.ArrayIndexScale manual substitution for io.netty.util.internal.shaded.org.jctools.util.UnsafeRefArrayAccess. 
  (typeflow):  17,253.19 ms
   (objects):  12,827.78 ms
  (features):     383.32 ms
    analysis:  31,351.20 ms
    universe:     916.64 ms
     (parse):   2,671.71 ms
    (inline):   2,552.73 ms
   (compile):  11,442.58 ms
     compile:  17,764.03 ms
       image:   2,328.21 ms
       write:     620.77 ms
     [total]:  58,618.58 ms

$ ./func 
Jun 29, 2018 2:15:04 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext@68f50e3a: startup date [Fri Jun 29 14:15:04 CEST 2018]; root of context hierarchy
Jun 29, 2018 2:15:04 PM org.springframework.context.support.AbstractApplicationContext refresh
WARNING: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start reactive web server; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.web.embedded.netty.NettyReactiveWebServerFactory': Initialization of bean failed; nested exception is org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.ServerProperties': Could not bind properties to 'ServerProperties' : prefix=server, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.context.properties.ConversionServiceDeducer$Factory': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.context.properties.ConversionServiceDeducer$Factory]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.springframework.boot.context.properties.ConversionServiceDeducer$Factory.<init>()
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at java.lang.Throwable.<init>(Throwable.java:310)
        at java.lang.Exception.<init>(Exception.java:102)
        at java.lang.ReflectiveOperationException.<init>(ReflectiveOperationException.java:89)
        at java.lang.reflect.InvocationTargetException.<init>(InvocationTargetException.java:72)
        at com.oracle.svm.reflect.proxies.Proxy_1_FuncApplication_main.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:173)
Caused by: org.springframework.context.ApplicationContextException: Unable to start reactive web server; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.web.embedded.netty.NettyReactiveWebServerFactory': Initialization of bean failed; nested exception is org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.ServerProperties': Could not bind properties to 'ServerProperties' : prefix=server, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.context.properties.ConversionServiceDeducer$Factory': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.context.properties.ConversionServiceDeducer$Factory]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.springframework.boot.context.properties.ConversionServiceDeducer$Factory.<init>()
        at java.lang.Throwable.<init>(Throwable.java:287)
        at java.lang.Exception.<init>(Exception.java:84)
        at java.lang.RuntimeException.<init>(RuntimeException.java:80)
        at org.springframework.core.NestedRuntimeException.<init>(NestedRuntimeException.java:66)
        at org.springframework.beans.BeansException.<init>(BeansException.java:50)
        at org.springframework.beans.FatalBeanException.<init>(FatalBeanException.java:45)
        at org.springframework.context.ApplicationContextException.<init>(ApplicationContextException.java:45)
        at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.onRefresh(ReactiveWebServerApplicationContext.java:76)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544)
        at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:61)
        at com.example.func.FuncApplication.run(FuncApplication.java:111)
        at com.example.func.FuncApplication.main(FuncApplication.java:92)
        ... 3 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.web.embedded.netty.NettyReactiveWebServerFactory': Initialization of bean failed; nested exception is org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.ServerProperties': Could not bind properties to 'ServerProperties' : prefix=server, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.context.properties.ConversionServiceDeducer$Factory': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.context.properties.ConversionServiceDeducer$Factory]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.springframework.boot.context.properties.ConversionServiceDeducer$Factory.<init>()
        at java.lang.Throwable.<init>(Throwable.java:265)
        at java.lang.Exception.<init>(Exception.java:66)
        at java.lang.RuntimeException.<init>(RuntimeException.java:62)
        at org.springframework.core.NestedRuntimeException.<init>(NestedRuntimeException.java:56)
        at org.springframework.beans.BeansException.<init>(BeansException.java:40)
        at org.springframework.beans.FatalBeanException.<init>(FatalBeanException.java:35)
        at org.springframework.beans.factory.BeanCreationException.<init>(BeanCreationException.java:93)
        at org.springframework.beans.factory.BeanCreationException.<init>(BeanCreationException.java:108)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:589)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:503)
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317)
        at org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$463/1747119870.getObject(Unknown Source)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)
        at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.getWebServerFactory(ReactiveWebServerApplicationContext.java:135)
        at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.createWebServer(ReactiveWebServerApplicationContext.java:99)
        at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.onRefresh(ReactiveWebServerApplicationContext.java:73)
        ... 7 more
Caused by: org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.ServerProperties': Could not bind properties to 'ServerProperties' : prefix=server, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.context.properties.ConversionServiceDeducer$Factory': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.context.properties.ConversionServiceDeducer$Factory]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.springframework.boot.context.properties.ConversionServiceDeducer$Factory.<init>()
        at java.lang.Throwable.<init>(Throwable.java:265)
        at java.lang.Exception.<init>(Exception.java:66)
        at java.lang.RuntimeException.<init>(RuntimeException.java:62)
        at org.springframework.core.NestedRuntimeException.<init>(NestedRuntimeException.java:56)
        at org.springframework.beans.BeansException.<init>(BeansException.java:40)
        at org.springframework.beans.FatalBeanException.<init>(FatalBeanException.java:35)
        at org.springframework.beans.factory.BeanCreationException.<init>(BeanCreationException.java:70)
        at org.springframework.beans.factory.BeanCreationException.<init>(BeanCreationException.java:81)
        at org.springframework.boot.context.properties.ConfigurationPropertiesBindException.<init>(ConfigurationPropertiesBindException.java:38)
        at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.bind(ConfigurationPropertiesBindingPostProcessor.java:110)
        at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:93)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:424)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1700)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:581)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:503)
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317)
        at org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$463/1747119870.getObject(Unknown Source)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:224)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveNamedBean(DefaultListableBeanFactory.java:1015)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:339)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:334)
        at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1107)
        at com.example.func.FuncApplication.lambda$registerReactiveWebServerFactoryAutoConfiguration$11(FuncApplication.java:193)
        at com.example.func.FuncApplication$$Lambda$410/41351020.get(Unknown Source)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1153)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1101)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:503)
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317)
        at org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$463/1747119870.getObject(Unknown Source)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:515)
        at org.springframework.boot.web.server.WebServerFactoryCustomizerBeanPostProcessor.getWebServerFactoryCustomizerBeans(WebServerFactoryCustomizerBeanPostProcessor.java:94)
        at org.springframework.boot.web.server.WebServerFactoryCustomizerBeanPostProcessor.getCustomizers(WebServerFactoryCustomizerBeanPostProcessor.java:84)
        at org.springframework.boot.web.server.WebServerFactoryCustomizerBeanPostProcessor.postProcessBeforeInitialization(WebServerFactoryCustomizerBeanPostProcessor.java:75)
        at org.springframework.boot.web.server.WebServerFactoryCustomizerBeanPostProcessor.postProcessBeforeInitialization(WebServerFactoryCustomizerBeanPostProcessor.java:61)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:424)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1700)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:581)
        ... 16 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.context.properties.ConversionServiceDeducer$Factory': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.context.properties.ConversionServiceDeducer$Factory]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.springframework.boot.context.properties.ConversionServiceDeducer$Factory.<init>()
        at java.lang.Throwable.<init>(Throwable.java:265)
        at java.lang.Exception.<init>(Exception.java:66)
        at java.lang.RuntimeException.<init>(RuntimeException.java:62)
        at org.springframework.core.NestedRuntimeException.<init>(NestedRuntimeException.java:56)
        at org.springframework.beans.BeansException.<init>(BeansException.java:40)
        at org.springframework.beans.FatalBeanException.<init>(FatalBeanException.java:35)
        at org.springframework.beans.factory.BeanCreationException.<init>(BeanCreationException.java:93)
        at org.springframework.beans.factory.BeanCreationException.<init>(BeanCreationException.java:108)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1238)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1137)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:503)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:305)
        at org.springframework.boot.context.properties.ConversionServiceDeducer.getConversionService(ConversionServiceDeducer.java:53)
        at org.springframework.boot.context.properties.ConfigurationPropertiesBinder.getConversionService(ConfigurationPropertiesBinder.java:151)
        at org.springframework.boot.context.properties.ConfigurationPropertiesBinder.getBinder(ConfigurationPropertiesBinder.java:135)
        at org.springframework.boot.context.properties.ConfigurationPropertiesBinder.bind(ConfigurationPropertiesBinder.java:82)
        at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.bind(ConfigurationPropertiesBindingPostProcessor.java:107)
        ... 49 more
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.context.properties.ConversionServiceDeducer$Factory]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.springframework.boot.context.properties.ConversionServiceDeducer$Factory.<init>()
        at java.lang.Throwable.<init>(Throwable.java:287)
        at java.lang.Exception.<init>(Exception.java:84)
        at java.lang.RuntimeException.<init>(RuntimeException.java:80)
        at org.springframework.core.NestedRuntimeException.<init>(NestedRuntimeException.java:66)
        at org.springframework.beans.BeansException.<init>(BeansException.java:50)
        at org.springframework.beans.FatalBeanException.<init>(FatalBeanException.java:45)
        at org.springframework.beans.BeanInstantiationException.<init>(BeanInstantiationException.java:59)
        at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:83)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1230)
        ... 58 more
Caused by: java.lang.NoSuchMethodException: org.springframework.boot.context.properties.ConversionServiceDeducer$Factory.<init>()
        at java.lang.Throwable.<init>(Throwable.java:265)
        at java.lang.Exception.<init>(Exception.java:66)
        at java.lang.ReflectiveOperationException.<init>(ReflectiveOperationException.java:56)
        at java.lang.NoSuchMethodException.<init>(NoSuchMethodException.java:51)
        at java.lang.Class.getConstructor0(Class.java:3082)
        at java.lang.Class.getDeclaredConstructor(Class.java:2178)
        at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:78)
        ... 59 more

@mukel
Copy link
Member

mukel commented Jul 2, 2018

Fixed in fda115b

@dsyer
Copy link
Author

dsyer commented Jul 23, 2018

This was marked as fixed before rc3 was released. I just tried rc4 and it's still broken even with the MicroApplication. Do we need a new issue, or just some more clarity on when this fix is going to be released?

The func branch of the repo above is up to date, and I split the JSON config into micro.json (works with MicroApplication) and func.json (formerly worked with BuncApplication) when I compiled graal from source before rc4.

So MicroApplication actually does still work, but not if you try and use the wrong JSON (e.g. just switch micro.json for func.json and you get the error above). The FuncApplication and BuncApplication both fail the same way.

@dsyer
Copy link
Author

dsyer commented Jul 26, 2018

More data: deleting stuff systematically from func.json until it works, it appears that the ClassCastException first appears when you add this to the JSON:

	{
		"name": "org.springframework.boot.web.server.WebServerFactoryCustomizerBeanPostProcessor",
		"methods": [
			{
				"name": "<init>",
				"parameterTypes": []
			}
		]
	}

So in fact, using a JSON file with just that entry is enough to break the compilation in a native-image build. I don't think the code in WebServerFactoryCustomizerBeanPostProcessor has changed lately, so something in graal did change I guess. Hopefully this will make it easier to pinpoint.

@sdeleuze
Copy link
Collaborator

sdeleuze commented Jul 27, 2018

@dougxc @mukel Is fda115b part of RC4? If yes, this issue should probably be reopened.

@mukel
Copy link
Member

mukel commented Jul 29, 2018

Landed just after the freeze, should be out for RC5.

@dsyer
Copy link
Author

dsyer commented Jul 29, 2018

How about using the "milestone" feature in Github to track that?

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