Skip to content

Deadlock on Dispose #576

@igvk

Description

@igvk

Issue Title

Deadlock condition when Disposing CommandManager

Issue Categories

  • Bug

Version Information

  • Build From Master branch, Commit bae88aa

Steps to Reproduce

Open media file, then close the player

Code

There exists deadlock condition in CommandManager.OnDisposing and ExecuteDirectCommand when there IsDirectCommandPending.
PauseAsync eternally waits for the lock that is held by Dispose in the main thread.

WorkerBase.cs:

        protected virtual void Dispose(bool alsoManaged)
        {
            StopAsync().Wait();

            lock (SyncLock)
            {
            ...
                try { OnDisposing(); } catch { /* Ignore */ }
            ...
        }

        public Task<WorkerState> PauseAsync()
        {
            lock (SyncLock)
            {
            ...
        }


CommandManager.cs:

        protected override void OnDisposing()
        {
            ...
            // wait for any pending direct commands (unlikely)
            this.LogDebug(Aspects.EngineCommand, "Dispose is waiting for pending direct commands.");
            while (IsDirectCommandPending)
                Task.Delay(Constants.DefaultTimingPeriod).Wait();
            ...
        }


CommandManager.Direct.cs:

        private Task<bool> ExecuteDirectCommand(DirectCommandType command, Func<bool> commandDeleagte)
        {
            ...
                    PauseAsync().Wait();
            ...
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions