fuwaneko / node-protobuf

Google Protocol Buffers wrapper for Node.js [UNMAINTAINED]
180 stars 42 forks source link

SIGSEGV, Segmentation fault -- Attempt to read 0x0000000000000000 #17

Closed neumino closed 10 years ago

neumino commented 10 years ago

I get a segfault with this code.

var node_protobuf = require('node-protobuf');
var fs = require('fs');

var desc = fs.readFileSync(__dirname + '/ql2.desc');
var NodePB = new node_protobuf.Protobuf(desc);

var limit = 100000000000;

fs.readFile('query.txt', function(err, data) {
    if (err) throw err;
    var query = JSON.parse(data.toString());

    var buf;
    for(var i=0; i<limit; i++) {
        buf = NodePB.Serialize(query, "Query");
    }
    console.log(buf.toJSON());
});

A few things:

Not sure why...

All the files are in this archive -- http://justonepixel.com/rethinkdb/test.tar Running node test.js triggers the error. The only thing I can get with gdb is

(gdb) bt
#0  0x000012411360d699 in ?? ()
#1  0x0000108c03f06c91 in ?? ()
#2  0x00001570c9110071 in ?? ()
#3  0x000012411360d601 in ?? ()
#4  0x0000000600000000 in ?? ()
#5  0x0000000000000000 in ?? ()

Running with node in debug mode and symbols doens't provide a better backtrace. I did built node-protobuf in debug mode, but it doesn't replace the question marks.

Any idea how to debug that?

wentianle commented 10 years ago

please use https://github.com/wentianle/node-protobuf this version fix this bug

On Jan 9, 2014, at 11:51 AM, Michel notifications@github.com wrote:

I get a segfault with this code.

var node_protobuf = require('node-protobuf'); var fs = require('fs');

var desc = fs.readFileSync(__dirname + '/ql2.desc'); var NodePB = new node_protobuf.Protobuf(desc);

var limit = 100000000000;

fs.readFile('query.txt', function(err, data) { if (err) throw err; var query = JSON.parse(data.toString());

var buf;
for(var i=0; i<limit; i++) {
    buf = NodePB.Serialize(query, "Query");
}
console.log(buf.toJSON());

}); A few things:

if I replace the for loop with while(true) I can't seem to get a segfault if I remove the console.log I can't seem to get a segfault Not sure why...

All the files are in this archive -- http://justonepixel.com/rethinkdb/test.tar Running node test.js triggers the error. The only thing I can get with gdb is

(gdb) bt

0 0x000012411360d699 in ?? ()

1 0x0000108c03f06c91 in ?? ()

2 0x00001570c9110071 in ?? ()

3 0x000012411360d601 in ?? ()

4 0x0000000600000000 in ?? ()

5 0x0000000000000000 in ?? ()

Running with node in debug mode and symbols doens't provide a better backtrace. I did built node-protobuf in debug mode, but it doesn't replace the question marks.

Any idea how to debug that?

— Reply to this email directly or view it on GitHub.

fuwaneko commented 10 years ago

@neumino check 1.0.10 from npm, should work.

neumino commented 10 years ago

@wentianle @fuwaneko, awesome, I ran a quick test, and 1.0.10 seems to fix this bug.

Thanks!