在V8中,为什么Isolate::GetCurrent()返回NULL ?
In V8 why does Isolate::GetCurrent() return NULL?
我在Ubuntu上编译了V8,并且有一个非常简单的V8程序isolate_test.cc。它基于来自Google的Hello World示例:
#include <v8.h>
using namespace v8;
int main(int argc, char* argv[]) {
V8::initialize();
Isolate* isolate = Isolate::GetCurrent(); //Always returns NULL
return 0;
}
我用来编译这个程序的命令是:
g++ -Iinclude -g isolate_test.cc -o isolate_test -Wl,--start-group out/x64.debug/obj.target/{tools/gyp/libv8_{base,snapshot},third_party/icu/libicu{uc,i18n,data}}.a -Wl,--end-group -lrt -lpthread
问题是Isolate::GetCurrent()
总是返回NULL
。为什么会发生这种情况,获得当前Isolate
的正确方法是什么?
我可能会偏离轨道,但我的第一个想法是这与Isolate::GetCurrent()
无法从libpthread
获得当前线程有关。
Update:根据这个问题,我添加了V8::initialize()
作为程序中的第一个调用,但是这并不能解决问题。
我有同样的问题。我真的不知道潜在的原因,但这里的NULL意味着没有创建和输入默认隔离。显而易见的解决方法是手动执行
Isolate* isolate = Isolate::GetCurrent(); // returns NULL
if (!isolate) {
isolate = Isolate::New();
isolate->Enter();
}
默认隔离已从v8中删除。因此,GetCurrent()
不再默认初始化。
以下是更改的问题:https://code.google.com/p/chromium/issues/detail?id=359977
相关文章:
- 如何在映射中返回null
- 为什么返回 NULL 不会破坏函数?
- fopen 在 gdb 中返回 NULL
- 为什么要从main()返回NULL?
- 为什么TinyXML2的XMLDocument::FirstChild()函数在尝试解析这个有效的XML文件时返回NULL?
- Box2D World.GetBodyList() 返回 NULL,但 World 显然正在更新对象
- boost::p ython:PyErr_Fetch始终返回 NULL 回溯
- 如何在 Visual C++ 中从返回类型为 map 的函数返回 null?
- 如何在C++中返回Null作为引用
- 从模板化函数返回Null对象
- GDALOpen 在 GEOTiff 文件上返回 null
- PyThreadState_GET() 从 PyImport_GetModuleDict() 中返回 NULL
- (位图)LoadImage() 返回 NULL,GetLastError() 返回 0
- 在构造函数处将类对象强制转换为接口始终返回 NULL
- 如何为迭代器返回"null"值?
- 具有 4 个指针的节点的递归插入函数返回 null
- winAPI FindResource 仅在 DLL 中返回 NULL
- 使用 dlopen/dlsym 打开C++共享库 - dlsym 返回 NULL
- SetWindowsHookEx 在挂接到其他线程时返回 NULL
- 尚未归shared_ptr所有的实例的 shared_from_this() 总是返回 null?