Skip to content

Instantly share code, notes, and snippets.

@pepve
Last active December 18, 2015 00:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pepve/5694305 to your computer and use it in GitHub Desktop.
Save pepve/5694305 to your computer and use it in GitHub Desktop.

Node bug 5504

Steps to reproduce nodejs/node-v0.x-archive#5504. With either Vagrant/VirtualBox or plain EC2.

Vagrant/VirtualBox

vagrant up
vagrant ssh
git clone git://github.com/joyent/node.git
cd node
./configure
make
./node /vagrant/server.js
  • Open another terminal to monitor the VM, in the new directory:
vagrant ssh
top
  • Yet another terminal, local, in the new directory:
node client.js

Note:

  • Node will spin up to 100% CPU and eat a lot of memory when the bug is triggered.
  • This issue is very hard to reproduce when both the client and the server run on the same host.
  • It won't always trigger with a smaller content Buffer.

EC2

  • You need an AWS account and the AWS CLI tools for this.
  • Create instance and a group for it, compile Node, run server.js:
ec2-create-group node-issue-5504 -d 'Node issue 5504'
ec2-authorize node-issue-5504 -P tcp -p 22 -s 0.0.0.0/0
ec2-authorize node-issue-5504 -P tcp -p 3000 -s 0.0.0.0/0
ec2-run-instances ami-7ee2ed0a -g node-issue-5504 -k <key pair> -t m1.small -z <availability zone>
ec2-get-console-output <instance id> # Get the host key
ec2-describe-instances <instance id> # Get the public domain name
ssh ec2-user@<public domain name>
sudo iptables -F
sudo yum install --assumeyes gcc gcc-c++ git
git clone git://github.com/joyent/node.git
cd node
./configure
make
wget https://gist.github.com/pepve/5694305/raw/037d20cbf34367dc8fd36d90102e50cb03954e7a/server.js
./node server.js
  • In another terminal, also ssh to the instance, and run top
  • Modify client.js to connect to the instance and run it locally
  • After you're done, remove the instance and the group:
ec2-terminate-instances <instance id>
ec2-delete-group node-issue-5504
var net = require('net');
var client = net.connect({
host: '192.168.60.2',
port: 3000
}, function() {
client.destroy();
});
var net = require('net');
var content = new Buffer(10 * 1024 * 1024);
content.fill('#');
net.createServer(function(socket) {
socket.write(content);
}).listen(3000);
Vagrant::Config.run do |config|
config.vm.box = "centos-6.3-minimal"
config.vm.box_url = "https://dl.dropbox.com/u/7225008/Vagrant/CentOS-6.3-x86_64-minimal.box"
config.vm.network :hostonly, "192.168.60.2"
config.vm.provision :shell do |shell|
shell.inline = "yum --assumeyes install git; iptables -F"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment