Status: New
Owner: ----
New issue 1503 by sgbeal: Function.Data() going missing on 32-bit build,
not on 64-bit
http://code.google.com/p/v8/issues/detail?id=1503
Hello, gurus,
Ubuntu 10.10, gcc 4.4.4 or 4.4.5 (gcc --version displays both numbers!),
x86/32.
v8 version: trunk r8424 (current as of about 20 minutes ago)
This morning i discovered that on 32-bit builds, data i am setting via
FunctionTemplate::New( func, DATA ) are disappearing - not available via
GetData() in the function itself. On my 64-bit box this does not happen.
i don't have a self-contained example, but what i do have is relatively
straightforward:
My Callback:
static v8::Handle<v8::Value> Include( v8::Arguments const & argv )
{
int const argc = argv.Length();
if( argc < 1 ) return v8::Undefined();
v8::Local<v8::Value> const jvself(argv.Data());
if( jvself.IsEmpty() || !jvself->IsExternal() )
{
return Toss((StringBuffer()<<
"Internal error: Include() callback is missing
its native V8Shell object. "
<< "So far i am seeing this on 32-bit but not
64-bit builds. Aarrgghh! "
<< "jvself.IsEmpty()=="<<jvself.IsEmpty()<< "
(if it's not Empty then "
<< "it's also not an External, which is a
problem)."
)
.toError());
}
V8Shell * self = static_cast<V8Shell *>(
v8::External::Unwrap(jvself) );
ArgCaster<char const *> ac;
return self->ExecuteFile( ac.ToNative(argv[0]) );
}
That gets initialized like this:
v8::Handle<v8::Function> CreateIncludeFunction()
{
return v8::FunctionTemplate::New(Include,
v8::External::Wrap(this))->GetFunction();
}
and the return value of that function is added to my global object (which,
in turn, is owned by the 'this' object referenced above).
On my 64-bit box this is working exactly as i'd expect. On my 32-bit system
(same OS/compiler, different bitness), the error block in Include() is
being triggered because handle->IsExternal() is returning false (but the
handle is not Empty). The complete code is here:
http://code.google.com/p/v8-juice/source/browse/convert/include/v8/convert/V8Shell.hpp
but i think that all of the relevant bits are shown above.
i don't think that gc is an issue here - the Include() call is made at the
very first line in the scripts i'm running, and those scripts are started
just a few function calls down from where Include() function bound to my
global object.
i'm not 100% fixed on the idea of using Function::GetData() to pass my
native object around for this purpose (and this is the only place i do it).
If there is a better way to do this then i would love to hear it.
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev