Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Mono 5.4.1.7 crashes on MacOS on Syste.Net.Sockets.UdpClient.Client.IOControl() #6612

@Bounz

Description

@Bounz

Steps to Reproduce

  1. Create simple console application using gist https://gist.github.com/Bounz/fdc35c1fe0c8348f25319a4049b97c7d or use archive with sample project Test.UPnP.zip
  2. Run application on MacOS with Mono 5.4.1.7 installed

Current Behavior

Mono runtime crashes with error mono_w32socket_convert_error: no translation into winsock error for (6) "Device not configured".

Expected Behavior

The process exits normally.

On which platforms did you notice this

[X] macOS
[ ] Linux
[ ] Windows

Version Used:
MacOS 10.13.2 High Sierra
Mono

Mono JIT compiler version 5.4.1.7 (2017-06/e66d9abbb27 Wed Oct 25 12:10:41 EDT 2017)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
	TLS:           normal
	SIGSEGV:       altstack
	Notification:  kqueue
	Architecture:  amd64
	Disabled:      none
	Misc:          softdebug
	LLVM:          yes(3.6.0svn-mono-master/8b1520c8aae)
	GC:            sgen (concurrent by default)

Stacktrace

mono_w32socket_convert_error: no translation into winsock error for (6) "Device not configured"
Stacktrace:

  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) System.Net.Sockets.Socket.IOControl_internal (intptr,int,byte[],byte[],int&) [0x00000] in <a24e193d5cf14a42ac00ebaea26ec7bc>:0
  at System.Net.Sockets.Socket.IOControl_internal (System.Net.Sockets.SafeSocketHandle,int,byte[],byte[],int&) [0x00010] in <a24e193d5cf14a42ac00ebaea26ec7bc>:0
  at System.Net.Sockets.Socket.IOControl (int,byte[],byte[]) [0x00019] in <a24e193d5cf14a42ac00ebaea26ec7bc>:0
  at Test.UPnP.MainClass.Main (string[]) [0x000b5] in <4c1e681f8bf64cdc8561387b4092e5cf>:0
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) [0x0004e] in <4c1e681f8bf64cdc8561387b4092e5cf>:0

Native stacktrace:

	0   mono                                0x000000010bf0c3d1 mono_handle_native_crash + 257
	1   libsystem_platform.dylib            0x00007fff7ea04f5a _sigtramp + 26
	2   ???                                 0x0000000112d5c2d4 0x0 + 4610966228
	3   libsystem_c.dylib                   0x00007fff7e82f312 abort + 127
	4   mono                                0x000000010c0dc88f mono_log_write_logfile + 351
	5   mono                                0x000000010c0f43fe monoeg_g_log + 206
	6   mono                                0x000000010bf8252c mono_w32socket_convert_error + 124
	7   mono                                0x000000010bf83cad mono_w32socket_ioctl + 477
	8   mono                                0x000000010c017910 ves_icall_System_Net_Sockets_Socket_IOControl_internal + 208
	9   ???                                 0x000000010e99b4dc 0x0 + 4539921628

Debug info from gdb:

(lldb) command source -s 0 '/tmp/mono-gdb-commands.tctyRs'
Executing commands in '/tmp/mono-gdb-commands.tctyRs'.
(lldb) process attach --pid 90629
warning: (x86_64) /Library/Frameworks/Mono.framework/Versions/5.4.1/lib/mono/4.5/mscorlib.dll.dylib empty dSYM file detected, dSYM was created with an executable with no debug info.
Process 90629 stopped
* thread #1, name = 'tid_307', queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
    frame #0: 0x00007fff7e8d3502 libsystem_kernel.dylib`__wait4 + 10
libsystem_kernel.dylib`__wait4:
->  0x7fff7e8d3502 <+10>: jae    0x7fff7e8d350c            ; <+20>
    0x7fff7e8d3504 <+12>: movq   %rax, %rdi
    0x7fff7e8d3507 <+15>: jmp    0x7fff7e8ca0dd            ; cerror
    0x7fff7e8d350c <+20>: retq
Target 0: (mono) stopped.

Executable module set to "/Library/Frameworks/Mono.framework/Versions/Current/Commands/mono".
Architecture set to: x86_64-apple-macosx.
(lldb) thread list
Process 90629 stopped
* thread #1: tid = 0x990430, 0x00007fff7e8d3502 libsystem_kernel.dylib`__wait4 + 10, name = 'tid_307', queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
  thread #2: tid = 0x990431, 0x00007fff7e8d2cee libsystem_kernel.dylib`__psynch_cvwait + 10, name = 'SGen worker'
  thread #3: tid = 0x990432, 0x00007fff7e8d2cee libsystem_kernel.dylib`__psynch_cvwait + 10, name = 'SGen worker'
  thread #4: tid = 0x990439, 0x00007fff7e8c97fe libsystem_kernel.dylib`semaphore_wait_trap + 10, name = 'Finalizer'
  thread #5: tid = 0x99043a, 0x00007fff7e8d3562 libsystem_kernel.dylib`__workq_kernreturn + 10
  thread #6: tid = 0x99043b, 0x00007fff7e8d3562 libsystem_kernel.dylib`__workq_kernreturn + 10
(lldb) thread backtrace all
* thread #1, name = 'tid_307', queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
  * frame #0: 0x00007fff7e8d3502 libsystem_kernel.dylib`__wait4 + 10
    frame #1: 0x000000010bf0c45e mono`mono_handle_native_crash(signal=<unavailable>, ctx=<unavailable>, info=<unavailable>) at mini-exceptions.c:2720 [opt]
    frame #2: 0x00007fff7ea04f5a libsystem_platform.dylib`_sigtramp + 26
    frame #3: 0x00007fff7e8d2e3f libsystem_kernel.dylib`__pthread_kill + 11
    frame #4: 0x00007fff7ea11150 libsystem_pthread.dylib`pthread_kill + 333
    frame #5: 0x00007fff7e82f312 libsystem_c.dylib`abort + 127
    frame #6: 0x000000010c0dc88f mono`mono_log_write_logfile(log_domain=<unavailable>, level=<unavailable>, hdr=<unavailable>, message="mono_w32socket_convert_error: no translation into winsock error for (6) \"Device not configured\"") at mono-log-common.c:135 [opt]
    frame #7: 0x000000010c0f43fe mono`monoeg_g_log [inlined] monoeg_g_logv at goutput.c:115 [opt]
    frame #8: 0x000000010c0f43b8 mono`monoeg_g_log(log_domain=0x0000000000000000, log_level=G_LOG_LEVEL_ERROR, format=<unavailable>) at goutput.c:125 [opt]
    frame #9: 0x000000010bf8252c mono`mono_w32socket_convert_error(error=6) at w32socket-unix.c:1329 [opt]
    frame #10: 0x000000010bf83cad mono`mono_w32socket_ioctl(sock=<unavailable>, command=<unavailable>, input=<unavailable>, inputlen=<unavailable>, output=<unavailable>, outputlen=4, written=<unavailable>) at w32socket-unix.c:1060 [opt]
    frame #11: 0x000000010c017910 mono`ves_icall_System_Net_Sockets_Socket_IOControl_internal(sock=<unavailable>, code=-1744830452, input=<unavailable>, output=<unavailable>, werror=<unavailable>) at w32socket.c:2432 [opt]
    frame #12: 0x000000010e99b4dc
  thread #2, name = 'SGen worker'
    frame #0: 0x00007fff7e8d2cee libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #1: 0x00007fff7ea0f662 libsystem_pthread.dylib`_pthread_cond_wait + 732
    frame #2: 0x000000010c0d403f mono`thread_func [inlined] mono_os_cond_wait(cond=0x000000010c1fb960, mutex=<unavailable>) at mono-os-mutex.h:173 [opt]
    frame #3: 0x000000010c0d4033 mono`thread_func(thread_data=0x000000010c1fb918) at sgen-thread-pool.c:108 [opt]
    frame #4: 0x00007fff7ea0e6c1 libsystem_pthread.dylib`_pthread_body + 340
    frame #5: 0x00007fff7ea0e56d libsystem_pthread.dylib`_pthread_start + 377
    frame #6: 0x00007fff7ea0dc5d libsystem_pthread.dylib`thread_start + 13
  thread #3, name = 'SGen worker'
    frame #0: 0x00007fff7e8d2cee libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #1: 0x00007fff7ea0f662 libsystem_pthread.dylib`_pthread_cond_wait + 732
    frame #2: 0x000000010c0d4022 mono`thread_func [inlined] mono_os_cond_wait(cond=0x000000010c24fbd0, mutex=<unavailable>) at mono-os-mutex.h:173 [opt]
    frame #3: 0x000000010c0d4016 mono`thread_func(thread_data=0x000000010c3d0108) at sgen-thread-pool.c:90 [opt]
    frame #4: 0x00007fff7ea0e6c1 libsystem_pthread.dylib`_pthread_body + 340
    frame #5: 0x00007fff7ea0e56d libsystem_pthread.dylib`_pthread_start + 377
    frame #6: 0x00007fff7ea0dc5d libsystem_pthread.dylib`thread_start + 13
  thread #4, name = 'Finalizer'
    frame #0: 0x00007fff7e8c97fe libsystem_kernel.dylib`semaphore_wait_trap + 10
    frame #1: 0x000000010c056165 mono`finalizer_thread [inlined] mono_os_sem_wait(flags=MONO_SEM_FLAGS_ALERTABLE) at mono-os-semaphore.h:91 [opt]
    frame #2: 0x000000010c05615a mono`finalizer_thread at mono-coop-semaphore.h:43 [opt]
    frame #3: 0x000000010c05614e mono`finalizer_thread(unused=<unavailable>) at gc.c:864 [opt]
    frame #4: 0x000000010c02a2f3 mono`start_wrapper [inlined] start_wrapper_internal at threads.c:829 [opt]
    frame #5: 0x000000010c02a273 mono`start_wrapper(data=0x00007fe5fe609430) at threads.c:891 [opt]
    frame #6: 0x00007fff7ea0e6c1 libsystem_pthread.dylib`_pthread_body + 340
    frame #7: 0x00007fff7ea0e56d libsystem_pthread.dylib`_pthread_start + 377
    frame #8: 0x00007fff7ea0dc5d libsystem_pthread.dylib`thread_start + 13
  thread #5
    frame #0: 0x00007fff7e8d3562 libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #1: 0x00007fff7ea0e26f libsystem_pthread.dylib`_pthread_wqthread + 1552
    frame #2: 0x00007fff7ea0dc4d libsystem_pthread.dylib`start_wqthread + 13
  thread #6
    frame #0: 0x00007fff7e8d3562 libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #1: 0x00007fff7ea0e06a libsystem_pthread.dylib`_pthread_wqthread + 1035
    frame #2: 0x00007fff7ea0dc4d libsystem_pthread.dylib`start_wqthread + 13
(lldb) detach

=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================

Process 90629 detached
(lldb) quit
Abort trap: 6

Notes

The sample application works on Mono 4.6.2 (Raspbian Jessie on Raspberry Pi).
The sample application works on .Net Framework 4.7 (Windows 10).
Using Mono version 5.2.0.224 and 5.0.1.1 I have the same behavior on macOS.
With Mono 4.8.1 on macOS I see the following output in the console:

Hello World!
wapi_WSAIoctl: Need to translate 6 [Device not configured] into winsock error
System call failed
The End.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions