apl-cornell / fabric

Distributed persistent programming language with secure information flow types
http://www.cs.cornell.edu/projects/fabric/
Other
28 stars 4 forks source link

Inaccessibility of $classHash for nonpublic classes. #32

Open tmagrino opened 6 years ago

tmagrino commented 6 years ago

So it looks like the current master of Fabric and Jif combined with commit 256b116e of Polyglot (latest version known to work, there's an issue with changes in master affecting Jif's build right now) has a problem with making sure the $classHash field is appropriately visible to the runtime. We found this issue trying to run commit ac93352b of @karannewatia FabIL Scrabble implementation. When attempting to run the application, we would get:

$ bin/start-store
Worker started
Store started

store> App
Nov 15, 2018 4:31:23 PM Creating InternalError exception:
================ BEGIN STACK TRACE ================
fabric.common.exceptions.InternalError: java.lang.IllegalAccessException: Class fabric.common.SysUtil can not access a member of class Board with modifiers "public static final"
        at fabric.common.SysUtil.classHashFieldValue(SysUtil.java:259)
        at fabric.common.SysUtil.classHashFieldValueOrNull(SysUtil.java:270)
        at fabric.common.SysUtil.hashPlatformClass(SysUtil.java:101)
        at fabric.common.ClassRef$PlatformClassRef.getHashImpl(ClassRef.java:300)
        at fabric.common.ClassRef.getHash(ClassRef.java:178)
        at fabric.common.ClassRef$PlatformClassRef.writeImpl(ClassRef.java:326)
        at fabric.common.ClassRef.write(ClassRef.java:927)
        at fabric.common.SerializedObject.write(SerializedObject.java:1007)
        at fabric.common.SerializedObject.<init>(SerializedObject.java:213)
        at fabric.store.InProcessStore$3.run(InProcessStore.java:107)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalAccessException: Class fabric.common.SysUtil can not access a member of class Board with modifiers "public static final"
        at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:102)
        at java.lang.reflect.AccessibleObject.slowCheckMemberAccess(AccessibleObject.java:296)
        at java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:288)
        at java.lang.reflect.Field.get(Field.java:390)
        at fabric.common.SysUtil.classHashFieldValue(SysUtil.java:253)
        ... 14 more
================= END STACK TRACE =================

This IllegalAccessException happens because the nonpublic class Board was compiled to a nonpublic interface Board, whose public static final byte[] $classHash field is not legally accessible from fabric.common.SysUtil!

I'm not sure at what point this bug got introduced as it wasn't a problem when using the prepackaged release of Fabric version 0.3.0. It's possible this is a bug due to changes in either Jif or Polyglot (I doubt it is Jif). Worth figuring out when this regressed and, regardless, we need to fix this.