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] mono_thread_attach repeat hit assert #91716

Open
srxqds opened this issue Sep 7, 2023 · 1 comment
Open

[mono] mono_thread_attach repeat hit assert #91716

srxqds opened this issue Sep 7, 2023 · 1 comment

Comments

@srxqds
Copy link
Contributor

srxqds commented Sep 7, 2023

Description

mono_thread_attach repeat hit assert in debugger-agent

Reproduction Steps

void TestMonoThreadProc()
{

	MonoThread* attachThread = mono_thread_attach(mono_domain_get());
	Scripting::InvokeClassMethod("UnrealEngine.Game", "UnrealEngine.Game.Tests.Runtime.MonoThreadTests", "TestEntry", nullptr, 0);
	mono_thread_detach(attachThread);
        // attach again will hit assert
	attachThread = mono_thread_attach(mono_domain_get());
	Scripting::InvokeClassMethod("UnrealEngine.Game", "UnrealEngine.Game.Tests.Runtime.MonoThreadTests", "TestEntry", nullptr, 0);
	mono_thread_detach(attachThread);

}

void TestMonoThreadAttach()
{
	thread th2(TestMonoThreadProc);
	
	th2.join(); 
}

Expected behavior

work correctly

Actual behavior

crash

Regression?

no, i think the mono always have this problem.

Known Workarounds

no

Configuration

No response

Other information

No response

stack trace

coreclr.dll!thread_startup(_MonoProfiler * prof, unsigned __int64 tid) 行 3880
	在 F:\netease-gitlab\dotnet\runtime\src\mono\mono\component\debugger-agent.c(3880)
coreclr.dll!mono_profiler_raise_thread_started(unsigned __int64 tid) 行 102
	在 F:\netease-gitlab\dotnet\runtime\src\native\public\mono\metadata\profiler-events.h(102)
coreclr.dll!fire_attach_profiler_events(unsigned long tid) 行 1093
	在 F:\netease-gitlab\dotnet\runtime\src\mono\mono\metadata\threads.c(1093)
coreclr.dll!mono_thread_internal_attach(_MonoDomain * domain) 行 1607
	在 F:\netease-gitlab\dotnet\runtime\src\mono\mono\metadata\threads.c(1607)
coreclr.dll!mono_thread_attach_external_native_thread(_MonoDomain * domain, int background) 行 1508
	在 F:\netease-gitlab\dotnet\runtime\src\mono\mono\metadata\threads.c(1508)
coreclr.dll!mono_thread_attach(_MonoDomain * domain) 行 1494
	在 F:\netease-gitlab\dotnet\runtime\src\mono\mono\metadata\threads.c(1494)
UE4Editor-MonoSample.dll!TestMonoThreadProc() 行 13
	在 D:\UnrealMono\uedemo4.27\Plugins\MonoSample\Source\MonoSample\Tests\Runtime\MonoThreadTest.cpp(13)
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Sep 7, 2023
@srxqds
Copy link
Contributor Author

srxqds commented Sep 7, 2023

can i fix replace with below code:

tls = (DebuggerTlsData *)mono_native_tls_get_value (debugger_tls_id);
	// g_assert (!tls);
	// FIXME: Free this somewhere
	if (!tls)
        {
		tls = g_new0 (DebuggerTlsData, 1);
               mono_native_tls_set_value (debugger_tls_id, tls);
       }

@SamMonoRT SamMonoRT removed the untriaged New issue has not been triaged by the area owner label Sep 13, 2023
@SamMonoRT SamMonoRT added this to the 9.0.0 milestone Sep 13, 2023
@mangod9 mangod9 modified the milestones: 9.0.0, Future Jul 10, 2024
@fanyang-mono fanyang-mono removed their assignment Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants