Pourquoi Hello World for V8 provoque-t-il une erreur de segmentation sur Ubuntu?

J’ai compilé V8 sur Ubuntu 14.04 et j’essaie maintenant de faire fonctionner l’exemple hello_world.cc , mais quand je l’exécute, j’obtiens une Segmentation fault (core dumped) .

Voici ma source pour hello_world.cc:

 #include  using namespace v8; int main(int argc, char* argv[]) { // Get the default Isolate created at startup. Isolate* isolate = Isolate::GetCurrent(); // Create a stack-allocated handle scope. HandleScope handle_scope(isolate); return 0; } 

En suivant les instructions, voici la commande que j’ai utilisée pour construire hello_world.cc dans un exécutable:

 g++ -Iinclude -g hello_world.cc -o hello_world -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 

Notez qu’en plus des instructions, j’ai dû append l’ -lpthread flag pour la comstackr et -g pour inclure les symboles de débogage.

Voici le résultat du programme:

 $ ./hello_world Segmentation fault (core dumped) 

Et si je lance gdb hello_world core je reçois:

 [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Core was generated by `./hello_world'. Program terminated with signal SIGSEGV, Segmentation fault. #0 0x00000000004148bb in v8::HandleScope::Initialize (this=0x7fff9b86a110, isolate=0x0) at ../src/api.cc:572 572 prev_next_ = current->next; 

La ligne 572 de src / api.cc est ici

Ajouter un contrôle pour Isolate* isolate = Isolate::GetCurrent(); retourner NULL :

 Isolate* isolate = Isolate::GetCurrent(); if(!isolate) { isolate = v8::Isolate::New(); isolate->Enter(); }