Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native crash in ves_icall_System_Net_Sockets_Socket_Connect_internal #16024

Closed
Therzok opened this issue Aug 5, 2019 · 5 comments
Assignees

Comments

@Therzok
Copy link
Member

@Therzok Therzok commented Aug 5, 2019

Steps to Reproduce

N/A, see https://devdiv.visualstudio.com/DevDiv/_workitems/edit/919108

Current Behavior

From the looks of it, an error code does not have a translation. Possible ones below.

connect

Other findings:
setsockopt

socket

Expected Behavior

It should not crash at all. Maybe throw a less descriptive exception rather than bringing down the application

On which platforms did you notice this

[*] macOS
[ ] Linux
[ ] Windows

Version Used:

Not sure, not contained in the bug report.

Stacktrace

Thread 14 Crashed:: Thread Pool Worker
0   libsystem_kernel.dylib            0x00007fff6f4262c6 __pthread_kill + 10
1   libsystem_pthread.dylib           0x00007fff6f4e1bf1 pthread_kill + 284
2   libsystem_c.dylib                 0x00007fff6f3906a6 abort + 127
3   libmonosgen-2.0.dylib             0x000000010511728e mono_post_native_crash_handler + 14
4   libmonosgen-2.0.dylib             0x00000001050ba7d0 mono_handle_native_crash + 448 (mini-exceptions.c:3321)
5   libsystem_platform.dylib          0x00007fff6f4d6b5d _sigtramp + 29
6   ???                               0x00007fa73ad1b7e0 0 + 140356223088608
7   libsystem_c.dylib                 0x00007fff6f3906a6 abort + 127
8   libxammac.dylib                   0x0000000103ef1430 log_callback(char const*, char const*, char const*, int, void*) + 64
9   libmonosgen-2.0.dylib             0x000000010530610e monoeg_g_logv_nofree + 190 (goutput.c:150)
10  libmonosgen-2.0.dylib             0x00000001053061c2 monoeg_g_log + 130 (goutput.c:165)
11  libmonosgen-2.0.dylib             0x0000000105178c4c mono_w32socket_convert_error + 124 (w32socket-unix.c:1540)
12  libmonosgen-2.0.dylib             0x0000000105179139 mono_w32socket_connect + 377 (w32socket-unix.c:224)
13  libmonosgen-2.0.dylib             0x000000010521d82b ves_icall_System_Net_Sockets_Socket_Connect_internal + 91 (w32socket.c:1342)
@marek-safar

This comment has been minimized.

Copy link
Member

@marek-safar marek-safar commented Aug 5, 2019

@lambdageek please take care of this, we should not crash in error handling

@lambdageek lambdageek self-assigned this Aug 5, 2019
@lambdageek

This comment has been minimized.

Copy link
Member

@lambdageek lambdageek commented Aug 5, 2019

We don't really have a straightforward way to throw a generic exception here.

We can add some of the other errno values, but they don't really have WSA counterparts. It would be helpful to know what the log message was.

lambdageek added a commit that referenced this issue Aug 7, 2019
Translate to WSAELOOP and WSAENAMETOOLONG, respectively.

See https://docs.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2

Addresses part of #16024
@Therzok

This comment has been minimized.

Copy link
Member Author

@Therzok Therzok commented Aug 8, 2019

@lambdageek I suppose ENOENT could be translated to WSAENOTSOCK

ENOTDIR could be translated to WSA_INVALID_PARAMETER or WSAEINVAL.

EDOM - WSAEINVAL?

ENFILE - WSAEPROCLIM? EMFILE?

@lambdageek

This comment has been minimized.

Copy link
Member

@lambdageek lambdageek commented Aug 19, 2019

ENOENT already has a translation (WSAECONNREFUSED):

case ENOENT: return WSAECONNREFUSED;

Elsewhere in Mono we have some translations for EIO, ENOTDIR, and ENFILE:

case ENFILE:
case EMFILE: return ERROR_TOO_MANY_OPEN_FILES;
case ENOENT:
case ENOTDIR: return ERROR_FILE_NOT_FOUND;

Maybe EIO -> WSA_INVALID_HANDLE by analogy with w32error-unix.c

lambdageek added a commit to lambdageek/mono that referenced this issue Aug 19, 2019
These aren't a perfect match, but better than falling into the `default` case
where Mono asserts and crashes.

Addresses part of mono#16024
lambdageek added a commit that referenced this issue Aug 20, 2019
These aren't a perfect match, but better than falling into the `default` case
where Mono asserts and crashes.

Addresses part of #16024
monojenkins added a commit to monojenkins/mono that referenced this issue Aug 26, 2019
These aren't a perfect match, but better than falling into the `default` case
where Mono asserts and crashes.

Addresses part of mono#16024
monojenkins added a commit to monojenkins/mono that referenced this issue Aug 26, 2019
These aren't a perfect match, but better than falling into the `default` case
where Mono asserts and crashes.

Addresses part of mono#16024
akoeplinger added a commit that referenced this issue Aug 26, 2019
…cisely. (#16488)

* [w32socket] Translate some errno codes to WSA_ errors imprecisely.

These aren't a perfect match, but better than falling into the `default` case
where Mono asserts and crashes.

Addresses part of #16024

* [w32error] Add WSA_INVALID_PARAMETER and WSA_INVALID_HANDLE
akoeplinger added a commit that referenced this issue Aug 26, 2019
…cisely. (#16489)

* [w32socket] Translate some errno codes to WSA_ errors imprecisely.

These aren't a perfect match, but better than falling into the `default` case
where Mono asserts and crashes.

Addresses part of #16024

* [w32error] Add WSA_INVALID_PARAMETER and WSA_INVALID_HANDLE

Backport of #16331.
@lambdageek

This comment has been minimized.

Copy link
Member

@lambdageek lambdageek commented Aug 27, 2019

All the error codes have been added and the PRs backported to 2019-08 and 2019-06.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.