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

Cannot access a disposed object #176

Open
NikitaEgorov opened this issue May 10, 2024 · 2 comments
Open

Cannot access a disposed object #176

NikitaEgorov opened this issue May 10, 2024 · 2 comments
Labels

Comments

@NikitaEgorov
Copy link

Description

I get an exception when I use HostBuilder in Unit Tests under debug.

System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.Threading.ThreadLocal`1[[System.Collections.Concurrent.ConcurrentBag`1+WorkStealingQueue[[MonoMod.Core.Platforms.Memory.PagedMemoryAllocator+Page, 0Harmony, Version=2.3.3.0, Culture=neutral, PublicKeyToken=null]], System.Collections.Concurrent, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]]'.
   at System.Threading.ThreadLocal`1.GetValueSlow()
   at System.Collections.Concurrent.ConcurrentBag`1.Add(T item)
   at MonoMod.Core.Platforms.Memory.PagedMemoryAllocator.RegisterForCleanup(Page page) in /_/src/MonoMod.Core/Platforms/Memory/PagedMemoryAllocator.cs:line 375
   at MonoMod.Core.Platforms.Memory.PagedMemoryAllocator.Page.FreeMem(UInt32 offset, UInt32 size) in /_/src/MonoMod.Core/Platforms/Memory/PagedMemoryAllocator.cs:line 240
   at MonoMod.Core.Platforms.Memory.PagedMemoryAllocator.PageAllocation.Dispose(Boolean disposing) in /_/src/MonoMod.Core/Platforms/Memory/PagedMemoryAllocator.cs:line 56
   at MonoMod.Core.Platforms.Memory.PagedMemoryAllocator.PageAllocation.Finalize() in /_/src/MonoMod.Core/Platforms/Memory/PagedMemoryAllocator.cs:line 66

I have no idea why that exception happened. And I don't know how to provide any details.

@nike4613
Copy link
Contributor

What runtime are you on? When are you seeing this exception? I would expect it to only happen on shutdown, but AFAIK only .NET Framework (and maybe Mono) actually tries to run all finalizers on shutdown.

@NikitaEgorov
Copy link
Author

NikitaEgorov commented May 10, 2024

.NET8+Windows

The exception occurs when I call HostBuilder.Build() in debug session in unit test xunit + allure.xunit (2.12.0)
I created a corresponding issue for Allure allure-framework/allure-csharp#500

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants