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

[iOS] AOT: mono_gc_pthread_create Cannot transition thread 0x16b77b000 from STATE_BLOCKING with DO_BLOCKING #47121

Closed
EgorBo opened this issue Jan 18, 2021 · 4 comments · Fixed by #48465
Assignees
Milestone

Comments

@EgorBo
Copy link
Member

EgorBo commented Jan 18, 2021

Steps to reproduce (on a clean repo):

cd src/mono/netcore/sample/iOS
make all MONO_CONFIG=Debug MONO_ARCH=arm64 USE_LLVM=false AOT=true

(or MONO_ARCH=x64 for simulators)

Open ~/prj/runtime/src/mono/netcore/sample/iOS/bin/ios-arm64/publish/app/HelloiOS/HelloiOS.xcodeproj in XCode, solve all signing issues if any (in case of physical devices), e.g.:

image

try to deploy the app to a physical device or a simulator.

Observe a runtime crash:

2021-01-18 16:22:07.980830+0300 HelloiOS[738:177189] assembly_preload_hook: System.Private.CoreLib (null) /private/var/containers/Bundle/Application/1EC7039A-4661-454C-B89A-815E6F80932D/HelloiOS.app
2021-01-18 16:22:07.985347+0300 HelloiOS[738:177189] Looking for aot data for assembly 'System.Private.CoreLib'.
2021-01-18 16:22:07.985593+0300 HelloiOS[738:177189] Loaded aot data for System.Private.CoreLib.
2021-01-18 16:22:08.056385+0300 HelloiOS[738:177189] ((null) error) mono_gc_pthread_create Cannot transition thread 0x16be63000 from STATE_BLOCKING with DO_BLOCKING
2021-01-18 16:22:08.056427+0300 HelloiOS[738:177189] Exit code: 1.
@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Jan 18, 2021
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@lambdageek
Copy link
Member

Probably due to the switch to hybrid suspend in #46873 - going to try to fix it if I can get a stack trace (it should be straightforward - we're calling MONO_ENTER_GC_SAFE somewhere after we came in from a Mono API that doesn't have a MONO_ENTER_GC_UNSAFE. Just need a good stack trace.

@rolfbjarne
Copy link
Member

@lambdageek I'm running into this now on iOS:

2021-02-18 09:04:05.733 link all[4445:4884336] error: mono_gc_pthread_create Cannot transition thread 0x1050dd880 from STATE_BLOCKING with DO_BLOCKING

=================================================================
	Native Crash Reporting
=================================================================
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.
=================================================================

=================================================================
	Native stacktrace:
=================================================================
	0x10260b2bc - /private/var/containers/Bundle/Application/A1AA667A-928A-4560-988A-827119F3B577/link all.app/link all : mono_dump_native_crash_info
	0x1025f5114 - /private/var/containers/Bundle/Application/A1AA667A-928A-4560-988A-827119F3B577/link all.app/link all : mono_handle_native_crash
	0x10260a68c - /private/var/containers/Bundle/Application/A1AA667A-928A-4560-988A-827119F3B577/link all.app/link all : sigabrt_signal_handler
	0x19ae61414 - /usr/lib/system/libsystem_platform.dylib : <redacted>
	0x19ae64948 - /usr/lib/system/libsystem_pthread.dylib : pthread_kill
	0x19adf3ba4 - /usr/lib/system/libsystem_c.dylib : abort
	0x102412b8c - /private/var/containers/Bundle/Application/A1AA667A-928A-4560-988A-827119F3B577/link all.app/link all : _ZL12log_callbackPKcS0_S0_iPv
	0x102479280 - /private/var/containers/Bundle/Application/A1AA667A-928A-4560-988A-827119F3B577/link all.app/link all : monoeg_g_logv
	0x1024793b4 - /private/var/containers/Bundle/Application/A1AA667A-928A-4560-988A-827119F3B577/link all.app/link all : monoeg_g_log
	0x10257997c - /private/var/containers/Bundle/Application/A1AA667A-928A-4560-988A-827119F3B577/link all.app/link all : mono_threads_transition_do_blocking
	0x10257b014 - /private/var/containers/Bundle/Application/A1AA667A-928A-4560-988A-827119F3B577/link all.app/link all : mono_threads_enter_gc_safe_region_unbalanced_with_info
	0x1025530fc - /private/var/containers/Bundle/Application/A1AA667A-928A-4560-988A-827119F3B577/link all.app/link all : mono_gc_pthread_create
	0x10257a200 - /private/var/containers/Bundle/Application/A1AA667A-928A-4560-988A-827119F3B577/link all.app/link all : mono_thread_platform_create_thread
	0x102513ec0 - /private/var/containers/Bundle/Application/A1AA667A-928A-4560-988A-827119F3B577/link all.app/link all : create_thread
	0x102513bf4 - /private/var/containers/Bundle/Application/A1AA667A-928A-4560-988A-827119F3B577/link all.app/link all : mono_thread_create_internal
	0x102541f80 - /private/var/containers/Bundle/Application/A1AA667A-928A-4560-988A-827119F3B577/link all.app/link all : mono_gc_init_finalizer_thread
	0x102422d38 - /private/var/containers/Bundle/Application/A1AA667A-928A-4560-988A-827119F3B577/link all.app/link all : -[XamarinGCSupport start]
	0x102422c9c - /private/var/containers/Bundle/Application/A1AA667A-928A-4560-988A-827119F3B577/link all.app/link all : -[XamarinGCSupport init]
	0x10242342c - /private/var/containers/Bundle/Application/A1AA667A-928A-4560-988A-827119F3B577/link all.app/link all : xamarin_main
	0x10265a018 - /private/var/containers/Bundle/Application/A1AA667A-928A-4560-988A-827119F3B577/link all.app/link all : main
	0x19af4f384 - /usr/lib/system/libdyld.dylib : <redacted>

is there a way to disable hybrid suspend on my side, or do I have to wait until it's fixed in mono?

@marek-safar marek-safar removed the untriaged New issue has not been triaged by the area owner label Feb 18, 2021
@marek-safar marek-safar added this to the 6.0.0 milestone Feb 18, 2021
lambdageek added a commit to lambdageek/runtime that referenced this issue Feb 18, 2021
when lazy thread creation is used, this external API function is called
from a thread in GC Safe mode, so enter GC Unsafe before calling runtime
functions.

Fixes a double transition to GC Safe in mono_gc_pthread_create.

Fixes dotnet#47121
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Feb 18, 2021
@lambdageek
Copy link
Member

Thanks for the stack trace, @rolfbjarne. PR is up. meanwhile setenv MONO_THREADS_SUSPEND to preemptive

rolfbjarne added a commit to rolfbjarne/xamarin-macios that referenced this issue Feb 18, 2021
The default was changed to be hybrid suspend, and due to bugs in Mono that
crashes:

dotnet/runtime#47121

In the meantime we can go back to the older GC mode until Mono has fixed any
issues with the hybrid suspend mode.
lambdageek added a commit that referenced this issue Feb 18, 2021
when lazy thread creation is used, this external API function is called
from a thread in GC Safe mode, so enter GC Unsafe before calling runtime
functions.

Fixes a double transition to GC Safe in mono_gc_pthread_create.

Fixes #47121
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Feb 18, 2021
rolfbjarne added a commit to xamarin/xamarin-macios that referenced this issue Feb 19, 2021
The default was changed to be hybrid suspend, and due to bugs in Mono that
crashes:

dotnet/runtime#47121

In the meantime we can go back to the older GC mode until Mono has fixed any
issues with the hybrid suspend mode.
@ghost ghost locked as resolved and limited conversation to collaborators Mar 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants