On Wed, May 26, 2010 at 8:28 PM, mgen <[email protected]> wrote: > Ty, I think I got it working now except a seg fault but can iron that > out now that I can retrieve the property. >
In my experience this can often be caused when using v8::External and when using the InternalFields concept without checking to ensure that the object has the proper number of fields before insertion/extraction. Summary: a) if you're using Internal Fields, make sure the object you're working on has the slots reserved. Allocating slots is done at the _prototype_ level, not the object level, and InternalFieldCount() (i think that's what it's called) can be used on the Object level to ensure that the object has the expected/required number of fields. b) if using Externals, make damned sure that each really contains a value and NEVER try to dereference them from JS space. Doing so will lead to Grief. It is API-legal to pass an External back to JS space, but any dereferencing of it (even checking to see if it is a "true" value) can segfault your app. Thus it's bad practice to allow Externals to escape from C++ into JS. Once i learned the API well enough to figure those things out, 95% of my crashes went away. (The other 5% have to be examined on a case by case basis.) Additional tip: build v8 in debug mode if you can, because the crash dumps are quite informative. If not building in debug mode then a segfault will typically be handled in the conventional manner (i.e. no informational output and no clue as to what happened). -- ----- stephan beal http://wanderinghorse.net/home/stephan/ -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
