joyent/node — Issue #1920: Nodejs 0.5.10 and asynchronous addons
Author: pschumi
Created: 2011-10-21 21:09:32+00:00
State: open

I wrote simple databse plugin that use eio to make asynchronous db queries. Plugin works fine with 0.4.12 but core dumps with 0.5.10xxx. I didn't find anything useful from documents so is there something that has changed or is it just a old plain bug ?-) I assume that my code is fine as I have removed all unneccessary and it still core dumps...and yes it works fine with old version.

Here is code. Program never reaches EIO_Query (core dump just after returning this function).

static Handle Query(const Arguments& args) {
HandleScope scope;

MyConnection *connection = ObjectWrap::Unwrap(args.This());
cout << "Query" << endl;

if (args.Length() != 2) {
return ThrowException(
Exception::Error( String::New("Wrong number of arguments: [callback, query]")));
}
if (!args[0]->IsFunction() || !args[1]->IsString()) {
return ThrowException(
Exception::Error( String::New("Invalid query parameter types: [cb, string]")));
}

// Extract parameters
Local cb = Local::Cast(args[0]);
String::AsciiValue ascii(args[1]->ToString());
string *persistent = new string(*ascii);

query_t *holder = new query_t();
holder->instance = connection;
holder->sqlStmt = (char*)persistent->c_str();
holder->cb = Persistent::New(cb);

connection->Ref();

eio_custom(EIO_query, EIO_PRI_DEFAULT, EIO_afterQuery, holder);
ev_ref(EV_DEFAULT_UC);
cout << "PH1 " << endl;

return Undefined();
}