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

check null terminated messages #75

Merged
merged 1 commit into from
Mar 26, 2015
Merged

check null terminated messages #75

merged 1 commit into from
Mar 26, 2015

Conversation

nickdesaulniers
Copy link
Owner

@@ -1,7 +1,5 @@
// https://github.com/chuckremes/nn-core/blob/master/spec/nn_send_spec.rb

var assert = require('assert');
var should = require('should');
var nano = require('../');
var nn = nano._bindings;

Copy link
Collaborator

Choose a reason for hiding this comment

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

we can remove var nn = nano._bindings; here

Copy link
Owner Author

Choose a reason for hiding this comment

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

let's leave it for this PR and I'll target unnecessary requires in #74

@nickdesaulniers
Copy link
Owner Author

huh, bunch of failed tests, I wonder if the utf8 is getting GC'd

@reqshark
Copy link
Collaborator

osx is passing.

fails on my ubuntu server same as the tests.. hmm

size_t length = 0;

// check if Local<v8::Value> is a v8::String
if (args[1]->IsString()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

what's a V8::String?

@nickdesaulniers
Copy link
Owner Author

I'm quite certain that because I'm using args[1] directly, it's getting GC'd before libuv sends the message, so whatever is sent is completely random memory! Will need to copy the string. :(

@nickdesaulniers
Copy link
Owner Author

Also, this only seems to failing for strings, not buffers.

@reqshark
Copy link
Collaborator

just check for buffer instance otherwise assume string and don't return undefined. that might fix

@nickdesaulniers nickdesaulniers force-pushed the null-term branch 2 times, most recently from a67941a to 06054e2 Compare March 26, 2015 04:20
@nickdesaulniers
Copy link
Owner Author

pushing another test, not holding my breath though. I know we have no issues for buffers, but we definitely do for strings, since I believe we're adding the null byte (so this patch still doesn't address the whole point of the PR)

@nickdesaulniers
Copy link
Owner Author

ah! NO_NULL_TERMINATION

@nickdesaulniers
Copy link
Owner Author

yep, don't merge yet, I've got a bunch of ideas to clean this up

@nickdesaulniers
Copy link
Owner Author

so, this whole thing might have been a waste of time. I just added a test that sends a string, and sure enough it looks like we have nothing to worry about

@nickdesaulniers
Copy link
Owner Author

that took some serious patch surgery to save just the tests. These tests help show we don't send null terminated msgs from the application layer. patch ready for review

@reqshark
Copy link
Collaborator

LGTM.

btw, I think we may end up encountering some of this issue again in the near future when we introduce zero-copy send operations using the nn_allocmsg stuff

@reqshark reqshark changed the title Dont null terminate messages. See: check null terminated messages Mar 26, 2015
@reqshark reqshark merged commit 727f552 into master Mar 26, 2015
@reqshark reqshark deleted the null-term branch March 26, 2015 12:42
@reqshark
Copy link
Collaborator

sizzurp 727f552

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.

2 participants