Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] CheckValidSockets no longer remove sockets from group, this was causing inconsistency. #1687

Merged

Conversation

ethouris
Copy link
Collaborator

@ethouris ethouris commented Dec 1, 2020

The problem: CheckValidSockets called CUDTGroup::remove (locked version) for a socket that it couldn't find in the global container. This, however, might cause that a socket already moved to ClosedSockets will be left with a dangling iterator to the group container entry.

@codecov

This comment has been minimized.

@maxsharabayko maxsharabayko added [core] Area: Changes in SRT library core Type: Bug Indicates an unexpected problem or unintended behavior labels Dec 1, 2020
@maxsharabayko maxsharabayko added this to the v1.4.3 milestone Dec 1, 2020
Comment on lines +1073 to +1074
d->sndstate = SRT_GST_BROKEN;
d->rcvstate = SRT_GST_BROKEN;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we safe to set this to broken? This happens under these locks:

  • m_pGlobal->m_GlobControlLock
  • m_GroupLock

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. The first one protects the sockets against being updated against the group (that is, removed from the group container in the meantime), the second one protects the m_Group container (members container). Note also that this function is being called from inside the sending function only, so it happens in the same thread as the transmission functions. A simultaneous call to a receiving function, let's say, isn't possible because it also requires lock on m_Group.

Comment on lines 1161 to 1163
CUDT* pu = 0;
if (d->ps)
pu = &d->ps->core();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be better.

Suggested change
CUDT* pu = 0;
if (d->ps)
pu = &d->ps->core();
const CUDT* pu = (d->ps)
? &d->ps->core()
: NULL;

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you meant CUDT* const pu = (d->ps) ...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, both. pu is not modified here, so const CUDT* const pu =....

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. In practice actually, this intermediate variable is only for having a shortcut - the condition would be more elaborate without it.

Comment on lines 3793 to 3795
CUDT* pu = 0;
if (d->ps)
pu = &d->ps->core();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const pu... like above

@maxsharabayko maxsharabayko merged commit b84f3d2 into Haivision:master Dec 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[core] Area: Changes in SRT library core Type: Bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants