dokan-dev / dokan-dotnet

Dokan DotNet Wrapper
http://dokan-dev.github.io
MIT License
462 stars 116 forks source link

Encountered infinite recursion for setting SingleThread=false in DOKAN_OPTIONS #344

Closed LinusABC closed 1 year ago

LinusABC commented 1 year ago

Dear all,

I have tried to call DokanCreateFileSystem, setting SingleThread=false in DOKAN_OPTIONS. However, the following error is occurred after running my program for certain period, and my program will then halt. If I set SingleThread=true, it runs normally. Please suggest how can I solve the problem. Thanks.

The error, found in event viewer, is as follows:

Application: XXX.exe CoreCLR Version: 7.0.1323.51816 .NET Version: 7.0.13 Description: The application requested process termination through System.Environment.FailFast. Message: Encountered infinite recursion while looking up resource 'Arg_NullReferenceException' in System.Private.CoreLib. Verify the installation of .NET is complete and does not need repairing, and that the state of the process has not become corrupted. Stack: at System.Environment.FailFast(System.String) at System.SR.InternalGetResourceString(System.String) at System.SR.GetResourceString(System.String) at System.NullReferenceException..ctor() at System.Globalization.CultureInfo.get_CurrentUICulture() at System.Resources.ResourceManager.GetString(System.String, System.Globalization.CultureInfo) at System.SR.InternalGetResourceString(System.String) at System.SR.GetResourceString(System.String) at System.NullReferenceException..ctor() at System.Threading.ThreadPoolWorkQueue.Dispatch() at System.Threading.PortableThreadPool+WorkerThread.WorkerThreadStart()

LTRData commented 1 year ago

This is a strange error in several ways. It looks like two exceptions, first a NullReferenceException and then another exception when it tries to lookup a localized message string for that exception. Also, this all happens in a pool thread so it would need to be caught in that particular thread method, otherwise the application crashes like this.

Do you have any places in your code where you use worker threads, such as ThreadPool.QueueUserWorkItem or Task.Run? If so, try to add exception handling in the methods that are started in a pool thread. Also check for places where you might call things that are not thread safe. Most of .NET API is not thread safe and require separate object instances per thread or otherwise some kind of synchronization mechanism to make sure that an object instance is only used by one thread at a time.