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

mono_thread_info_exit ignores exit_code and just passes 0 on. #10467

Closed
jaykrell opened this issue Sep 4, 2018 · 1 comment

Comments

@jaykrell
Copy link
Collaborator

@jaykrell jaykrell commented Sep 4, 2018

mono-threads.c:

void
mono_thread_info_exit (gsize exit_code)
{
	mono_thread_info_detach ();

	mono_threads_platform_exit (0);
}

Why does it pass 0 and not exit_code? This seems very counter intuitive, and there is no comment.

jaykrell added a commit to jaykrell/mono that referenced this issue Sep 4, 2018
…2 vs. gulong."

This reverts commit 8e02c9c.

mono#10432 (comment)

This area of thread creation is a mess in several ways.
1. We have function pointers with almost gratuitous casts,
2. inconsistent return types (motivating function pointer casts)
3. return values ignored

mono#10467
mono#10319 (comment)
and more.
@luhenry

This comment has been minimized.

Copy link
Member

@luhenry luhenry commented Sep 5, 2018

Follow the template if you want anyone to take a look at it. How do we reproduce? How does it impact anything?

@luhenry luhenry closed this Sep 5, 2018
jaykrell added a commit that referenced this issue Sep 5, 2018
* [cxx][metadata] Cast from void.

* [cxx][metadata] Casts, mostly from void*.

* [cxx] [metadata] MONO_BEGIN_DECLS / MONO_END_DECLS only in public headers.
G_BEGIN_DECLS / G_END_DECLS are ok in private headers (and .c), but the vast majority of uses are not needed. In this case, every function is MONO_API anyway.

* [cxx] [metadata] Add template for mono_mb_emit_native_call under #ifdef __cplusplus.

* [cxx] [metadata] Loosen the parameter type in mono_vtype_get_field_addr from guint8* to gpointer.

* [cxx][metadata][profiler] Add G_ENUM_FUNCTIONS (MonoProfilerCallInstrumentationFlags), outside of the public header MonoProfilerCallInstrumentationFlags is defined in.

* [cxx][metadata][profiler] Cast void* to function pointer MonoProfilerCallInstrumentationFilterCallback.

* [cxx][metadata] Cast from void*.

* [cxx][metadata][sgen] Change sgen_client_root_registered(source) from int to enum MonoGCRootSource.

* [cxx][metadata][sgen] Change report_conservative_roots(root_report_address) from char* to void*.

* [cxx][metadata][sgen] In mono_gc_register_obj_with_weak_fields, cast parameter from void* to MonoObject*.

* [cxx][metadata][sgen] In sgen_client_gchandle_created and sgen_client_gchandle_destroyed, cast handle_type from int to MonoGCHandleType. This could be better.

* [cxx][metadata][sre] In mono_dynimage_encode_constant, change local box_val from char* to void*.

* [cxx][metadata][sre] Change  swap_with_size(dest, val) from {,const}char* to {,const}void*. Move function starting brace to its own line.

* [cxx][metadata][sre] encode_cattr_value(argval) from char* to const void*.

* [cxx][metadata][sre] Add ICALL_EXPORT to ves_icall_TypeBuilder_create_runtime_class.

* [cxx][metadata] Templatize mono_thread_create_internal and mono_thread_create_checked. FIXME: Fix the parameter type and inputs.

* [cxx][metadata][threads] Cast from void* to MonoCoopMutex*.

* [cxx] Fix return type of  start_wrapper_internal -- guint32 vs. gulong.

* [cxx][metadata] In start_wrapper_internal, cast function pointer to void*. Later we should get all the types correct.

* [cxx][metadata] Fix return type of start_wrapper from gsize to mono_thread_start_return_t.

* [cxx][metadata] create_thread: Remove cast on first parameter to mono_thread_platform_create_thread.

* [cxx][metadata] Add ICALL_EXPORT on ves_icall_System_Threading_Thread_GetPriority.

* [cxx][metadata] g_cast does not allow for ternary operator though it could with one line; add casts to workaround; remove cycle optimization from error path, favoring smaller code.

* [cxx][metadata] ves_icall_System_IO_MonoIO_Read, ves_icall_System_IO_MonoIO_Write: Change relatively untyped data from char* to void*.

* [cxx][metadata] Add parentheses around define INVALID_HANDLE_VALUE to avoid surprises.

* [cxx][metadata] In mono_w32handle_convert_wait_ret, cast between int and enum MonoW32HandleWaitRet. We could also give up on enums for this type.

* [cxx][metadata]ves_icall_System_Diagnostics_Process_ShellExecuteEx_internal: Add cast to HWND.

* [cxx][metadata] Cast to HMODULE. Add const.

* [cxx] w32process.h: Add missing ICALL_EXPORT.

* [cxx][metadata] w32socket-win32.c: add const on string literals.

* [cxx] mono_w32socket_recvbuffers: cast to LPWSAOVERLAPPED and LPWSAOVERLAPPED_COMPLETION_ROUTINE.

* [cxx] mono_w32socket_send: cast from void* to char*.

* [cxx]mono_w32socket_sendbuffers cast to LPWSAOVERLAPPED and LPWSAOVERLAPPED_COMPLETION_ROUTINE.

* [cxx] mono_w32socket_getsockopt cast from void* to char*.

* [cxx] mono_w32socket_setsockopt cast from const void* to const char*.

* [cxx] mono_w32socket_ioctl fix out parameter written from glong* to DWORD* to avoid casts.

* [cxx] [w32socket] Remove casts on calls to mono_w32socket_getsockopt and mono_w32socket_setsockopt since they nicely accept void*  and const void*.

* [cxx][w32socket] Change output_bytes from glong to the correct DWORD to avoid casts.

* [cxx] Add ICALL_EXPORT to ves_icall_cancel_blocking_socket_operation.

* [cxx] Remove keyword 'template'.

* PR: Revert "[cxx] Fix return type of  start_wrapper_internal -- guint32 vs. gulong."
This reverts commit 8e02c9c.
#10432 (comment)

This area of thread creation needs work.
1. We have function pointers with almost gratuitous casts,
2. inconsistent return types (motivating function pointer casts)
3. return values ignored

#10467
#10319 (comment)
and more.
EgorBo added a commit to EgorBo/mono that referenced this issue Sep 10, 2018
* [cxx][metadata] Cast from void.

* [cxx][metadata] Casts, mostly from void*.

* [cxx] [metadata] MONO_BEGIN_DECLS / MONO_END_DECLS only in public headers.
G_BEGIN_DECLS / G_END_DECLS are ok in private headers (and .c), but the vast majority of uses are not needed. In this case, every function is MONO_API anyway.

* [cxx] [metadata] Add template for mono_mb_emit_native_call under #ifdef __cplusplus.

* [cxx] [metadata] Loosen the parameter type in mono_vtype_get_field_addr from guint8* to gpointer.

* [cxx][metadata][profiler] Add G_ENUM_FUNCTIONS (MonoProfilerCallInstrumentationFlags), outside of the public header MonoProfilerCallInstrumentationFlags is defined in.

* [cxx][metadata][profiler] Cast void* to function pointer MonoProfilerCallInstrumentationFilterCallback.

* [cxx][metadata] Cast from void*.

* [cxx][metadata][sgen] Change sgen_client_root_registered(source) from int to enum MonoGCRootSource.

* [cxx][metadata][sgen] Change report_conservative_roots(root_report_address) from char* to void*.

* [cxx][metadata][sgen] In mono_gc_register_obj_with_weak_fields, cast parameter from void* to MonoObject*.

* [cxx][metadata][sgen] In sgen_client_gchandle_created and sgen_client_gchandle_destroyed, cast handle_type from int to MonoGCHandleType. This could be better.

* [cxx][metadata][sre] In mono_dynimage_encode_constant, change local box_val from char* to void*.

* [cxx][metadata][sre] Change  swap_with_size(dest, val) from {,const}char* to {,const}void*. Move function starting brace to its own line.

* [cxx][metadata][sre] encode_cattr_value(argval) from char* to const void*.

* [cxx][metadata][sre] Add ICALL_EXPORT to ves_icall_TypeBuilder_create_runtime_class.

* [cxx][metadata] Templatize mono_thread_create_internal and mono_thread_create_checked. FIXME: Fix the parameter type and inputs.

* [cxx][metadata][threads] Cast from void* to MonoCoopMutex*.

* [cxx] Fix return type of  start_wrapper_internal -- guint32 vs. gulong.

* [cxx][metadata] In start_wrapper_internal, cast function pointer to void*. Later we should get all the types correct.

* [cxx][metadata] Fix return type of start_wrapper from gsize to mono_thread_start_return_t.

* [cxx][metadata] create_thread: Remove cast on first parameter to mono_thread_platform_create_thread.

* [cxx][metadata] Add ICALL_EXPORT on ves_icall_System_Threading_Thread_GetPriority.

* [cxx][metadata] g_cast does not allow for ternary operator though it could with one line; add casts to workaround; remove cycle optimization from error path, favoring smaller code.

* [cxx][metadata] ves_icall_System_IO_MonoIO_Read, ves_icall_System_IO_MonoIO_Write: Change relatively untyped data from char* to void*.

* [cxx][metadata] Add parentheses around define INVALID_HANDLE_VALUE to avoid surprises.

* [cxx][metadata] In mono_w32handle_convert_wait_ret, cast between int and enum MonoW32HandleWaitRet. We could also give up on enums for this type.

* [cxx][metadata]ves_icall_System_Diagnostics_Process_ShellExecuteEx_internal: Add cast to HWND.

* [cxx][metadata] Cast to HMODULE. Add const.

* [cxx] w32process.h: Add missing ICALL_EXPORT.

* [cxx][metadata] w32socket-win32.c: add const on string literals.

* [cxx] mono_w32socket_recvbuffers: cast to LPWSAOVERLAPPED and LPWSAOVERLAPPED_COMPLETION_ROUTINE.

* [cxx] mono_w32socket_send: cast from void* to char*.

* [cxx]mono_w32socket_sendbuffers cast to LPWSAOVERLAPPED and LPWSAOVERLAPPED_COMPLETION_ROUTINE.

* [cxx] mono_w32socket_getsockopt cast from void* to char*.

* [cxx] mono_w32socket_setsockopt cast from const void* to const char*.

* [cxx] mono_w32socket_ioctl fix out parameter written from glong* to DWORD* to avoid casts.

* [cxx] [w32socket] Remove casts on calls to mono_w32socket_getsockopt and mono_w32socket_setsockopt since they nicely accept void*  and const void*.

* [cxx][w32socket] Change output_bytes from glong to the correct DWORD to avoid casts.

* [cxx] Add ICALL_EXPORT to ves_icall_cancel_blocking_socket_operation.

* [cxx] Remove keyword 'template'.

* PR: Revert "[cxx] Fix return type of  start_wrapper_internal -- guint32 vs. gulong."
This reverts commit 8e02c9c.
mono#10432 (comment)

This area of thread creation needs work.
1. We have function pointers with almost gratuitous casts,
2. inconsistent return types (motivating function pointer casts)
3. return values ignored

mono#10467
mono#10319 (comment)
and more.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.