Access Violation errors when accessing V8 objects

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Access Violation errors when accessing V8 objects

Postby ayoung24 » Thu Oct 29, 2009 9:24 am

I'm seeing random program exceptions when accessing V8 values. I always access them from the UI thread. Are there restrictions on when these objects can be accessed? Is there any way to determine whether or not they are accessible beforehand? I know they are not being released prematurely.

From the looks of the stack trace I captured using a debug build of CEF, it looks like some sort of required JavaScript context is missing:

libcef.dll!v8::internal::Array::length() Line 1572 + 0x11 bytes C++
libcef.dll!v8::internal::FixedArray::get(int index=4) Line 1295 + 0xe bytes C++
libcef.dll!v8::internal::Context::global() Line 244 + 0xa bytes C++
libcef.dll!v8::internal::Top::global_context() Line 937 + 0xb bytes C++
libcef.dll!v8::Context::GetCurrent() Line 2772 + 0x9 bytes C++
libcef.dll!WebCore::V8Proxy::currentContext() Line 1205 + 0x9 bytes C++
libcef.dll!WebCore::V8Proxy::retrieve() Line 566 + 0x9 bytes C++
libcef.dll!WebCore::V8DOMWrapper::instantiateV8Object(WebCore::V8Proxy * proxy=0x00000000, WebCore::V8ClassIndex::V8WrapperType descriptorType=CSSRULELIST, WebCore::V8ClassIndex::V8WrapperType cptrType=CSSRULELIST, void * impl=0x09aab698) Line 827 + 0x5 bytes C++
libcef.dll!WebCore::V8DOMWrapper::instantiateV8Object(WebCore::V8ClassIndex::V8WrapperType descType=CSSRULELIST, WebCore::V8ClassIndex::V8WrapperType cptrType=CSSRULELIST, void * impl=0x09aab698) Line 314 + 0x17 bytes C++
libcef.dll!WebCore::V8DOMWrapper::convertToV8Object(WebCore::V8ClassIndex::V8WrapperType type=CSSRULELIST, void * impl=0x09aab698) Line 686 + 0x15 bytes C++
libcef.dll!WebCore::V8DOMWrapper::convertToV8Object<WebCore::CSSRuleList>(WebCore::V8ClassIndex::V8WrapperType type=CSSRULELIST, WTF::PassRefPtr<WebCore::CSSRuleList> imp={...}) Line 139 + 0x16 bytes C++
libcef.dll!WebCore::CSSStyleSheetInternal::cssRulesAttrGetter(v8::Local<v8::String> name={...}, const v8::AccessorInfo & info={...}) Line 55 + 0x15 bytes C++
libcef.dll!v8::internal::Object::GetPropertyWithCallback(v8::internal::Object * receiver=0x07077fd9, v8::internal::Object * structure=0x095841b5, v8::internal::String * name=0x0707b2f9, v8::internal::Object * holder=0x07077fd9) Line 172 + 0x26 bytes C++
libcef.dll!v8::internal::Object::GetProperty(v8::internal::Object * receiver=0x07077fd9, v8::internal::LookupResult * result=0x0024d394, v8::internal::String * name=0x0707b2f9, PropertyAttributes * attributes=0x0024d404) Line 556 + 0x1d bytes C++
libcef.dll!v8::internal::Object::GetPropertyWithReceiver(v8::internal::Object * receiver=0x07077fd9, v8::internal::String * name=0x0707b2f9, PropertyAttributes * attributes=0x0024d404) Line 135 + 0x18 bytes C++
libcef.dll!v8::internal::Object::GetProperty(v8::internal::String * key=0x0707b2f9, PropertyAttributes * attributes=0x0024d404) Line 671 C++
libcef.dll!v8::internal::Runtime::GetObjectProperty(v8::internal::Handle<v8::internal::Object> object={...}, v8::internal::Handle<v8::internal::Object> key={...}) Line 2601 + 0x1c bytes C++
libcef.dll!v8::internal::GetProperty(v8::internal::Handle<v8::internal::Object> obj={...}, v8::internal::Handle<v8::internal::Object> key={...}) Line 265 + 0x4a bytes C++
libcef.dll!v8::Object::Get(v8::Handle<v8::Value> key={...}) Line 1962 + 0x11 bytes C++
libcef.dll!CefV8ValueImpl::GetValue(const std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> > & key="cssRules") Line 518 + 0x40 bytes C++
libcef.dll!v8value_get_value_bykey(_cef_v8value_t * self=0x09af51e8, const wchar_t * key=0x0510ed08) Line 291 + 0x3d bytes C++

In the Top::global_context() method above, this line:

Code: Select all
GlobalObject* global = thread_local_.context_->global();


Is what eventually causes the exception because thread_local_.context_ is null.
ayoung24
Techie
 
Posts: 13
Joined: Sat Oct 17, 2009 6:26 pm

Re: Access Violation errors when accessing V8 objects

Postby ayoung24 » Thu Oct 29, 2009 1:11 pm

It seems that this bug only happens when using get_value_bykey, and only when the return value of a property is a CSS object (stylesheet, etc). It is not raised when returning HTML objects; it seems these are wrapped by another means.

In order to work around the problem, I added a function to Object which looks like this:

Code: Select all
Object.prototype.__getValue = function(p) { return this[p]; };


And then execute __getValue on the target object using execute_function, passing the name of the property to get. This works correctly, whereas attempting to access the same property using get_value_bykey would cause the exception.

Just to be clear, the get_value_bykey method works (even for CSS objects) 95% of the time. Also, if I pause in the debugger before calling get_value_bykey and wait about 2 minutes, it will work. Threading issue? I'm not sure, but it sure is strange that execute_function works...
ayoung24
Techie
 
Posts: 13
Joined: Sat Oct 17, 2009 6:26 pm


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 58 guests