Access Violation when creating a new function

341 views
Skip to first unread message

Robert Chatman

unread,
May 19, 2014, 3:55:00 AM5/19/14
to v8-u...@googlegroups.com
I am in the process of finishing up implementing a plugin for UE4 that leverages V8 for scripting. As such, I've been moving slowly towards making the API simple enough that people don't have to get into the guts of V8 too deeply. I have to say that the implementation I'm working with (I am currently running 3.26.0) has been quite frustrating =\ 

My current issue revolves around exposing a static method. I have simplified the sample down to something that illustrates the issue and hides the rest of the implementation. 

Example with failure on line 26:

Usage of Expose:

Signatures & Definition of methods: 

Whenever line 26 is executed an Access Violation is triggered: 
Unhandled exception at 0x00007FFA753CB17F (UE4Editor-FH_Flying-Win64-DebugGame.dll) in UE4Editor.exe: 0xC0000005: Access violation reading location 0x0000000000000020.

If I comment out the line with the function delegate assignment the code runs fine.In the following example, loaded in viat BobTest.js, I am able to confirm that Bob is created, that it has creationTime and setActorPosition defined, and that the callback/accessors are executed, and that value and value2 (set to be the address of the method that failed earlier) are defined and correct. 

game.log(Bob);
game.log(Bob.creationTime);
game.log(Bob.setActorPosition(10, 10, 10));
game.log(Bob.value);
game.log(Bob.value2);

[2014.05.19-07.24.29:404][ 14]FH: [object Object]
[2014.05.19-07.24.29:405][ 14]FH: 0
[2014.05.19-07.24.29:406][ 14]FH: true
[2014.05.19-07.24.29:406][ 14]FH: 42
[2014.05.19-07.24.29:407][ 14]FH: 140713690731404

I've spent a few days trying to sort this one out, and I am needing some assistance in sorting this one out. I hope to get this sorted out ASAP so I can get the plugin out. 

I thank you all for any assistance you provide. Please let me know if there is anything else you need to help me out. 

.:Bob

Ben Noordhuis

unread,
May 19, 2014, 5:51:07 AM5/19/14
to v8-u...@googlegroups.com
It's not immediately clear to me what's wrong but I suspect that
FunctionTemplate::New() returns an empty handle for some reason, i.e.
that ft.IsEmpty() == true.

I'd recommend trying it with a debug build of V8, it has many more
checks enabled. I don't know how you build V8 but you probably want
to set v8_enable_extra_checks=1 as well (extrachecks=on if you use the
Makefile.)

Bob Chatman

unread,
May 19, 2014, 10:05:28 PM5/19/14
to v8-u...@googlegroups.com
When loading it up with the debug libs the following lands in my logs. 
#
# Fatal error in g:\unreal\fh_flying\plugins\flathead\v8\src\isolate.h, line 871
# CHECK(logger_ != 0) failed
#
First-chance exception at 0x0000000000000000 in UE4Editor.exe: 0xC0000005: Access violation executing location 0x0000000000000000.
Unhandled exception at 0x0000000000000000 in UE4Editor.exe: 0xC0000005: Access violation executing location 0x0000000000000000

ft.IsEmpty() is false.

Tested as follows: 

Local<FunctionTemplate> ft = FunctionTemplate::New(ref.GetIsolate(), AFH_FlyingPawn::JS_CurrentRollSpeed);

if (!ft.IsEmpty())
{
Local<Function> function = ft->GetFunction();
}


Bob Chatman - www.gneu.org



--
--
v8-users mailing list
v8-u...@googlegroups.com
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to a topic in the Google Groups "v8-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/v8-users/cYkuljdJEJ8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to v8-users+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ben Noordhuis

unread,
May 20, 2014, 6:27:17 AM5/20/14
to v8-u...@googlegroups.com
On Tue, May 20, 2014 at 4:05 AM, Bob Chatman <bob.c...@gmail.com> wrote:
> When loading it up with the debug libs the following lands in my logs.
> #
> # Fatal error in g:\unreal\fh_flying\plugins\flathead\v8\src\isolate.h, line
> 871
> # CHECK(logger_ != 0) failed
> #
> First-chance exception at 0x0000000000000000 in UE4Editor.exe: 0xC0000005:
> Access violation executing location 0x0000000000000000.
> Unhandled exception at 0x0000000000000000 in UE4Editor.exe: 0xC0000005:
> Access violation executing location 0x0000000000000000
>
> ft.IsEmpty() is false.
>
> Tested as follows:
>
> Local<FunctionTemplate> ft = FunctionTemplate::New(ref.GetIsolate(),
> AFH_FlyingPawn::JS_CurrentRollSpeed);
>
> if (!ft.IsEmpty())
> {
> Local<Function> function = ft->GetFunction();
> }

It sounds like one of two things is happening here. Either V8 or the
isolate wasn't fully initialized or you're calling into V8 from
multiple threads without using Locker and Unlocker objects.

Robert Chatman

unread,
May 20, 2014, 12:51:26 PM5/20/14
to v8-u...@googlegroups.com
It sounds like one of two things is happening here.  Either V8 or the
isolate wasn't fully initialized or you're calling into V8 from
multiple threads without using Locker and Unlocker objects.

What is expected to be done to initialize V8 or the isolate that is not done in the samples?
Gameplay is executed on the same (Game) thread, so I don't think that is the issue. 
Message has been deleted

Robert Chatman

unread,
May 20, 2014, 11:38:38 PM5/20/14
to v8-u...@googlegroups.com
Two Further Additions to the above issue:

1. I am able to replace the function assignment with Function::New with the same error. 
2. I am able to replace the function assignment with 500 parameters each with its own integer value with no errors. 
(I assume any number but at this point I have put a for loop that creates 500) 

Robert Chatman

unread,
May 26, 2014, 2:57:18 PM5/26/14
to v8-u...@googlegroups.com
One more additional piece of information. 

SetAccessor is working as expected. So as of now, the issue is only presenting itself when trying to bind a function. Are there any further thoughts?
Reply all
Reply to author
Forward
0 new messages