On Mon, Apr 21, 2014 at 2:45 AM, David Wardell <[email protected]> wrote: > Hi all. > > I tried to research the topic first, so if it has already been posted please > forgive me. > > Running Linux on x64 and I can use V8 (which I built from source) just fine. > However, when I run the hello_world code provided here against valgrid I > find memory leaks: > >> >> ==4240== Memcheck, a memory error detector >> ==4240== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al. >> ==4240== Using Valgrind-3.10.0.SVN and LibVEX; rerun with -h for copyright >> info >> ==4240== Command: ./hello_world >> ==4240== >> ==4240== Warning: set address range perms: large range [0x20ad2ae19000, >> 0x20ad4ae19000) (noaccess) >> Hello, World! >> ==4240== >> ==4240== HEAP SUMMARY: >> ==4240== in use at exit: 331,256 bytes in 162 blocks >> ==4240== total heap usage: 272 allocs, 110 frees, 1,034,898 bytes >> allocated >> ==4240== >> ==4240== 104 bytes in 1 blocks are possibly lost in loss record 88 of 142 >> ==4240== at 0x4C2B800: operator new[](unsigned long) (in >> /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) >> ==4240== by 0x465090: >> v8::internal::Debugger::Debugger(v8::internal::Isolate*) (in >> /home/david/opt/v8/hello_world) >> ==4240== by 0x575514: >> v8::internal::Isolate::Init(v8::internal::Deserializer*) (in >> /home/david/opt/v8/hello_world) >> ==4240== by 0x6B48D0: v8::internal::Snapshot::Initialize(char const*) >> (in /home/david/opt/v8/hello_world) >> ==4240== by 0x406CEE: >> v8::EnsureInitializedForIsolate(v8::internal::Isolate*, char const*) (in >> /home/david/opt/v8/hello_world) >> ==4240== by 0x4182E3: v8::Context::New(v8::Isolate*, >> v8::ExtensionConfiguration*, v8::Handle<v8::ObjectTemplate>, >> v8::Handle<v8::Value>) (in /home/david/opt/v8/hello_world) >> ==4240== by 0x40501A: main (in /home/david/opt/v8/hello_world) >> ==4240== >> ==4240== 104 bytes in 1 blocks are possibly lost in loss record 89 of 142 >> ==4240== at 0x4C2B800: operator new[](unsigned long) (in >> /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) >> ==4240== by 0x465157: >> v8::internal::Debugger::Debugger(v8::internal::Isolate*) (in >> /home/david/opt/v8/hello_world) >> ==4240== by 0x575514: >> v8::internal::Isolate::Init(v8::internal::Deserializer*) (in >> /home/david/opt/v8/hello_world) >> ==4240== by 0x6B48D0: v8::internal::Snapshot::Initialize(char const*) >> (in /home/david/opt/v8/hello_world) >> ==4240== by 0x406CEE: >> v8::EnsureInitializedForIsolate(v8::internal::Isolate*, char const*) (in >> /home/david/opt/v8/hello_world) >> ==4240== by 0x4182E3: v8::Context::New(v8::Isolate*, >> v8::ExtensionConfiguration*, v8::Handle<v8::ObjectTemplate>, >> v8::Handle<v8::Value>) (in /home/david/opt/v8/hello_world) >> ==4240== by 0x40501A: main (in /home/david/opt/v8/hello_world) >> ==4240== >> ==4240== 288 bytes in 1 blocks are possibly lost in loss record 106 of 142 >> ==4240== at 0x4C2CC70: calloc (in >> /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) >> ==4240== by 0x4012E54: _dl_allocate_tls (dl-tls.c:296) >> ==4240== by 0x5047DA0: pthread_create@@GLIBC_2.2.5 >> (allocatestack.c:589) >> ==4240== by 0x7768A4: v8::internal::Thread::Start() (in >> /home/david/opt/v8/hello_world) >> ==4240== by 0x5756C9: >> v8::internal::Isolate::Init(v8::internal::Deserializer*) (in >> /home/david/opt/v8/hello_world) >> ==4240== by 0x6B48D0: v8::internal::Snapshot::Initialize(char const*) >> (in /home/david/opt/v8/hello_world) >> ==4240== by 0x406CEE: >> v8::EnsureInitializedForIsolate(v8::internal::Isolate*, char const*) (in >> /home/david/opt/v8/hello_world) >> ==4240== by 0x4182E3: v8::Context::New(v8::Isolate*, >> v8::ExtensionConfiguration*, v8::Handle<v8::ObjectTemplate>, >> v8::Handle<v8::Value>) (in /home/david/opt/v8/hello_world) >> ==4240== by 0x40501A: main (in /home/david/opt/v8/hello_world) >> ==4240== >> ==4240== 576 bytes in 2 blocks are possibly lost in loss record 121 of 142 >> ==4240== at 0x4C2CC70: calloc (in >> /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) >> ==4240== by 0x4012E54: _dl_allocate_tls (dl-tls.c:296) >> ==4240== by 0x5047DA0: pthread_create@@GLIBC_2.2.5 >> (allocatestack.c:589) >> ==4240== by 0x7768A4: v8::internal::Thread::Start() (in >> /home/david/opt/v8/hello_world) >> ==4240== by 0x57526A: >> v8::internal::Isolate::Init(v8::internal::Deserializer*) (in >> /home/david/opt/v8/hello_world) >> ==4240== by 0x6B48D0: v8::internal::Snapshot::Initialize(char const*) >> (in /home/david/opt/v8/hello_world) >> ==4240== by 0x406CEE: >> v8::EnsureInitializedForIsolate(v8::internal::Isolate*, char const*) (in >> /home/david/opt/v8/hello_world) >> ==4240== by 0x4182E3: v8::Context::New(v8::Isolate*, >> v8::ExtensionConfiguration*, v8::Handle<v8::ObjectTemplate>, >> v8::Handle<v8::Value>) (in /home/david/opt/v8/hello_world) >> ==4240== by 0x40501A: main (in /home/david/opt/v8/hello_world) >> ==4240== >> ==4240== LEAK SUMMARY: >> ==4240== definitely lost: 0 bytes in 0 blocks >> ==4240== indirectly lost: 0 bytes in 0 blocks >> ==4240== possibly lost: 1,072 bytes in 5 blocks >> ==4240== still reachable: 330,184 bytes in 157 blocks >> ==4240== suppressed: 0 bytes in 0 blocks >> ==4240== Reachable blocks (those to which a pointer was found) are not >> shown. >> ==4240== To see them, rerun with: --leak-check=full --show-leak-kinds=all >> ==4240== >> ==4240== For counts of detected and suppressed errors, rerun with: -v >> ==4240== ERROR SUMMARY: 4 errors from 4 contexts (suppressed: 0 from 0) >> > > I researched and found this post which describes the issue (with win32) and > how he mostly solved it with V8::Dispose(). > > However, whenever I run the hello_world program with Dispose() (as the last > function called in the program) it causes a segmentation fault. It seems to > be seg-faulting after the call to Dispose() returns (I assume some > destructor is attempting to access memory cleaned up by Dispose()). > > What am I doing wrong? > > Thanks for any help.
If you're using something like Context::Scope, make sure that the object is properly scoped, i.e. that it is destructed before you call V8::Dispose(). If it's not that, try a debug build. It has a ton more checks, that will usually help flush out the bug. -- -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
