Skip to content

Deadlocks and race conditions on stop / dispose in 3.10 #681

@coldays

Description

@coldays

After using 3.10 for a while, I've discovered a few deadlocks, null refs and race conditions in the new rendering system when disposing or stopping a player.

I've looked into fixing them and some might be easier fixes than others.

Renderer.Preset.cs:

  • RenderIdleLoop is the only place that sets isIdleRunning to false. However, it can call
    RenderIdleLoop -> RenderIdle -> SharpGenException -> ResetLocal -> RenderIdleStop.
    RenderIdleStop waits for isIdleRunning to be set to false which cannot happen since RenderIdleLoop is waiting for itself.

SwapChain.cs:

  • Multiple threads can call DisposeLocal at the same time which may provoke uncaught null ref exceptions.

Renderer.VP.D3.cs:

  • D3Dispose might stall on vp.Dispose(), tried moving context.ClearState() and context.Flush() earlier in the Dispose call, but that would also sometimes stall. I think it might have to do with another thread already using the context for rendering while Dispose is trying to free the resource.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions