Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Problem with Buffer.copy() #3

avz opened this Issue · 1 comment

2 participants

Artem Zaytsev Ben Noordhuis
Artem Zaytsev
avz commented

Hi, I found problem with Buffer.copy() on buffer, returned by mmap().
Node version: v0.4.11, npm module version 0.0.3


var mmap = require('mmap')
var fs = require('fs')

var fd = fs.openSync('/tmp/test', 'w+')
var size = 1024
fs.truncateSync(fd, size)

var buffer =, mmap.PROT_READ | mmap.PROT_WRITE, mmap.MAP_SHARED, fd, 0)
var source = new Buffer(size)



# node mmap.js

        throw e; // process.nextTick error, or 'error' event on first tick
TypeError: First arg should be a Buffer
    at Buffer.copy (buffer.js:364:22)
    at Object.<anonymous> (/tmp/mmap.js:11:8)
    at Module._compile (module.js:402:26)
    at Object..js (module.js:408:10)
    at Module.load (module.js:334:31)
    at Function._load (module.js:293:12)
    at Array.<anonymous> (module.js:421:10)
    at EventEmitter._tickCallback (node.js:126:26)
Ben Noordhuis

I added a fix in 09146e9 that passes your test case. However, I added a test that maps /dev/zero and it makes 0.4.x and 0.5.x crash inside memmove with an out of bounds pointer. WIP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.