-
Notifications
You must be signed in to change notification settings - Fork 47
[Bug] Thread-unsafe static service collection in PluginManager causes race conditions #348
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't workingsquadSquad triage inbox — Lead will assign to a memberSquad triage inbox — Lead will assign to a membersquad:riverAssigned to River (Backend Dev)Assigned to River (Backend Dev)
Description
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
IServiceProviderduring 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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingsquadSquad triage inbox — Lead will assign to a memberSquad triage inbox — Lead will assign to a membersquad:riverAssigned to River (Backend Dev)Assigned to River (Backend Dev)