Your weak callback (handle_weak) is empty and does not follow the contract.
Put object.Dispose(); there. -- Vyacheslav Egorov On Mon, Dec 26, 2011 at 12:55 PM, D C <[email protected]> wrote: > Hi: > Thanks for you replay, I modify my source according to your words, > It seems not work. > here is my source snippet: > > void javascript_ctx_impl::call_obj_func (v8::persistent<object> > object, const char* method, int argc, handle<value> argv[]) > { > handlescope handle_scope; > > local<value> cb = object->get(string::new(method)); > > if (!cb->isfunction()) { > std::cerr << "method = " << method << std::endl; > return; > } > > local<function> do_action = local<function>::cast(cb); > > trycatch try_catch; > /*********** ASSERT HERE ******************/ > /*********** ASSERT HERE ******************/ > /*********** ASSERT HERE ******************/ > do_action->call(object, argc, argv); > /*********** ASSERT HERE ******************/ > /*********** ASSERT HERE ******************/ > /*********** ASSERT HERE ******************/ > if (try_catch.hascaught()) { > v8::local<v8::message> msg = try_catch.message (); > if (!msg->getscriptresourcename().isempty() && !msg- > >getscriptresourcename()->isundefined()) > { > v8::string::asciivalue name (msg- > >getscriptresourcename()); > std::cerr << *name << std::endl; > } > else { > std::cerr << "call_obj_func: runtime error." << std::endl; > } > } > } > > template <typename T> > class write_handle : public handle_impl_base > { > public: > write_handle (boost::asio::io_service& io, > v8::Persistent<Object> > local, > v8::Persistent<Object> h > ) > : handle_impl_base (io), handle_ (h), session_ (local) > { > } > public: > void operator () (const boost::system::error_code& ec, > std::size_t bytes_transferred) > { > HandleScope handle_scope; > if (!ec) { > Handle<Value> args[3] = { > js::instance ().safe_new_value (session_), > js::instance ().safe_new_value > ("TRUE"), > js::instance ().safe_new_value > (bytes_transferred) > }; > > js::instance ().call_obj_func (handle_, > "onHandle", 3, args); > } > else { > Handle<Value> args[3] = { > js::instance ().safe_new_value (session_), > js::instance ().safe_new_value > ("FALSE"), > js::instance ().safe_new_value > (bytes_transferred) > }; > js::instance ().call_obj_func (handle_, > "onHandle", 3, args); > } > handle_.Dispose (); session_.Dispose (); > } > static void handle_weak (Persistent<Value> object, void* > parameter) > { > } > private: > v8::Persistent<Object> handle_; > v8::Persistent<Object> session_; > }; > > v8::Handle<v8::Value> js_asio_socket_ip_tcp_function::async_write > (const v8::Arguments& args) > { > HandleScope hScope; > js_asio_socket_ip_tcp_function* native_obj = > unwrap<js_asio_socket_ip_tcp_function>(args.This()); > > if (args.Length () < 4) { > return ThrowException (Exception::TypeError(String::New( > "async_resolve need 4 parameters.")) > ); > } > /** Argument check here */ > js_stream_function* s = unwrap<js_stream_function> (args[1]- > >ToObject ()); > if (s == NULL) { > return ThrowException (Exception::TypeError(String::New( > "async_resolve parameter 2 error.")) > ); > } > > v8::Local<v8::Object> p0 = args[0]->ToObject (); > v8::Local<v8::Integer> p2 = args[2]->ToUint32 (); > > v8::Persistent<Object> handle; > v8::Persistent<Object> sessin; > > if (args[3]->ToObject ()->IsFunction ()) { > v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(args > [3]->ToObject()); > handle = v8::Persistent<v8::Object>::New(f); > } > else { > handle = v8::Persistent<Object>::New (args[3]->ToObject ()); > } > > handle.MakeWeak (NULL, write_handle<void>::handle_weak); > handle.MarkIndependent (); > > sessin = v8::Persistent<Object>::New (p0); > boost::asio::async_write (*(native_obj->socket_), > boost::asio::buffer (s->get (), p2->Value ()), > boost::asio::transfer_all (), > make_concrete_handle (write_handle <void> (native_obj- > >socket_->get_io_service (), sessin, handle) > ) > ); > return v8::Undefined (); > } > > if you have some suggestion, it will be very thankful. > > > On 12月26日, 午前8:15, Vyacheslav Egorov <[email protected]> wrote: > > Every weak callback should either revive (via ClearWeak or MakeWeak) or > > destroy (via Dispose) the handle for which it was called. This contract > is > > described in v8.h, see the comment above WeakReferenceCallback > definition. > > > > You have a callback that does not follow this contract. > > > > -- > > Vyacheslav Egorov > > On Dec 25, 2011 3:41 PM, "D C" <[email protected]> wrote: > > > > > > > > > > > > > > > > > Hi all: > > > I stuck here for about two weeks. > > > Here is my stack trace. > > > > ========================================================================= > > > Agent.exe!v8::internal::OS::DebugBreak() Line 930 C++ > > > Agent.exe!v8::internal::OS::Abort() Line 925 C++ > > > Agent.exe!V8_Fatal(const char * file=0x00d8fcd8, int line=237, > const > > > char * format=0x00d7bd18, ...) Line 59 C++ > > > Agent.exe!CheckHelper(const char * file=0x00d8fcd8, int > line=237, > > > const char * source=0x00d8fe34, bool condition=false) Line 60 + 0x16 > > > bytes C++ > > > > > > Agent.exe!v8::internal::GlobalHandles::Node::PostGarbageCollectionProcessin > g(v8::internal::Isolate > > > * isolate=0x014b0068, v8::internal::GlobalHandles * > > > global_handles=0x003ef478) Line 237 + 0x27 bytes C++ > > > Agent.exe! > > > > > > v8::internal::GlobalHandles::PostGarbageCollectionProcessing(v8::internal:: > GarbageCollector > > > collector=SCAVENGER) Line 540 + 0x12 bytes C++ > > > Agent.exe! > > > > v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector > > > collector=SCAVENGER, v8::internal::GCTracer * tracer=0x0012e0b4) Line > > > 822 + 0x15 bytes C++ > > > Agent.exe! > > > v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace > > > space=NEW_SPACE, v8::internal::GarbageCollector collector=SCAVENGER) > > > Line 518 + 0x16 bytes C++ > > > Agent.exe! > > > v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace > > > space=NEW_SPACE) Line 443 C++ > > > Agent.exe! > > > v8::internal::Factory::NewStringFromUtf8(v8::internal::Vector<char > > > const > string={...}, v8::internal::PretenureFlag > > > pretenure=NOT_TENURED) Line 186 + 0xea bytes C++ > > > Agent.exe!v8::String::New(const char * data=0x00d68254, int > > > length=8) Line 4410 C++ > > > > Agent.exe!javascript_ctx_impl::call_obj_func(v8::Handle<v8::Object> > > > object={...}, const char * method=0x00d68254, int argc=3, > > > v8::Handle<v8::Value> * argv=0x0012e4b0) Line 111 + 0x12 bytes C++ > > > Agent.exe!read_handle<void>::operator()(const > > > boost::system::error_code & ec={...}, unsigned int > > > bytes_transferred=661) Line 226 C++ > > > > ========================================================================= > > > It seem like each time GC, String::New ASSERT, who can help me about > > > that. > > > > > -- > > > v8-users mailing list > > > [email protected] > > >http://groups.google.com/group/v8-users > > -- > v8-users mailing list > [email protected] > http://groups.google.com/group/v8-users > -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
