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

native-image: Include the original cause that led to the failure of CollectionPolicy instantiation #2241

Closed
wants to merge 1 commit into from
Closed

native-image: Include the original cause that led to the failure of CollectionPolicy instantiation #2241

wants to merge 1 commit into from

Conversation

jaikiran
Copy link
Contributor

In Quarkus, we have seen more than one user reporting an exception, during the native-image generation, of the form:

Error: policy com.oracle.svm.core.genscavenge.CollectionPolicy cannot be instantiated.
com.oracle.svm.core.util.UserError$UserException: policy com.oracle.svm.core.genscavenge.CollectionPolicy cannot be instantiated.
        at com.oracle.svm.core.util.UserError.abort(UserError.java:65)
        at com.oracle.svm.core.genscavenge.HeapPolicy.instantiatePolicy(HeapPolicy.java:87)
        at com.oracle.svm.core.genscavenge.CollectionPolicy.getInitialPolicy(CollectionPolicy.java:59)
        at com.oracle.svm.core.genscavenge.GCImpl.<init>(GCImpl.java:148)
        at com.oracle.svm.core.genscavenge.HeapImpl.<init>(HeapImpl.java:106)
        at com.oracle.svm.core.genscavenge.graal.HeapFeature.afterRegistration(HeapFeature.java:65)
        at com.oracle.svm.hosted.NativeImageGenerator.lambda$setupNativeImage$11(NativeImageGenerator.java:812)
        at com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:63)
        at com.oracle.svm.hosted.NativeImageGenerator.setupNativeImage(NativeImageGenerator.java:812)
        at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:528)
        at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:445)
        at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
Error: Image build request failed with exit status 1

like here quarkusio/quarkus#7684 and here quarkusio/quarkus#2414

The error reported doesn't include the root cause which caused the failure.

The commit here now includes the original cause of the exception to help in situations like these.

@jaikiran jaikiran changed the title Include the original cause that led to the failure of CollectionPolicy instantiation native-image: Include the original cause that led to the failure of CollectionPolicy instantiation Mar 10, 2020
@dmlloyd
Copy link
Contributor

dmlloyd commented Mar 10, 2020

I think that this exception is caused by incorrect escaping - the collection policy is actually a nested class of CollectionPolicy; since nested classes contain a $, if there is inadequate escaping of the class name and it passes through Docker (for example) which removes a layer of escaping, then it looks like an environment variable that is undefined, thus the suffix gets lost.

I'm not sure the additional exception cause will help debug this exact error, but it might be useful in other situations.

@jaikiran
Copy link
Contributor Author

I'm not sure the additional exception cause will help debug this exact error, but it might be useful in other situations.

If that's what's happening, I think then this piece of code will try to instantiate (using the no-org constructor) the com.oracle.svm.core.genscavenge.CollectionPolicy which is an abstract class and the exception that gets thrown as a result of that (after this proposed change) will have a clear message stating that as the cause, which IMO should be an hint enough that the escaping went wrong.

@jaikiran
Copy link
Contributor Author

jaikiran commented Mar 10, 2020

which IMO should be an hint enough that the escaping went wrong

Well, now that you mentioned it @dmlloyd, I went back and looked at that exception that's being already thrown:

policy com.oracle.svm.core.genscavenge.CollectionPolicy cannot be instantiated

and compared it to the code throwing it:

throw UserError.abort("policy " + className + " cannot be instantiated.");

So it's already printing the className as com.oracle.svm.core.genscavenge.CollectionPolicy, which means it's a clear hint that the escaping has caused it to lose the rest of the passed class name following the $ sign.

So yes, like you note we may not need this change for the current issue, but it still can be useful in other failures.

@jaikiran
Copy link
Contributor Author

jaikiran commented Jul 1, 2020

Closing this as this is no longer relevant and the linked issue in Quarkus ended up being solved in a different way.

@jaikiran jaikiran closed this Jul 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants