Skip to content

Conversation

@dmlloyd
Copy link
Contributor

@dmlloyd dmlloyd commented Jun 19, 2019

Partially fixes #1398

@cstancu
Copy link
Member

cstancu commented Jun 19, 2019

Can you come up with a simple test that exercises this code at least partially that we can add under com.oracle.svm.test?

@dmlloyd
Copy link
Contributor Author

dmlloyd commented Jun 20, 2019

Sure, maybe I can adapt the original test case.

@dmlloyd
Copy link
Contributor Author

dmlloyd commented Jun 20, 2019

Done.

@cstancu
Copy link
Member

cstancu commented Jun 20, 2019

This currently fails on Darwin with:

Error: Error compiling query code (in /var/folders/gw/2lg06ffn6zvb2svk9svvmrym0000gp/T/SVM-2074132810265460097/PosixDirectives.c). Compiler command  gcc /var/folders/gw/2lg06ffn6zvb2svk9svvmrym0000gp/T/SVM-2074132810265460097/PosixDirectives.c -o /var/folders/gw/2lg06ffn6zvb2svk9svvmrym0000gp/T/SVM-2074132810265460097/PosixDirectives output included error: /var/folders/gw/2lg06ffn6zvb2svk9svvmrym0000gp/T/SVM-2074132810265460097/PosixDirectives.c:899:110: error: use of undeclared identifier 'IPV6_ADD_MEMBERSHIP'
    method com.oracle.svm.core.posix.headers.Pthread.PTHREAD_CANCEL_DISABLE()
    C file contents around line 899:
    /var/folders/gw/2lg06ffn6zvb2svk9svvmrym0000gp/T/SVM-2074132810265460097/PosixDirectives.c:898:     printf("NativeCodeInfo:PosixDirectives:ConstantInfo:PTHREAD_CANCEL_DISABLE:PropertyInfo:value=%lX\n", PTHREAD_CANCEL_DISABLE);
    /var/folders/gw/2lg06ffn6zvb2svk9svvmrym0000gp/T/SVM-2074132810265460097/PosixDirectives.c:899:     printf("NativeCodeInfo:PosixDirectives:ConstantInfo:IPV6_ADD_MEMBERSHIP:PropertyInfo:size=%lu\n", sizeof(IPV6_ADD_MEMBERSHIP));
    /var/folders/gw/2lg06ffn6zvb2svk9svvmrym0000gp/T/SVM-2074132810265460097/PosixDirectives.c:900:     printf("NativeCodeInfo:PosixDirectives:ConstantInfo:IPV6_ADD_MEMBERSHIP:PropertyInfo:signedness=$%s$\n", (IS_CONST_UNSIGNED(IPV6_ADD_MEMBERSHIP)) ? "UNSIGNED" : "SIGNED");

@dmlloyd
Copy link
Contributor Author

dmlloyd commented Jun 20, 2019

OK I'll check it out. I think I have an idea of what the problem might be.

@dmlloyd
Copy link
Contributor Author

dmlloyd commented Jun 20, 2019

My local build is still running on my really slow Mac but this should fix the problem. Just out of curiosity - how do you get the tests to run as a native image?

@cstancu
Copy link
Member

cstancu commented Jun 20, 2019

You can use the mx native-unittest in substratevm like so:

~/graal/substratevm$ mx native-unittest GitHub1398
Building junit image for matching: com.oracle.svm.test.GitHub1398
Build on Server(pid: 14943, port: 44121)*
[com.oracle.svm.junit.svmjunitrunner:14943]    classlist:   1,309.45 ms
[com.oracle.svm.junit.svmjunitrunner:14943]        (cap):   1,186.72 ms
[com.oracle.svm.junit.svmjunitrunner:14943]        setup:   2,638.80 ms
[com.oracle.svm.junit.svmjunitrunner:14943]   (typeflow):   4,862.05 ms
[com.oracle.svm.junit.svmjunitrunner:14943]    (objects):   2,942.30 ms
[com.oracle.svm.junit.svmjunitrunner:14943]   (features):     234.29 ms
[com.oracle.svm.junit.svmjunitrunner:14943]     analysis:   8,237.48 ms
[com.oracle.svm.junit.svmjunitrunner:14943]     (clinit):     126.05 ms
[com.oracle.svm.junit.svmjunitrunner:14943]     universe:     437.07 ms
[com.oracle.svm.junit.svmjunitrunner:14943]      (parse):     852.09 ms
[com.oracle.svm.junit.svmjunitrunner:14943]     (inline):   3,245.91 ms
[com.oracle.svm.junit.svmjunitrunner:14943]    (compile):  10,054.97 ms
[com.oracle.svm.junit.svmjunitrunner:14943]      compile:  17,544.09 ms
[com.oracle.svm.junit.svmjunitrunner:14943]        image:     717.03 ms
[com.oracle.svm.junit.svmjunitrunner:14943]        write:     154.42 ms
[com.oracle.svm.junit.svmjunitrunner:14943]      [total]:  31,190.11 ms
Running: /home/cdrtz/projects/graal-ee-ws-0/graal/substratevm/svmbuild/linux-amd64/junit/tmpdWkVy_/com.oracle.svm.junit.svmjunitrunner --verbose
SVMJUnitCore
JUnit version 4.12
com.oracle.svm.test.GitHub1398 started (1 of 1)
  testMulticast: MulticastSocket: local=0.0.0.0/0.0.0.0:6789, remote=null
Passed
com.oracle.svm.test.GitHub1398 finished
Time: 0

OK (1 test)

@dmlloyd
Copy link
Contributor Author

dmlloyd commented Jun 20, 2019

Thanks!

@dmlloyd
Copy link
Contributor Author

dmlloyd commented Jun 20, 2019

Looks like there's one more problem. On it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really understand this comment. Also, can you please add some asserts in the test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The success condition is simply that the test completes without error. I can try to think of something else to add though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even something as simple as an Assert.fail() on exception, like we do for GitHub1087 test.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I think that might be unused in the upstream code as well. For now I just removed the useless declaration.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmlloyd
Copy link
Contributor Author

dmlloyd commented Jun 20, 2019

It looks as though wrapping with IsDefined.__linux__() is not sufficient to make the code analyzer happy with the usage of LinuxIn, so I'll have to split this into two methods. Is it allowed to create e.g. a mcast_join_leave_Linux with @Platforms(Platform.LINUX.class) and similarly one for Darwin? Can I put both methods in this class, or should I make two more classes in this file for the Linux- and Darwin-specific versions?

@cstancu
Copy link
Member

cstancu commented Jun 20, 2019

I wonder why IsDefined.__linux__() doesn't work as that should be constant folded.

@dmlloyd
Copy link
Contributor Author

dmlloyd commented Jun 20, 2019

Yeah I was surprised too. It didn't give me a line number, it happened during pointsto analysis:

com.oracle.svm.core.util.UserError$UserException: type is not available in this platform: com.oracle.svm.core.posix.headers.linux.LinuxIn
Detailed message:

	at com.oracle.svm.core.util.UserError.abort(UserError.java:75)
	at com.oracle.svm.hosted.FallbackFeature.reportAsFallback(FallbackFeature.java:216)
	at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:732)
	at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:522)
	at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:440)
	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)
Caused by: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: type is not available in this platform: com.oracle.svm.core.posix.headers.linux.LinuxIn
Detailed message:

	at com.oracle.graal.pointsto.constraints.UnsupportedFeatures.report(UnsupportedFeatures.java:130)
	at com.oracle.graal.pointsto.BigBang.finish(BigBang.java:565)
	at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:683)
	... 8 more
Caused by: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: type is not available in this platform: com.oracle.svm.core.posix.headers.linux.LinuxIn
	at com.oracle.graal.pointsto.meta.AnalysisUniverse.createType(AnalysisUniverse.java:212)
	at com.oracle.graal.pointsto.meta.AnalysisUniverse.lookupAllowUnresolved(AnalysisUniverse.java:203)
	at com.oracle.graal.pointsto.meta.AnalysisUniverse.lookup(AnalysisUniverse.java:180)
	at com.oracle.graal.pointsto.meta.AnalysisType.getEnclosingType(AnalysisType.java:947)
	at com.oracle.svm.hosted.analysis.Inflation.checkType(Inflation.java:162)
	at java.base/java.lang.Iterable.forEach(Iterable.java:75)
	at java.base/java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1083)
	at com.oracle.svm.hosted.analysis.Inflation.checkObjectGraph(Inflation.java:136)
	at com.oracle.graal.pointsto.BigBang.checkObjectGraph(BigBang.java:603)
	at com.oracle.graal.pointsto.BigBang.finish(BigBang.java:558)
	... 9 more
Error: Image build request failed with exit status 1

@cstancu
Copy link
Member

cstancu commented Jun 20, 2019

Can you try cleaning and rebuilding? I just finished running your latest version (from 3 hours ago) through our internal gate and I don't see the error: use of undeclared identifier 'IPV6_ADD_MEMBERSHIP' anymore, so I am not really sure that I understand where IsDefined.__linux__() is failing.

@dmlloyd
Copy link
Contributor Author

dmlloyd commented Jun 20, 2019

OK, I'll give it a shot.

@dmlloyd
Copy link
Contributor Author

dmlloyd commented Jun 20, 2019

I cleaned everything and rebuilt and the error remains. I've pushed up the commits with fixes as previously described, and hopefully you can get the same error I am.

@bobmcwhirter
Copy link

bobmcwhirter commented Jun 21, 2019 via email

@cstancu
Copy link
Member

cstancu commented Jun 21, 2019

@bobmcwhirter the one that travis downloads. That should be done automatically, I raised this issue with the right people already.

@cstancu
Copy link
Member

cstancu commented Jun 21, 2019

@dmlloyd I run the latest changes in your PR through our internal gate (after fixing the remaining style issues) and all the gates pass. Do you see the error in one of your tests or in the general build?

@dmlloyd
Copy link
Contributor Author

dmlloyd commented Jun 21, 2019

I'm seeing the error when I run mx native-unittest GitHub1398.

@dmlloyd
Copy link
Contributor Author

dmlloyd commented Jun 21, 2019

Maybe you can sanity-check me. Here are the steps I'm running:

$ cd substratevm
$ mx clean
$ cd ../vm
$ mx clean
$ mx --dynamicimports /substratevm --disable-polyglot --disable-libpolyglot build
$ cd ../substratevm
$ mx native-unittest GitHub1398

Am I forgetting something obvious?

@dmlloyd
Copy link
Contributor Author

dmlloyd commented Jun 21, 2019

I'm running through the steps one more time just to be certain...

@dmlloyd
Copy link
Contributor Author

dmlloyd commented Jun 21, 2019

Same error. I'm going to update my JDK just to see if that matters.

@dmlloyd
Copy link
Contributor Author

dmlloyd commented Jun 21, 2019

One other thing to note is that I'm testing with Java 11, not Java 8.

@dmlloyd
Copy link
Contributor Author

dmlloyd commented Jun 21, 2019

I wonder - the exception occurs in BigBang.finish; isn't this after constant folding would have been done?

@dmlloyd
Copy link
Contributor Author

dmlloyd commented Jun 21, 2019

Pushed up another style fix.

@cstancu
Copy link
Member

cstancu commented Jun 21, 2019

@dmlloyd the steps that you are running look good to me. I don't have access to a Mac to try to debug the issue; maybe @vjovanov can help.

BigBang.finish() is an intermediate step in the fixpoint analysis, but there should be constant folding happening before that. Plus, IsDefined.__linux__() is annotated with @Fold.

@dmlloyd
Copy link
Contributor Author

dmlloyd commented Jun 24, 2019

I don't know what that last CI failure is all about. It looks like mx itself has crashed?

@vjovanov
Copy link
Member

Ignore it, we have an issue for that.

@dmlloyd
Copy link
Contributor Author

dmlloyd commented Jul 3, 2019

I factored out the method into two, one for Linux and one non-Linux, and that seems to have fixed the constant folding issue. I'll add that as a separate commit so that it can be easily individually reverted if/when the constant folding mystery is solved.

@dmlloyd
Copy link
Contributor Author

dmlloyd commented Jul 3, 2019

Pushed.

@cstancu
Copy link
Member

cstancu commented Jul 3, 2019

Thank you! I'll pull in the changes.

@graalvmbot graalvmbot merged commit e7edb18 into oracle:master Jul 3, 2019
@dmlloyd dmlloyd deleted the fix-1398 branch July 4, 2019 00:21
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.

SubstrateVM: MulticastSocket.joinGroup() fails

5 participants