Skip to content

Missed synchronization #826

@jinek

Description

@jinek

While investigating other issues I’ve found probably few hard to reproduce issue.

I haven’t seen them happening, but I’ve seen several issues which are claimed as hard to reproduce/happens under heavy load, so may be it could help there. In original PR (where code has been introduced) that was mentioned also.

This block accessing sockets array


is not synchronized with this one
if (sockets[i] != null) // sockets[i] can be null if cancel callback is executed during connect()

The following order seems is possible:

  1. if (sockets[i] != null && !sockets[i].Connected) is true
  2. if (sockets[i] != null) gives true
  3. if (sockets[i].Connected) gives true
  4. sockets[i].Dispose();
  5. availableSocket = sockets[i];
  6. break; return availableSocket;

In this case socket is first returned and then at random time disposed while being used (user does not receive any exceptions, connection just disposes).
But there are also many hard investigate synchronization/exceptions things there. I think may be that entire file and related should be checked/reviewed again.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area\Managed SNIIssues that are targeted to the Managed SNI codebase.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions