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

Fix sctp crash #333

Closed
wants to merge 2 commits into from
Closed

Fix sctp crash #333

wants to merge 2 commits into from

Conversation

chehefen
Copy link
Contributor

@chehefen chehefen commented Apr 8, 2020

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov-io
Copy link

Codecov Report

Merging #333 into master will increase coverage by 0.08%.
The diff coverage is 96.29%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #333      +/-   ##
==========================================
+ Coverage   86.95%   87.04%   +0.08%     
==========================================
  Files          33       33              
  Lines        8028     8044      +16     
==========================================
+ Hits         6981     7002      +21     
+ Misses       1047     1042       -5     
Impacted Files Coverage Δ
src/source/Sctp/Sctp.c 97.48% <96.29%> (-0.42%) ⬇️
src/source/Ice/IceAgent.c 93.81% <0.00%> (ø)
src/source/Signaling/LwsApiCalls.c 85.28% <0.00%> (+0.66%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e1cf453...69f66a6. Read the comment docs.

Copy link
Contributor

@MushMal MushMal left a comment

Choose a reason for hiding this comment

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

Could I ask to include more info on the crash - whether this is customer reported, etc..

@@ -1,6 +1,8 @@
#define LOG_CLASS "SCTP"
#include "../Include_i.h"

static volatile PSctpSessionControl pSctpSessionControl = NULL;
Copy link
Contributor

Choose a reason for hiding this comment

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

We shouldn't use statics here. This can be part of the object graph. Please change the deinitSctpSession to take this object of a parent object that it can use instead of the global

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This thing out lives peerConnection, so we dont have a right parent object for it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I understand now your point. Let's make this a high-level object that's lifespan will be tracked at the application level.

Have createSctpSession and freeSctpSession. The object created then will be passed to the perr connections?

@@ -63,15 +65,33 @@ STATUS initSctpSession()
// Disable Explicit Congestion Notification
usrsctp_sysctl_set_sctp_ecn_enable(0);

pSctpSessionControl = MEMALLOC(SIZEOF(SctpSessionControl));
Copy link
Contributor

Choose a reason for hiding this comment

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

The init and deinit can take an object/return an object to avoid the global. This object then can be part of the overall WebRTC object graph

Copy link
Contributor

Choose a reason for hiding this comment

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

It will still be a global though right? It is shared among all PeerConnections

Copy link
Contributor

Choose a reason for hiding this comment

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

Having mutable globals is a very bad idea at a high-level code. I think we might need to have a high-level object that lives in parallel with peer connection (like the signaling client) that will be passed into peer connection and it's lifecycle managed by the app

@@ -63,15 +65,33 @@ STATUS initSctpSession()
// Disable Explicit Congestion Notification
usrsctp_sysctl_set_sctp_ecn_enable(0);

pSctpSessionControl = MEMALLOC(SIZEOF(SctpSessionControl));
pSctpSessionControl->lock = MUTEX_CREATE(FALSE);
CHK_STATUS(hashTableCreate(&pSctpSessionControl->activeSctpSessions));
Copy link
Contributor

Choose a reason for hiding this comment

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

Use the parameterized version of the hash table. The default will create 2 * 10K buckets


/* If the key is not in activeSctpSessions, then the session must have been freed. Thus do not call callback.
* Fixes issue stated here: https://github.com/sctplab/usrsctp/issues/147.
* (return -1 otherwise usrsctp_finish() won't finish) */
Copy link
Contributor

Choose a reason for hiding this comment

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

So when do we return -1?

struct socket *socket;
SctpSessionCallbacks sctpSessionCallbacks;
UINT64 key;
Copy link
Contributor

Choose a reason for hiding this comment

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

So you use store the current time here and this acts as the key in the hash table. Perhaps add a comment to state what you use as a key. Also, we really need to create a hashset object in PIC

@Sean-Der
Copy link
Contributor

Sean-Der commented Apr 8, 2020

Sorry for the push back, but I think this will just end up accruing more technical debt :/

  • Are you able to easily reproduce? Maybe we can get upstream to help.
  • We could also do github.com/Single thread sctplab/usrsctp#339 and then have a timer pull from the association? That could fix everything for us!

@niyatim23
Copy link
Contributor

PR open in develop branch

@niyatim23 niyatim23 closed this Aug 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants