-
Notifications
You must be signed in to change notification settings - Fork 30.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v8::internal::JSReceiver::DefineOwnProperty exception cause a crash #14335
Comments
Can you provide a reproducible test case? |
@TimothyGu void AsyncDBWrap::PushQuery(const v8::FunctionCallbackInfo<v8::Value>& args)
{
Isolate* isolate = args.GetIsolate();
AsyncDBWrap* db_wrap = ObjectWrap::Unwrap<AsyncDBWrap>(args.This());
if (!db_wrap || !db_wrap->m_db)
{
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "err parameters for NewRouter")));
args.GetReturnValue().Set(Number::New(isolate, -1));
return;
}
if (!args[0]->IsString())
{
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "push query parameters error")));
args.GetReturnValue().Set(Number::New(isolate, -2));
return;
}
std::string sql = std::string(*String::Utf8Value(args[0]->ToString()));
bool cb_able = true;
ResHandler cb = nullptr;
if (args.Length() >= 2)
{
uint32_t cbId = ++m_cbOriId;
Persistent<Function> *f = nullptr;
if (args[1]->IsFunction())
{
f = new Persistent<Function>(isolate, Local<Function>::Cast(args[1]));
}
else if (args[1]->IsBoolean() && args[2]->IsFunction())
{
cb_able = args[1]->BooleanValue();
f = new Persistent<Function>(isolate, Local<Function>::Cast(args[2]));
}
else
{
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "push query parameters error")));
args.GetReturnValue().Set(Number::New(isolate, -3));
return;
}
m_cbs.insert(std::make_pair(cbId, f));
cb = [cbId](const std::string& err, ResultSetPtr& resPtr, uint64_t count, uint64_t time) -> void
{
Isolate* isolate = Isolate::GetCurrent();
EscapableHandleScope handler_scope(isolate);
//Local<Object> context = Context::GetCurrent()->Global();
Local<Object> context = isolate->GetCurrentContext()->Global();
const int argc = 4;
Local<Array> arr = Array::New(isolate, resPtr->rowsCount());
bool ret = GetV8Res(resPtr, arr);
if (ret)
{
Handle<Value> argv[argc] = { String::NewFromUtf8(isolate, err.c_str()), handler_scope.Escape(arr), Number::New(isolate,count), Number::New(isolate, time) };
Local<Function>::New(isolate, *m_cbs[cbId])->Call(context, argc, argv);
}
else
{
Handle<Value> argv[argc] = { String::NewFromUtf8(isolate, "get result error!"), Null(isolate), Null(isolate), Null(isolate) };
Local<Function>::New(isolate, *m_cbs[cbId])->Call(context, argc, argv);
}
m_cbs[cbId]->Reset();
delete m_cbs[cbId];
m_cbs.erase(cbId);
};
}
args.GetReturnValue().Set(Number::New(isolate, db_wrap->m_db->PushQuery(sql, cb, cb_able)));
}
void AsyncDBWrap::Tick(const v8::FunctionCallbackInfo<v8::Value>& args)
{
Isolate *isolate = args.GetIsolate();
bool hasErr = false;
AsyncDBWrap* db_wrap = ObjectWrap::Unwrap<AsyncDBWrap>(args.This());
if (!db_wrap || !db_wrap->m_db)
{
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "Tick error")));
args.GetReturnValue().Set(Boolean::New(isolate, !hasErr));
return;
}
uint32_t ec = db_wrap->m_db->OnTickResult();
std::string ec_what;
if (ec == MySqlServerGoneAway)
{
ec_what = "MySql server has gone away, reconnect soon.";
hasErr = true;
}
else if (ec)
{
ec_what = "db error: " + std::to_string(ec);
hasErr = true;
}
if (hasErr)
{
if (args[0]->IsFunction())
{
const int argc = 1;
Handle<Value> argv[argc] = { String::NewFromUtf8(isolate, ec_what.c_str()) };
Handle<Function>::Cast(args[0])->Call(isolate->GetCurrentContext()->Global(), argc, argv);
}
else
{
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "Tick error")));
args.GetReturnValue().Set(Boolean::New(isolate, !hasErr));
return;
}
}
//db_wrap->m_dbTask.tick();
args.GetReturnValue().Set(Boolean::New(isolate, !hasErr));
return;
} |
Please move this over to /~https://github.com/nodejs/help/issues. This bug tracker is for reporting bugs in node.js, not general support. |
bnoordhuis
added
invalid
Issues and PRs that are invalid.
question
Issues that look for answers.
labels
Jul 18, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
my issue details :
The crash reason: old_len_desc.value() is null.
The macro ASSIGN_RETURN_ON_EXCEPTION condition is true in the Object :: GetPropertyWithAccessor
, returns an empty object, why?
The text was updated successfully, but these errors were encountered: