SetInternalField internal field out of bounds

1,057 views
Skip to first unread message

Sébastien

unread,
Sep 27, 2008, 9:36:12 AM9/27/08
to v8-users
Hi,

I've modified the samples/shell.cc example script, inserting the
following indented code in the main function (after line 63):

// Enter the newly created execution environment.
v8::Context::Scope context_scope(context);

v8::Handle<v8::ObjectTemplate> point_templ =
v8::ObjectTemplate::New();
point_templ->SetInternalFieldCount(1);
v8::Local<v8::Object> obj = point_templ->NewInstance();
obj->SetInternalField(0, v8::External::New(NULL));

bool run_shell = (argc == 1);

This code is the same as the one from the embedding guide illustrating
the use of SetInternalField. When running the example, I got the
following error:

---
#
# Fatal error in v8::Object::SetInternalField()
# Writing internal field out of bounds
#

Abort
---

Any idea why this happens ?

-- Sébastien

Bryan White

unread,
Sep 28, 2008, 7:15:41 AM9/28/08
to v8-u...@googlegroups.com
> Any idea why this happens ?

This may be the same problem I had in this thread:
Object Internal Field Count is Lost

This ended up as issue 54
http://code.google.com/p/v8/issues/detail?id=54
Which is marked as fixed in 'bleeding edge'. My recollection is the
fix appeared in the release version a few days later.

Makes me think you just need to update to a the newest release to fix
the problem. If you are already running a new version then I don't
know what the problem may be.
--
Bryan White

Sébastien

unread,
Sep 28, 2008, 12:17:46 PM9/28/08
to v8-users
Oddly enough, getting the ObjectTemplate from a FunctionTemplate
instead of instanciating directly fixed the problem wit the stable
release (have not tried the bleeding edge yet).

v8::Handle<FunctionTemplate> fun_template =
v8::FunctionTemplate::New();
v8::Handle<ObjectTemplate> point_templ = fun_template-
>InstanceTemplate();

instead of

v8::Handle<v8::ObjectTemplate> point_templ =
v8::ObjectTemplate::New();

Thanks !

-- Sébastien
Reply all
Reply to author
Forward
0 new messages