Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Xamarin mono crashing on exit with SFML  (Read 6648 times)

0 Members and 2 Guests are viewing this topic.

SpacedCowboy

  • Newbie
  • *
  • Posts: 16
    • View Profile
    • Email
Xamarin mono crashing on exit with SFML
« on: April 03, 2016, 12:03:46 am »
Hi there,

So I followed the tutorial posted in this forum for setting up OSX to use mono and the SFML bindings, and it works fine until I quit the app, at which point mono crashes. Is anyone else seeing this ?

This is what I see in the console when the red window is up:

[atlantis:test2/bin/Debug] simon% mono test2.exe
Mono: DllImport attempting to load: 'libcsfml-graphics.2.3.0.dylib'.
Mono: DllImport loaded library '/Volumes/home/simon/src/c#/test2/test2/bin/Debug/libcsfml-graphics.2.3.0.dylib'.
Mono: DllImport searching in: 'libcsfml-graphics.2.3.0.dylib' ('/Volumes/home/simon/src/c#/test2/test2/bin/Debug/libcsfml-graphics.2.3.0.dylib').
Mono: Searching for 'sfRenderWindow_clear'.
Mono: Probing 'sfRenderWindow_clear'.
Mono: Found as 'sfRenderWindow_clear'.
Mono: DllImport searching in: 'libcsfml-graphics.2.3.0.dylib' ('/Volumes/home/simon/src/c#/test2/test2/bin/Debug/libcsfml-graphics.2.3.0.dylib').
Mono: Searching for 'sfRenderWindow_createUnicode'.
Mono: Probing 'sfRenderWindow_createUnicode'.
Mono: Found as 'sfRenderWindow_createUnicode'.
Warning: The created OpenGL context does not fully meet the settings that were requested
Requested: version = 2.0 ; depth bits = 0 ; stencil bits = 0 ; AA level = 0 ; core = false ; debug = false
Created: version = 2.1 ; depth bits = 0 ; stencil bits = 0 ; AA level = 0 ; core = false ; debug = false
Mono: DllImport searching in: 'libcsfml-graphics.2.3.0.dylib' ('/Volumes/home/simon/src/c#/test2/test2/bin/Debug/libcsfml-graphics.2.3.0.dylib').
Mono: Searching for 'sfRenderWindow_getDefaultView'.
Mono: Probing 'sfRenderWindow_getDefaultView'.
Mono: Found as 'sfRenderWindow_getDefaultView'.
Mono: DllImport searching in: 'libcsfml-graphics.2.3.0.dylib' ('/Volumes/home/simon/src/c#/test2/test2/bin/Debug/libcsfml-graphics.2.3.0.dylib').
Mono: Searching for 'sfRenderWindow_setVisible'.
Mono: Probing 'sfRenderWindow_setVisible'.
Mono: Found as 'sfRenderWindow_setVisible'.
Mono: DllImport searching in: 'libcsfml-graphics.2.3.0.dylib' ('/Volumes/home/simon/src/c#/test2/test2/bin/Debug/libcsfml-graphics.2.3.0.dylib').
Mono: Searching for 'sfRenderWindow_isOpen'.
Mono: Probing 'sfRenderWindow_isOpen'.
Mono: Found as 'sfRenderWindow_isOpen'.
Mono: DllImport searching in: 'libcsfml-graphics.2.3.0.dylib' ('/Volumes/home/simon/src/c#/test2/test2/bin/Debug/libcsfml-graphics.2.3.0.dylib').
Mono: Searching for 'sfRenderWindow_pollEvent'.
Mono: Probing 'sfRenderWindow_pollEvent'.
Mono: Found as 'sfRenderWindow_pollEvent'.
Mono: DllImport searching in: 'libcsfml-graphics.2.3.0.dylib' ('/Volumes/home/simon/src/c#/test2/test2/bin/Debug/libcsfml-graphics.2.3.0.dylib').
Mono: Searching for 'sfRenderWindow_display'.
Mono: Probing 'sfRenderWindow_display'.
Mono: Found as 'sfRenderWindow_display'.
 

and as soon as I click on the window-close button, I see:

Stacktrace:

  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) SFML.Graphics.RenderWindow.sfRenderWindow_destroy (intptr) <0xffffffff>
  at SFML.Graphics.RenderWindow.Destroy (bool) <0x00013>
  at SFML.ObjectBase.Dispose (bool) <0x00036>
  at SFML.ObjectBase.Finalize () <0x0001b>
  at (wrapper runtime-invoke) object.runtime_invoke_virtual_void__this__ (object,intptr,intptr,intptr) <0xffffffff>

Native stacktrace:


Debug info from gdb:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Resources/Python/lldb/__init__.py", line 98, in <module>
    import six
ImportError: No module named six
(lldb) command source -s 0 '/tmp/mono-gdb-commands.kELe7C'
Executing commands in '/tmp/mono-gdb-commands.kELe7C'.
(lldb) process attach --pid 44924
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'run_one_line' is not defined
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'run_one_line' is not defined
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'run_one_line' is not defined
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'run_one_line' is not defined
[repeats many many times]

Eventually, mono posts a crash-screen asking me if I want to report the bug.

Process:               mono-sgen [44965]
Path:                  /Library/Frameworks/Mono.framework/Versions/4.2.3/bin/mono
Identifier:            mono-sgen
Version:               ???
Code Type:             X86 (Native)
Parent Process:        tcsh [44961]
Responsible:           Terminal [2373]
User ID:               501

Date/Time:             2016-04-02 15:02:01.231 -0700
OS Version:            Mac OS X 10.11.4 (15E65)
Report Version:        11
Anonymous UUID:        50D2B39F-C928-3EF5-AF31-B6669F6D0248


Time Awake Since Boot: 330000 seconds

System Integrity Protection: disabled

Crashed Thread:        2

Exception Type:        EXC_BAD_ACCESS (SIGABRT)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000000

VM Regions Near 0:
-->
    __TEXT                 000000000003c000-0000000000359000 [ 3188K] r-x/rwx SM=COW  /Library/Frameworks/Mono.framework/Versions/4.2.3/bin/mono-sgen

Application Specific Information:
abort() called

Thread 0:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib              0x9ba893ea __psynch_cvwait + 10
1   libsystem_pthread.dylib             0x93e8b538 _pthread_cond_wait + 757
2   libsystem_pthread.dylib             0x93e8ed0b pthread_cond_timedwait$UNIX2003 + 71
3   mono                                0x0028f3a7 mono_cond_timedwait_ms + 135 (mono-mutex.c:181)
4   mono                                0x0020ef64 mono_gc_cleanup + 180 (gc.c:1234)
5   mono                                0x00206990 mono_runtime_cleanup + 16 (appdomain.c:362)
6   mono                                0x0004c552 mini_cleanup + 786 (mini-runtime.c:3461)
7   mono                                0x000c6f41 mono_main + 8001 (driver.c:2086)
8   mono                                0x0003ea80 main + 768 (.main.c:125)
9   mono                                0x0003e775 start + 53

Thread 1:
0   libsystem_kernel.dylib              0x9ba893ea __psynch_cvwait + 10
1   libsystem_pthread.dylib             0x93e8b538 _pthread_cond_wait + 757
2   libsystem_pthread.dylib             0x93e8d276 pthread_cond_wait$UNIX2003 + 71
3   mono                                0x0026f7d2 thread_func + 466 (sgen-thread-pool.c:118)
4   libsystem_pthread.dylib             0x93e8a780 _pthread_body + 138
5   libsystem_pthread.dylib             0x93e8a6f6 _pthread_start + 155
6   libsystem_pthread.dylib             0x93e87f7a thread_start + 34

Thread 2 Crashed:
0   libsystem_kernel.dylib              0x9ba89572 __pthread_kill + 10
1   libsystem_pthread.dylib             0x93e8d654 pthread_kill + 101
2   libsystem_c.dylib                   0x9a87dc34 abort + 156
3   mono                                0x000fbfe5 mono_handle_native_sigsegv + 757
4   mono                                0x00148462 mono_arch_handle_altstack_exception + 162 (exceptions-x86.c:1097)
5   mono                                0x0004933e mono_sigsegv_signal_handler + 446 (mini-runtime.c:2489)
6   libsystem_platform.dylib            0x927e679b _sigtramp + 43
7   ???                                 0xffffffff 0 + 4294967295
8   mono                                0x00049180 mono_sigill_signal_handler + 48 (mini-runtime.c:2398)
9   libsfml-window.2.3.2.dylib          0x01999a42 sf::priv::SFContext::~SFContext() + 114
10  libsfml-window.2.3.2.dylib          0x0198d208 sf::priv::GlContext::globalCleanup() + 56
11  libsfml-window.2.3.2.dylib          0x0198e5d0 sf::GlResource::~GlResource() + 48
12  libcsfml-graphics.2.3.0.dylib       0x007d7d17 sfRenderWindow_destroy + 23
13  ???                                 0x006f431c 0 + 7291676
14  ???                                 0x006f4248 0 + 7291464
15  ???                                 0x006f4188 0 + 7291272
16  ???                                 0x006f40bc 0 + 7291068
17  ???                                 0x006f3ebe 0 + 7290558
18  mono                                0x0020db1a mono_gc_run_finalize + 810 (gc.c:240)
19  mono                                0x0020f4d2 finalizer_thread + 370 (gc.c:1118)
20  mono                                0x001e9441 start_wrapper + 545 (threads.c:725)
21  mono                                0x00299e60 inner_start_thread + 240 (mono-threads-posix.c:97)
22  libsystem_pthread.dylib             0x93e8a780 _pthread_body + 138
23  libsystem_pthread.dylib             0x93e8a6f6 _pthread_start + 155
24  libsystem_pthread.dylib             0x93e87f7a thread_start + 34

Thread 3:
0   libsystem_kernel.dylib              0x9ba89d5e __workq_kernreturn + 10
1   libsystem_pthread.dylib             0x93e8a34b _pthread_wqthread + 1289
2   libsystem_pthread.dylib             0x93e87f56 start_wqthread + 34

Thread 4:: Dispatch queue: com.apple.libdispatch-manager
0   libsystem_kernel.dylib              0x9ba8a7fa kevent_qos + 10
1   libdispatch.dylib                   0x927427ea _dispatch_mgr_invoke + 234
2   libdispatch.dylib                   0x927423be _dispatch_mgr_thread + 52

Thread 5:: OGL Profiler
0   libsystem_kernel.dylib              0x9ba8249a mach_msg_trap + 10
1   libsystem_kernel.dylib              0x9ba81884 mach_msg + 68
2   com.apple.opengl                    0x9ba91995 glcDebugListener + 434
3   libsystem_pthread.dylib             0x93e8a780 _pthread_body + 138
4   libsystem_pthread.dylib             0x93e8a6f6 _pthread_start + 155
5   libsystem_pthread.dylib             0x93e87f7a thread_start + 34

Thread 6:
0   libsystem_kernel.dylib              0x9ba89d5e __workq_kernreturn + 10
1   libsystem_pthread.dylib             0x93e8a34b _pthread_wqthread + 1289
2   libsystem_pthread.dylib             0x93e87f56 start_wqthread + 34

Thread 7:
0   libsystem_kernel.dylib              0x9ba89d5e __workq_kernreturn + 10
1   libsystem_pthread.dylib             0x93e8a34b _pthread_wqthread + 1289
2   libsystem_pthread.dylib             0x93e87f56 start_wqthread + 34

Thread 8:
0   libsystem_kernel.dylib              0x9ba89d5e __workq_kernreturn + 10
1   libsystem_pthread.dylib             0x93e8a34b _pthread_wqthread + 1289
2   libsystem_pthread.dylib             0x93e87f56 start_wqthread + 34

Thread 9:

Thread 10:: com.apple.NSEventThread
0   libsystem_kernel.dylib              0x9ba8249a mach_msg_trap + 10
1   libsystem_kernel.dylib              0x9ba81884 mach_msg + 68
2   com.apple.CoreFoundation            0x98075dc6 __CFRunLoopServiceMachPort + 214
3   com.apple.CoreFoundation            0x980751d1 __CFRunLoopRun + 1521
4   com.apple.CoreFoundation            0x98074976 CFRunLoopRunSpecific + 390
5   com.apple.CoreFoundation            0x980747db CFRunLoopRunInMode + 123
6   com.apple.AppKit                    0x9898ef76 _NSEventThread + 291
7   libsystem_pthread.dylib             0x93e8a780 _pthread_body + 138
8   libsystem_pthread.dylib             0x93e8a6f6 _pthread_start + 155
9   libsystem_pthread.dylib             0x93e87f7a thread_start + 34

Thread 2 crashed with X86 Thread State (32-bit):
  eax: 0x00000000  ebx: 0xa3f406b0  ecx: 0x007af70c  edx: 0x00000000
  edi: 0xb0183000  esi: 0x00000006  ebp: 0x007af728  esp: 0x007af70c
   ss: 0x00000023  efl: 0x00000206  eip: 0x9ba89572   cs: 0x0000000b
   ds: 0x00000023   es: 0x00000023   fs: 0x00000000   gs: 0x0000000f
  cr2: 0xb05a3058
 
Logical CPU:     0
Error Code:      0x00080148
Trap Number:     132

 
It's 100% reproducible for me, just wanted to see if anyone had a workaround or if it's only happening for me...

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
AW: Xamarin mono crashing on exit with SFML
« Reply #1 on: April 03, 2016, 07:24:22 pm »
And what's your code?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Xamarin mono crashing on exit with SFML
« Reply #2 on: April 03, 2016, 07:31:01 pm »
Also, you're using CSFML 2.3.0 and SFML 2.3.2. Try not mixing versions.

And since I see in your stack trace this

9   libsfml-window.2.3.2.dylib      0x01999a42 sf::priv::SFContext::~SFContext()

try SFML's master version. Some stuff were fixed regarding multithreading memory management on OS X.
SFML / OS X developer

SpacedCowboy

  • Newbie
  • *
  • Posts: 16
    • View Profile
    • Email
Re: AW: Xamarin mono crashing on exit with SFML
« Reply #3 on: April 03, 2016, 11:43:24 pm »
And what's your code?

It's the code from the tutorial I linked to ...

using System;
using SFML;
using SFML.Graphics;
using SFML.Window;

namespace TestSFML
{
    class MainClass
    {
        private static RenderWindow _window;

        public static void Main(string[] args)
        {
            _window = new RenderWindow(new VideoMode(800, 600), "SFML window");
            _window.SetVisible(true);
            _window.Closed += new EventHandler(OnClosed);
            while (_window.IsOpen)
            {
                _window.DispatchEvents();
                _window.Clear(Color.Red);
                _window.Display();
            }
        }

        private static void OnClosed(object sender, EventArgs e)
        {
            _window.Close();
        }
    }
}
 

SpacedCowboy

  • Newbie
  • *
  • Posts: 16
    • View Profile
    • Email
Re: Xamarin mono crashing on exit with SFML
« Reply #4 on: April 03, 2016, 11:46:41 pm »
Also, you're using CSFML 2.3.0 and SFML 2.3.2. Try not mixing versions.

And since I see in your stack trace this

9   libsfml-window.2.3.2.dylib      0x01999a42 sf::priv::SFContext::~SFContext()

try SFML's master version. Some stuff were fixed regarding multithreading memory management on OS X.

I guess I just took the latest version of everything. By "master version", do you mean the latest code from the SFML github at https://github.com/SFML/SFML ?

Cheers
   Simon

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Xamarin mono crashing on exit with SFML
« Reply #5 on: April 04, 2016, 08:22:13 am »
Yes.
SFML / OS X developer

SpacedCowboy

  • Newbie
  • *
  • Posts: 16
    • View Profile
    • Email
Re: Xamarin mono crashing on exit with SFML
« Reply #6 on: April 05, 2016, 07:19:26 am »
Yes.

So I had a bit of trouble with this, but finally figured it out. I've used 64-bit mode for what seems like forever on the Mac, but mono is apparently compiled to be 32-bit as shipped from Xamarin, so it needs 32-bit shared libraries, and by default cmake compiles the 64-bit ones.

Once I'd set CMAKE_OSX_ARCHITECTURES to 'i386' and re-run cmake, run make, and done the remove-the-rpath step, it all actually works - I can now launch the test app, the red window comes up, and mono doesn't crash on exit. Looks as though the top-of-tree version has fixed whatever ails the 3.2 download :)

Now to see if my own C++ code ports over well. If so, managed runtime here I come :)

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Xamarin mono crashing on exit with SFML
« Reply #7 on: April 05, 2016, 07:46:03 am »
Just note that 32bit support for OS X was dropped last week. Expect this to no longer work very soon.
SFML / OS X developer