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

Datachannel fix for sending arrayBuffers #170

Closed
wants to merge 12 commits into from

Conversation

vmolsa
Copy link

@vmolsa vmolsa commented Mar 10, 2015

No description provided.

@vmolsa vmolsa closed this Mar 18, 2015
@vmolsa vmolsa reopened this Mar 18, 2015
@modeswitch
Copy link

Thanks for updating this! I'll have a look when I get home tonight.

@vmolsa
Copy link
Author

vmolsa commented Mar 18, 2015

Np :) I need those changes for rtc-stream which depends on binary buffer..
https://www.npmjs.com/package/rtc-stream

@ecoulon
Copy link

ecoulon commented Mar 23, 2015

I have the segmentation fault bug too when sending thousands of buffers. I tried to rebuild with these fixes, the seg fault is gone but i've got this error that happen quickly (about 50-200 buffers sent)
I tried with node >= 0.12.0 and node < 0.12.0

node(22846,0x106181000) malloc: *** error for object 0x103070500: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug

Thanks for your great work!

@modeswitch
Copy link

@ecoulon It's worth noting that the malloc issue may be covering up the segmentation fault, so it may not be fixed.

@vmolsa Are you able to have a look at the malloc issue?

@modeswitch
Copy link

@ecoulon Could you link to a gist with your test case?

@ecoulon
Copy link

ecoulon commented Mar 23, 2015

I forgot to precise : this bug happen when sending large buffers.
When i send small buffers, i have no error and the seg fault does not occur anymore.

I can reproduce my bug when i set the example/bridge.js to send 200 big buffers.
for example : https://gist.github.com/6d3ee6b6876067b4c939
I change line 115/116

@vmolsa
Copy link
Author

vmolsa commented Mar 23, 2015

@ecoulon with node-0.12.0 can you try to comment lines 267 and 268 @ src/datachannel.cc,

-> // arraybuffer->Neuter();
-> // delete[] static_cast<char*>(content.Data());

and rebuild code with "node-gyp build". Is it working?
But doing so it will start to collect memory and not freeing it?

@ecoulon
Copy link

ecoulon commented Mar 23, 2015

Hmm with these two lines commented i have 3 different results (seems to be random) :

  • the most often i have the same error
  • i had the seg fault a few times
  • it works a few times too with no error

@vmolsa
Copy link
Author

vmolsa commented Mar 23, 2015

Thanks, I created gist for sending multiple buffers with different times / sizes. And yes it's failing almost every time..

https://gist.github.com/vmolsa/84aab2974132d189574e

@vmolsa
Copy link
Author

vmolsa commented Mar 30, 2015

Datachannel max buffer size on node is 66528 bytes and on browser it's 73905 bytes (why?) without splitting input buffers and cause of that splitting some bytes will be lost..

Most of segfaults are coming from webrtc thread. rtc::Buffer() allocates new memory segment each time and copies data from string / arraybuffer to that segment and webrtc thread releases that buffer after it's not needed. So the problem is not in node-webrtc module?..

@modeswitch can you update libwebrtc?

node-v0.12.0
node(57067,0x1016fc000) malloc: *** error for object 0x1: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
0: SIGABRT [0x7fff9811f41d] thread_start
1: SIGABRT [0x7fff981211e5] pthread_body
2: SIGABRT [0x7fff98121268] pthread_body
3: SIGABRT [0x10340b9c6] rtc::Thread::PreRun(void
)
4: SIGABRT [0x10340bd3d] rtc::Thread::ProcessMessages(int)
5: SIGABRT [0x10335a000] cricket::DataChannel::OnMessage(rtc::Message
)
6: SIGABRT [0x10330c10f] webrtc::DataChannel::SendQueuedDataMessages()
7: SIGABRT [0x7fff9a6ad937] nano_size
8: SIGABRT [0x7fff8f102b53] abort
9: SIGABRT [0x10131bd01] function()

node-v0.11.16
0: SIGSEGV [0x106fb03060a2] function()
1: SIGSEGV [0x10042b23f] v8::internal::Runtime_TypedArrayInitializeFromArrayLike(int, v8::internal::Object*, v8::internal::Isolate)
2: SIGSEGV [0x1002334ad] v8::internal::Factory::NewJSArrayBuffer()
3: SIGSEGV [0x10026853d] v8::internal::Heap::CollectGarbage(v8::internal::GarbageCollector, char const_, char const_, v8::GCCallbackFlags)
4: SIGSEGV [0x100268c3f] v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags)
5: SIGSEGV [0x10024a787] v8::internal::GlobalHandles::PostGarbageCollectionProcessing(v8::internal::GarbageCollector)
6: SIGSEGV [0x10024ba34] v8::internal::GlobalHandles::Node::PostGarbageCollectionProcessing(v8::internal::Isolate*)
7: SIGSEGV [0x103a89707] node::ObjectWrap::WeakCallback(v8::WeakCallbackData<v8::Object, node::ObjectWrap> const&)
8: SIGSEGV [0x103a8a688] node_webrtc::DataChannel::~DataChannel()
9: SIGSEGV [0x103a8a648] node_webrtc::DataChannel::~DataChannel()
10: SIGSEGV [0x103a993ff] rtc::RefCountedObjectwebrtc::DataChannelProxy::Release()
11: SIGSEGV [0x103a9942e] rtc::RefCountedObjectwebrtc::DataChannelProxy::~RefCountedObject()
12: SIGSEGV [0x103a9a5bb] webrtc::DataChannelProxy::~DataChannelProxy()

@@ -41,6 +41,11 @@ function RTCDataChannel(internalDC) {
return this.RTCDataStates[state];
}
},
'bufferedAmount': {
get: function getReadyState() {

Choose a reason for hiding this comment

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

getReadyState is the wrong name for this function

Choose a reason for hiding this comment

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

This was pulled in from another patch, so you can revert the implementation for bufferedAmount. If you update your local copy it will be there.

}
}
}
/*

Choose a reason for hiding this comment

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

This should be removed instead of commented out. If we need it again, it's in the repo history.

Copy link
Author

Choose a reason for hiding this comment

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

It will gain better performance by using switch cases.

@modeswitch
Copy link

Can you elaborate on the problem this patch is meant to fix? It's a little difficult given the size of the patch to determine whether it addresses the original issue.

@@ -7,6 +7,7 @@ language: node_js
node_js:
- "0.10"
- "0.11"
- "0.12"

Choose a reason for hiding this comment

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

This was pulled in from another patch, so you can revert it here.

@vmolsa
Copy link
Author

vmolsa commented Apr 4, 2015

I'm currently working with another webrtc fork. These changes will fix some of problems.
Meaning that this project should be more compatible with webrtc API.

https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection

@vmolsa vmolsa closed this Apr 4, 2015
@modeswitch
Copy link

@vmolsa Why was this closed?

@janza janza mentioned this pull request Apr 4, 2015
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.

None yet

3 participants