typelead/eta

Missing Closure.evaluateTail() at Android runtime

noon99jaki opened this issue · 3 comments

I've got duckling to compile and installed in Android, but at runtime eta cannot find the implementation of evaluateTail(). I can see that evaluateTail is written in Types.hs here. Is this part failing?

/Users/ni.lao/git/eta/compiler/Eta/CodeGen/Types.hs:
  357   where closureCls = fromMaybe stgClosure (locClass cgLoc)
  358         methodName
  359:          | tailCall  = "evaluateTail"
  360           | otherwise = "evaluate"

Somehow the eta-duckling project does not seem to have such an issue:
typelead/eta-hackage#143

Description

logcat

08-22 16:21:46.417 10784 10784 D AndroidRuntime: Shutting down VM
08-22 16:21:46.424 10784 10784 E AndroidRuntime: FATAL EXCEPTION: main
08-22 16:21:46.424 10784 10784 E AndroidRuntime: Process: com.saymosaic.nlp.lite, PID: 10784
08-22 16:21:46.424 10784 10784 E AndroidRuntime: java.lang.NoSuchMethodError: No virtual method evaluateTail(Leta/runtime/stg/StgContext;)Leta/runtime/stg/Closure; in class Leta/runtime/stg/Closure; or its super classes (declaration of 'eta.runtime.stg.Closure' appears in /data/app/com.saymosaic.nlp.lite-FgNqpZCGaLScF2OhO1v2cw==/base.apk!classes12.dex)
08-22 16:21:46.424 10784 10784 E AndroidRuntime: 	at base.ghc.Base.zpzp(Base.hs:1145)
08-22 16:21:46.424 10784 10784 E AndroidRuntime: 	at app.duckling.Engine.$wparseString1(Engine.hs:181)
08-22 16:21:46.424 10784 10784 E AndroidRuntime: 	at app.duckling.Engine.parseAndResolve(Engine.hs:211)
08-22 16:21:46.424 10784 10784 E AndroidRuntime: 	at app.duckling.Api.$wanalyzze(Api.hs:56)
08-22 16:21:46.424 10784 10784 E AndroidRuntime: 	at app.duckling.Api.$wparse(Api.hs:40)
08-22 16:21:46.424 10784 10784 E AndroidRuntime: 	at app.Run.$w$fe_run_parse(Run.hs:20)
08-22 16:21:46.424 10784 10784 E AndroidRuntime: 	at app.Run.$fe_run_parse(Run.hs:23)
08-22 16:21:46.424 10784 10784 E AndroidRuntime: 	at app.Run$$fe_run_parse.apply1(Run.hs:23)
08-22 16:21:46.424 10784 10784 E AndroidRuntime: 	at eta.runtime.thunk.Ap2Upd.thunkEnter(Ap2Upd.java:18)
08-22 16:21:46.424 10784 10784 E AndroidRuntime: 	at eta.runtime.thunk.UpdatableThunk.evaluate(UpdatableThunk.java:24)
08-22 16:21:46.424 10784 10784 E AndroidRuntime: 	at base.ghc.TopHandler.runNonIO1(TopHandler.hs:70)
08-22 16:21:46.424 10784 10784 E AndroidRuntime: 	at base.ghc.TopHandler.runNonIO(TopHandler.hs:70)
08-22 16:21:46.424 10784 10784 E AndroidRuntime: 	at base.ghc.TopHandler$runNonIO.apply1V(TopHandler.hs:70)
08-22 16:21:46.424 10784 10784 E AndroidRuntime: 	at eta.runtime.apply.PAP1_1.applyV(PAP1_1.java:17)
08-22 16:21:46.424 10784 10784 E AndroidRuntime: 	at eta.runtime.stg.Closures$EvalIO.enter(Closures.java:129)
08-22 16:21:46.424 10784 10784 E AndroidRuntime: 	at eta.runtime.stg.Capability.schedule(Capability.java:175)
08-22 16:21:46.424 10784 10784 E AndroidRuntime: 	at eta.runtime.stg.Capability.scheduleClosure(Capability.java:120)
08-22 16:21:46.424 10784 10784 E AndroidRuntime: 	at eta.runtime.Runtime.evalIO(Runtime.java:230)
08-22 16:21:46.424 10784 10784 E AndroidRuntime: 	at org.mosaix.eta.Run.run_parse(Unknown Source:23)
08-22 16:21:46.424 10784 10784 E AndroidRuntime: 	at com.saymosaic.nlp.lite.MainActivity.onCreate(MainActivity.java:31)
08-22 16:21:46.424 10784 10784 E AndroidRuntime: 	at android.app.Activity.performCreate(Activity.java:7136)
08-22 16:21:46.424 10784 10784 E AndroidRuntime: 	at android.app.Activity.performCreate(Activity.java:7127)
08-22 16:21:46.424 10784 10784 E AndroidRuntime: 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
08-22 16:21:46.424 10784 10784 E AndroidRuntime: 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
08-22 16:21:46.424 10784 10784 E AndroidRuntime: 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
08-22 16:21:46.424 10784 10784 E AndroidRuntime: 	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
08-22 16:21:46.424 10784 10784 E AndroidRuntime: 	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
08-22 16:21:46.424 10784 10784 E AndroidRuntime: 	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
08-22 16:21:46.424 10784 10784 E AndroidRuntime: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
08-22 16:21:46.424 10784 10784 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:106)
08-22 16:21:46.424 10784 10784 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:193)
08-22 16:21:46.424 10784 10784 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:6669)
08-22 16:21:46.424 10784 10784 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
08-22 16:21:46.424 10784 10784 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
08-22 16:21:46.424 10784 10784 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
08-22 16:21:46.433  1952  2649 W ActivityManager:   Force finishing activity com.saymosaic.nlp.lite/.MainActivity
08-22 16:21:46.441 10784 10784 I Process : Sending signal. PID: 10784 SIG: 9

app/build.gradle:

plugins {
    id 'com.typelead.eta.android'
}

apply plugin: 'com.android.application'
// apply plugin: 'com.android.library'

apply plugin: 'eta-android'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'com.chaquo.python'

android {
    compileSdkVersion 25
    buildToolsVersion '25.0.0'

    defaultConfig {
        applicationId "com.saymosaic.nlp.lite"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true

        python {
            staticProxy "utils.Utils"
            pip {
                install "nltk==3.4"
            }
        }
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 
                          getDefaultEtaProguardFile(),
                          'proguard-rules.pro'
        }
    }
    lintOptions{
        disable 'GoogleAppIndexingWarning'
        abortOnError false
    }
    compileOptions {
        sourceCompatibility 1.8
        targetCompatibility 1.8
    }
    dexOptions {
        preDexLibraries = false
        javaMaxHeapSize "4g"
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:25.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:design:25.0.0'
    implementation 'com.google.code.gson:gson:2.8.5'
    // For Duckling
    implementation eta('rts:0.1.0.0')
    implementation eta('random:1.1')
    implementation eta('deepseq:1.4.1.1')
    implementation eta('base:4.8.2')
    implementation eta('array:0.5.1.1')
    //implementation eta('base-compat:0.10.4')
    implementation eta('attoparsec:0.13.2.2')
    implementation eta('aeson:0.11.3.0')
//    implementation eta('bytestring-builder:0.10.8.2.0')
    implementation eta('bytestring:0.10.6.0')
    implementation eta('containers:0.5.6.2')
    implementation eta('dependent-sum:0.4')
    implementation eta('extra:1.6.3')
    implementation eta('hashable:1.2.7.0')
    implementation eta('regex-base:0.93.2')
    implementation eta('regex-pcre-builtin:0.94.4.8.8.35')
    implementation eta('text:1.2.3.0')
    implementation eta('show:0.6')
    implementation eta('time:1.5.0.1')
    implementation eta('timezone-series:0.1.9')
    implementation eta('unordered-containers:0.2.9.0')

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

build.gradle:

buildscript {
    ext.kotlin_version = '1.3.21'
    repositories {
        google()
        jcenter()
        maven { url "https://chaquo.com/maven" }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "com.chaquo.python:gradle:6.2.1"
    }

    configurations.all {
        resolutionStrategy {
            force 'net.sf.proguard:proguard-gradle:6.0.3'
        }
    }
}

plugins {
    id 'com.typelead.eta.base' version '0.5.4'
}

apply plugin: 'eta-base'

eta {
    version = '0.8.6b2'
    etlasVersion = '1.5.0.0'
}


allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
    }
}

Expected Behavior

Actual Behavior

Possible Fix

Steps to Reproduce

Context

Your Environment

  • Did you install an older version of Eta/Etlas before? no
  • Current Eta & Etlas version:
  • Operating System and version: Android 25 and 28
  • Link to your project:

The problem does not seem to be specific to a Duckling function, since the following simple function also crashed

foreign export java "@static org.mosaix.eta.Run.print_context"
  print_context :: JString
print_context = toJava $ show (testContext)
08-23 15:45:55.430 20839 20839 D AndroidRuntime: Shutting down VM
08-23 15:45:55.434 20839 20839 E AndroidRuntime: FATAL EXCEPTION: main
08-23 15:45:55.434 20839 20839 E AndroidRuntime: Process: com.saymosaic.nlp.lite, PID: 20839
08-23 15:45:55.434 20839 20839 E AndroidRuntime: java.lang.NoSuchMethodError: No virtual method evaluateTail(Leta/runtime/stg/StgContext;)Leta/runtime/stg/Closure; in class Leta/runtime/stg/Closure; or its super classes (declaration of 'eta.runtime.stg.Closure' appears in /data/app/com.saymosaic.nlp.lite-3QHXqTDwvagYKe6yIZwc5Q==/base.apk!classes12.dex)
08-23 15:45:55.434 20839 20839 E AndroidRuntime: 	at base.ghc.Base.zpzp(Base.hs:1145)
08-23 15:45:55.434 20839 20839 E AndroidRuntime: 	at base.ghc.Base$sat$62.thunkEnter(Base.hs:1020)
08-23 15:45:55.434 20839 20839 E AndroidRuntime: 	at eta.runtime.thunk.UpdatableThunk.evaluate(UpdatableThunk.java:24)
08-23 15:45:55.434 20839 20839 E AndroidRuntime: 	at base.java.StringBase.$wgo(StringBase.hs:70)
08-23 15:45:55.434 20839 20839 E AndroidRuntime: 	at base.java.StringBase.$wtoJString(StringBase.hs:69)
08-23 15:45:55.434 20839 20839 E AndroidRuntime: 	at app.Run$print_context.thunkEnter(Run.hs:39)
08-23 15:45:55.434 20839 20839 E AndroidRuntime: 	at eta.runtime.thunk.CAF.evaluate(CAF.java:35)
...

while the following was not crashing

foreign export java "@static org.mosaix.eta.Run.hello"
  hello ::  JString -> JString
hello str = toJava "hello" 

Actually there might be some caching going on. print_context() works after deleting ~/.gradle/caches

08-23 21:29:01.880 25204 25204 I haskell : Context {referenceTime = DucklingTime 2013-02-12 02:30:00 -0200, locale = EN_XX}

The issue is also gone for run_parse()