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

Assertion `(offset) < (storage_size)' failed. #3182

Closed
maciej-zuk opened this issue Oct 5, 2015 · 7 comments
Closed

Assertion `(offset) < (storage_size)' failed. #3182

maciej-zuk opened this issue Oct 5, 2015 · 7 comments
Labels
c++ Issues and PRs that require attention from people who are familiar with C++.

Comments

@maciej-zuk
Copy link

Hi, I have following exception when I run code (it uses http and http-post internally and was working in 0.12.* node)
node: ../src/stream_base.cc:157: int node::StreamBase::Writev(const v8::FunctionCallbackInfov8::Value&): Assertion `(offset) < (storage_size)' failed.

$ node -v
v4.1.1

$ npm -v
3.3.5

i can provide details if needed

@bnoordhuis
Copy link
Member

Do you have a small test case that reproduces it, no third-party modules?

@mscdex mscdex added the c++ Issues and PRs that require attention from people who are familiar with C++. label Oct 5, 2015
@maciej-zuk
Copy link
Author

Here you are (logic extracted from http-post):

var options = require('url').parse('http://XYZ:3000/build');
options.method = 'POST';
options.headers = {
    'Content-Type': 'multipart/form-data; boundary=-----np0.25114468042738736',
    'Content-Length': 8809774
};

var req = require('http').request(options, function(responce) {
    console.log('response');
});

var fs = require('fs');
req.write('-------np0.25114468042738736\r\n');
req.write('Content-Disposition: form-data; name="token"\r\n\r\n');
req.write('some-token\r\n');
req.write('-------np0.25114468042738736\r\n');
req.write('Content-Disposition: form-data; name="targets"\r\n\r\n');
req.write('some-data\r\n');
req.write('-------np0.25114468042738736\r\n');
req.write('Content-Disposition: form-data; name="zip"; filename="trunk.zip"\r\n\r\n');
req.write(fs.readFileSync('./trunk.zip', 'binary'));
req.write('\r\n');
req.write('-------np0.25114468042738736--\r\n');
req.end();

XYZ is host accepting post requests at port 3000. Problematic part seems to be writing binary data to http request.

@bnoordhuis
Copy link
Member

What does trunk.zip contain in your example? How big is it approximately?

@maciej-zuk
Copy link
Author

it's a zip archive ~8.8MByte

@maciej-zuk
Copy link
Author

ok, update: it seems that if you put 'Content-Length' smaller than actual content size it throws that exception

actualy if you put any 'Content-Lenght', if you ommit that it works

@maciej-zuk
Copy link
Author

Minimal example:

var options = require('url').parse('http://posttestserver.com/post.php');
options.method = 'POST';
options.headers = {
    'Content-Type': 'multipart/form-data; boundary=-----np0.13421504013240337',
    'Content-Length': 1
};

var req = require('http').request(options, function(responce) {
    console.log('response');
});

var fs = require('fs');
req.write('-------np0.926842468092218--\r\n');
req.write('Content-Disposition: form-data; name="name"; filename="name"\r\n\r\n');
req.write(fs.readFileSync('./test', 'binary'));
req.write('\r\n');
req.write('-------np0.926842468092218--\r\n');
req.end();

test file is created as:
dd if=/dev/urandom of=test count=20000

@maciej-zuk
Copy link
Author

tested on node v4.1.2 and it works :) much ado about nothing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++.
Projects
None yet
Development

No branches or pull requests

3 participants