[Mono-dev] Mono in Ubuntu thread

howard.rubin howard.rubin at hl.konicaminolta.us
Wed Apr 12 17:22:07 UTC 2017


I was able to shorten the C part of my example to almost nothing:

// monotest.cpp
#include <thread>
#include <mono/jit/jit.h>

void Thread() {
    MonoDomain* domain = mono_jit_init("monotest.dll");
    mono_jit_cleanup(domain);
}

int main() {
    //Thread();
    std::thread t(Thread);
    t.join();
}


howard.rubin wrote
> My program (below) works on Fedora 22 or if I call the thread function
> directly from main(). But if I launch the mono calls in a thread on Ubuntu
> 16.04, it asserts like this. Am I doing something wrong?
> Howard Rubin
> 
> Output:
> 
> $ rm monotest.dll ; make ; ./monotest
> Mono C# compiler version 4.8.0.0
> mcs monotest.cs /out:monotest.dll /target:library
> g++ (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
> g++ monotest.cpp -o monotest -g3 -std=c++11 `pkg-config --cflags --libs
> mono-2`
> MySum(1,2) => 3
> * Assertion at mono-threads-posix.c:265, condition `info->handle' not met
> 
> Aborted (core dumped)
> $ 
> 
> ////////////////////////
> // monotest.cs
> namespace MyNamespace  {
> 
>     public class MyClass {
>         public MyClass() { }
> 
>         public void MySum(int arg1, int arg2) {
>             System.Console.WriteLine("MySum(" + arg1 + "," + arg2 + ") =>
> " + (arg1 + arg2));
>         }
>     }
> }
> 
> ###################
> # Makefile
> monotest : monotest.cpp monotest.dll Makefile
> 	@g++ --version | head -1
> 	g++ $< -o $@ -g3 -std=c++11 `pkg-config --cflags --libs mono-2`
> 
> monotest.dll : monotest.cs
> 	@mcs --version
> 	mcs $< /out:$@ /target:library





--
View this message in context: http://mono.1490590.n4.nabble.com/Mono-in-Ubuntu-thread-tp4670463p4670473.html
Sent from the Mono - Dev mailing list archive at Nabble.com.


More information about the Mono-devel-list mailing list