Mono AOT Segmentation Fault - Strange Problem
Asked Answered
O

3

9

I wanted to test Mono AOT, so I wrote a simple console application with MonoDevelop:

using System;

namespace abc
{
    public class Program
    {
        public static void Main()
        {
            Console.WriteLine("Hello World!");
        }
    }
}

It created a file named "abc.exe" in bin/debug. When I try to do:

mono abc.exe

it worked. So, I tried to AOT it. I did:

mono --aot abc.exe

it created me a file named abc.exe.so. When I try to start it, it throws an "Segmentation fault (core dumped)" error. Heres the output of mono --aot:

Code: 51 Info: 5 Ex Info: 8 Unwind Info: 31 Class Info: 30 PLT: 2 GOT Info: 11 GOT Info Offsets: 16 GOT: 20 Offsets: 48
Compiled 2 out of 3 methods (66%)
1 methods have other problems (33%)
Methods without GOT slots: 1 (33%)
Direct calls: 0 (100%)
JIT time: 1 ms, Generation time: 0 ms, Assembly+Link time: 0 ms.

How can I fix it?

Thanks.

Oblivion answered 25/12, 2009 at 23:44 Comment(0)
B
8

What skolima said was right, it is quite odd that he got down-voted.

You are not supposed to use directly the output generated by Mono's AOT compiler.

Mono's AOT compilation is a process that caches the output of JIT compilation and leaves it in a shared library that is loaded by the Mono runtime on demand. The .so file that is generated contains the pre-compiled code and the metadata necessary to be consumed by the runtime.

To use the AOT file, you just invoke your program like this:

mono program.exe

Mono will load the metadata from program.exe and probe for the existence of a program.exe.so to avoid doing just-in-time compilation at runtime, and instead use the code from the .so file. The same process is applied to any libraries referenced.

Even Mono's full static compilation mode produces code that requires the original .exe file to be present.

If what you wanted to achieve was a native executable, you could try the mkbundle command which packages the Mono runtime and your program into a single executable.

Bergschrund answered 7/1, 2010 at 6:52 Comment(0)
S
5

You shouldn't start the output .so file, just run mono on the original managed .exe and it will pick up the AOT file automatically.

Stressful answered 6/1, 2010 at 13:54 Comment(0)
E
1

What is your environment and Mono version?

AOT only works on x86, x86-64, and ARM, and only on Linux and maybe Mac.

If you are on one of these platforms and on the latest Mono version (2.6) then it sounds like a bug that should probably be filed at http://www.mono-project.com/Bugs.

Elnoraelnore answered 26/12, 2009 at 2:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.