Summary
PluginManager uses static mutable collections (IServiceCollection and IServiceProvider?) without thread synchronization. Concurrent plugin loads or config changes cause race conditions.
Affected Files
| File |
Lines |
Detail |
src/SharpSite.Web/PluginManager.cs |
25-26 |
Static _ServiceDescriptors and _ServiceProvider |
src/SharpSite.Web/PluginManager.cs |
134-144 |
Unsynchronized add/remove on config change |
src/SharpSite.Plugins/PluginAssemblyManager.cs |
12, 19-31 |
Unguarded dictionary |
Risks
- Collection modified during enumeration
- Stale
IServiceProvider during concurrent access
- Race conditions on concurrent plugin loads
Recommended Fix
Add lock or ReaderWriterLockSlim around all collection mutations. Use ConcurrentDictionary for PluginAssemblyManager. Use Interlocked.Exchange for provider swaps.
Estimated Effort
3-4 hours
Summary
PluginManageruses static mutable collections (IServiceCollectionandIServiceProvider?) without thread synchronization. Concurrent plugin loads or config changes cause race conditions.Affected Files
src/SharpSite.Web/PluginManager.cs_ServiceDescriptorsand_ServiceProvidersrc/SharpSite.Web/PluginManager.cssrc/SharpSite.Plugins/PluginAssemblyManager.csRisks
IServiceProviderduring concurrent accessRecommended Fix
Add
lockorReaderWriterLockSlimaround all collection mutations. UseConcurrentDictionaryforPluginAssemblyManager. UseInterlocked.Exchangefor provider swaps.Estimated Effort
3-4 hours