Skip to content

[Bug] Thread-unsafe static service collection in PluginManager causes race conditions #348

Description

@csharpfritz

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingsquadSquad triage inbox — Lead will assign to a membersquad:riverAssigned to River (Backend Dev)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions