Nodejs crashes when undefined is used as key

Hey guys,

I know this probably isn’t the best place to report this, but I couldn’t find any obvious links to a public bug tracking system on the website, so here it is.

Not sure if this a known issue, but I was playing around with the node client and I node.js kept coring on me.

I tracked the issue down to an undefined value being passed into aerospike.key. On the other hand, if I pass in null as a value, it kindly gives me a useful error message about an invalid parameter. It would be nice if the same thing happened for a key of undefined.

Here’s a short sample that should repro the crash:

var aerospike = require(‘aerospike’); var status = aerospike.status;

// Connect to the cluster. var client = aerospike.client({ hosts: [ { addr: ‘localhost’, port: 3000 } ] });

function connect_cb( err, client) { if (err.code == status.AEROSPIKE_OK) { console.log(“Aerospike Connection Success”) } }

client.connect(connect_cb)

// The key of the record we are reading. var key = aerospike.key(‘test’, ‘test’, undefined);

client.put( key, { baz: ‘bar’ }, function(err, rec, meta) { // Check for errors if ( err.code == status.AEROSPIKE_OK ) { // The record was successfully read. console.log(rec, meta); } else { // An error occurred console.error(‘error:’, err); } });

When I run it under gdb, it says that node gets a SIGSEGV, and here’s the stack:

0 as_key_set_digest (err=0x17487f0, key=0x1748c28) at src/main/aerospike/as_key.c:246

1 0x00007ffff696835a in aerospike_key_put (as=0x1647cf0, err=0x17487f0, policy=0x1748c10, key=0x1748c28, rec=0x1748cd0) at src/main/aerospike/aerospike_key.c:235

2 0x0000000000e0f0d9 in worker (arg=) at …/deps/uv/src/threadpool.c:91

3 0x0000000000e1c991 in uv__thread_start (arg=) at …/deps/uv/src/unix/thread.c:49

4 0x00007ffff6f98182 in start_thread (arg=0x7ffff592b700) at pthread_create.c:312

5 0x00007ffff6cc547d in clone () at …/sysdeps/unix/sysv/linux/x86_64/clone.S:111

Looks like the code snippet from the previous post didn’t quite make it.

var aerospike = require('aerospike');
var status = aerospike.status;


// Connect to the cluster.
var client = aerospike.client({
    hosts: [ { addr: 'localhost', port: 3000 } ]
});

function connect_cb( err, client) {
    if (err.code == status.AEROSPIKE_OK) {
        console.log("Aerospike Connection Success")
    }
}

client.connect(connect_cb)

// The key of the record we are reading.
var key = aerospike.key('test', 'test', undefined);



client.put(
    key,
    { baz: 'bar' },
    function(err, rec, meta) {
        // Check for errors
        if ( err.code == status.AEROSPIKE_OK ) {
            // The record was successfully read.
            console.log(rec, meta);
        }
        else {
            // An error occurred
            console.error('error:', err);
        }
    });

Hi Travis,

You’ve come to the right place! Users use these forums to report bugs they find, request new features, peruse our Knowledge Base, read announcements about our latest server and client releases, and connect with each other & exchange ideas.

Thanks for reporting this issue. We are looking into it and will follow up with you soon.

Best regards,

Maud

Hi Travis,

Thanks for reporting this issue. We have identified the issue and fixed it. It will be released as part of our next release, which is planned within this week. Thanks again for reporting this.

Thanks

Gayathri.K