Welcome! Please see the About page for a little more info on how this works.

0 votes
in ClojureCLR by

I see one of the reasons for clojure-clr-next is it will work on more platforms, is Android one of those?

I'm using Termux to operate dotnet on Android.

Both the clojure-clr global dotnet tool and locally compiled clojure-clr fail with exit code 1, no exceptions or anything. I tried dotnet-trace and it gets a partial trace, but no minidump. Puzzling as with the partial trace, the documentation indicates an expectation of a minidump, maybe there is some unmet condition to emit the minidump I'm not aware of yet (env variables for it didn't work).

In the trace here is an early line followed by some of the last lines:
`
"system.linq!System.Linq.Enumerable.SelectManyS\ingleSelectorIterator\u003cSystem.Reflection.As\sembly,System.Type\u003e.MoveNext()"

[...]
"system.collections!System.Collections.Generic.\
SortedSet\u003cSystem.Collections.Generic.KeyVa\luePair\u003cSystem.Int32,clojure.lang.CljCompi\ler.Ast.FnMethod\u003e\u003e.AddIfNotPresent(Sy\stem.Collections.Generic.KeyValuePair`2\u003cin\t,

[...last line...]
"ManagedModule!System.Buffers.SharedArrayPool\u\003cSystem.Byte\u003e.Trim()"
`

So maybe something to do with reflection, or that SharedArrayPool?

I tried inserting some logging to Clojure.Main, but nothing logged as it appears to fail before CljMain.Main() is called. Possibly fails during setting up attributes on one of the classes, in one of the Symbol.intern() or RT.var() calls or somewhere else?

Couldn't run the dotnet msbuild build.proj -t:Test -p:TestTargetFramework=net8.0, fails with:
Clojure.Main -> /data/data/com.termux/files/home/dev/clojure-clr/Clojure/Clojure.Main/bin/Debug/net8.0/Clojure.Main.dll ClojureCompileAssets = '' ClojureMainAssets = '' ClojureTestsAssets = '' /data/data/com.termux/files/home/dev/clojure-clr/Clojure/build.proj(177,5): error MSB3073: The command "dotnet run --project /data/data/com.termux/files/home/dev/clojure-clr/Clojure/Clojure.Main --framework net8.0 -c Debug -p:TargetOS=linux-bionic -p:TargetPlatform=arm64 -p:TargetFramework=net8.0 -p:TargetFrameworks='net8.0' -- run_test.clj" exited with code 1.
I had to edit build.proj a bit to get custom -p:TargetFrameworks and such to pass through, but still fails with exit code 1.

Well I'll continue poking around in this uncharted territory.

by
Turns out error is piped via mono runtime to logcat on Android:
https://gist.github.com/rene-descartes2021/22b3ceca022a3a733e9388073b1b4c37

Excerpt:
05-14 16:28:45.631 29686 29686 E mono    : Unhandled Exception:                                 
05-14 16:28:45.631 29686 29686 E mono    : System.TypeInitializationException: The type initializer for 'Clojure.CljMain' threw an exception.   
05-14 16:28:45.631 29686 29686 E mono    :  ---> System.TypeInitializationException: The type initializer for 'clojure.lang.RT' threw an exception.                                             
05-14 16:28:45.631 29686 29686 E mono    :  ---> Syntax error compiling fn* at (clojure/core.clj:400:2).                                        
05-14 16:28:45.631 29686 29686 E mono    : Token 40001d0 is not valid in the scope of module Clojure.dll. (Parameter 'metadataToken')           
05-14 16:28:45.631 29686 29686 E mono    :    --- End of inner exception stack trace ---

Looking at core.clj in that spot is the first use of PersistentTreeMap. Looking elsewhere, greping for 'Token' and 'metadata' I guess the symbol is mapped to a uint for lookup later, somewhere in the code... Maybe a rule of thumb in that uint mapping doesn't hold on linux-bionic-arm64? Will try to comprehend that code later.

Going to try to run the nunit tests next on Csharp.Tests project, test if PersistentTreeMap doesn't work or something. 'dotnet test' didn't work, trying to find a nunit dotnet tool now, maybe that will work.
by
edited ago by
Ok got 'dotnet test' to work for Csharp.Tests project. Had to restore again as I'd purged the NuGet cache.

Here is command and log:
$ cd Csharp.Tests
$ dotnet test --no-build -v n -f net8.0 -c Debug

Log:
https://gist.github.com/rene-descartes2021/67fa819bf6ab96097a0c0da2d83484f8

214 failed tests, most all appear to be variants of two exceptions, excerpted here:

Failed BooleanSpecPrintsTrueOnTrue [2 ms]       
Error Message:                                   
NExpect.Exceptions.UnmetExpectationException : Expected                                      
"True"                                          
but got                                         
"true"                                          
values have different casing


Failed DefaultCtorReturnsEmptyMap [< 1 ms]      
Error Message:                                   
System.TypeInitializationException : The type initializer for 'clojure.lang.PersistentTreeMap' threw an exception.                           
----> System.TypeInitializationException : The type initializer for 'clojure.lang.RT' threw an exception.                                       
----> System.ArgumentException : An item with the same key has already been added. Key: Casing

I'll try to see what I can find out. dotnet on Android uses Android's libcrypto and libssl, not the embedded ones in dotnet or whatever... Something along those lines. Maybe the difference is due to that- seems one or the other are used when hashing strings.

Please log in or register to answer this question.

...