Skip to content

[Critical] .Net4.x crashes #40

Description

@sekkit

Unity2018.4.5f1, MacOS works fine, but windows crashes.

issue reproduce: When calling MyGameAbstractBaseBallScriptUpdate

CSharp code:

                public override void Update()
		{
			if (CppHandle != 0)
			{
				int thisHandle = CppHandle;
				NativeScript.Bindings.MyGameAbstractBaseBallScriptUpdate(thisHandle);
				if (NativeScript.Bindings.UnhandledCppException != null)
				{
					Exception ex = NativeScript.Bindings.UnhandledCppException;
					NativeScript.Bindings.UnhandledCppException = null;
					throw ex;
				}
			}
		}

When executes to the line: auto returnValue = Plugin::UnityEngineTimePropertyGetDeltaTime();
It crashes.
C++ code:

System::Single UnityEngine::Time::GetDeltaTime()
	{
		auto returnValue = Plugin::UnityEngineTimePropertyGetDeltaTime();
		if (Plugin::unhandledCsharpException)
		{
			System::Exception* ex = Plugin::unhandledCsharpException;
			Plugin::unhandledCsharpException = nullptr;
			ex->ThrowReferenceToThis();
			delete ex;
		}
		return returnValue;
	}

Exception thrown at 0x00007FFDE974D5D9 (NativeScript_temp.dll) in Unity.exe: 0xC0000005: Access violation reading location 0x0000000000000000.

Stacktrace:

========== OUTPUTTING STACK TRACE ==================

0x00007FFE2AEBD5D9 (NativeScript_temp) [c:\projects\research\unitycpp\unity\libs\cppsource\nativescript\bindings.cpp:5498] UnityEngine::Time::GetDeltaTime 
0x00007FFE2AEA3B9A (NativeScript_temp) [c:\projects\research\unitycpp\unity\libs\cppsource\game\game.cpp:38] MyGame::BallScript::Update 
0x00007FFE2AEBFCA7 (NativeScript_temp) [c:\projects\research\unitycpp\unity\libs\cppsource\nativescript\bindings.cpp:5819] MyGameAbstractBaseBallScriptUpdate 
0x000000004E2DC2C5 (Mono JIT Code) (wrapper managed-to-native) object:wrapper_native_00007FFE2AEA12AD (int)
0x000000004E367898 (Mono JIT Code) [C:\Projects\Research\unitycpp\Unity\Assets\NativeScript\Bindings.cs:2121] MyGame.BaseBallScript:Update () 
0x000000004EE32FC8 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
0x00007FFDBABCB970 (mono-2.0-bdwgc) [c:\users\bokken\builds\vm\mono\mono\mini\mini-runtime.c:2809] mono_jit_runtime_invoke 
0x00007FFDBAB51922 (mono-2.0-bdwgc) [c:\users\bokken\builds\vm\mono\mono\metadata\object.c:2919] do_runtime_invoke 
0x00007FFDBAB5A91F (mono-2.0-bdwgc) [c:\users\bokken\builds\vm\mono\mono\metadata\object.c:2966] mono_runtime_invoke 
0x0000000140C03DAA (Unity) scripting_method_invoke
0x0000000140BF400A (Unity) ScriptingInvocation::Invoke
0x0000000140BBCB57 (Unity) MonoBehaviour::CallMethodIfAvailable
0x0000000140BBD271 (Unity) MonoBehaviour::CallUpdateMethod
0x00000001406EEBDC (Unity) BaseBehaviourManager::CommonUpdate<BehaviourManager>
0x00000001406F5266 (Unity) BehaviourManager::Update
0x0000000140960373 (Unity) `InitPlayerLoopCallbacks'::`2'::UpdateScriptRunBehaviourUpdateRegistrator::Forward
0x000000014095EFC7 (Unity) ExecutePlayerLoop
0x000000014095F093 (Unity) ExecutePlayerLoop
0x0000000140962351 (Unity) PlayerLoop
0x0000000141349FDF (Unity) PlayerLoopController::UpdateScene
0x0000000141339383 (Unity) PlayerLoopController::EnterPlayMode
0x0000000141345323 (Unity) PlayerLoopController::SetIsPlaying
0x0000000141348282 (Unity) Application::TickTimer
0x00000001414A4C53 (Unity) MainMessageLoop
0x00000001414A693D (Unity) WinMain
0x000000014249BABA (Unity) __scrt_common_main_seh
0x00007FFE3E237BD4 (KERNEL32) BaseThreadInitThunk
0x00007FFE3EBCCE71 (ntdll) RtlUserThreadStart


Game booted up
UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Log(Object)
NativeScript.Bindings:UnityEngineDebugMethodLogSystemObject(Int32) (at Assets\NativeScript\Bindings.cs:1372)
System.Object:wrapper_native_00007FFE2AEA18DE(IntPtr, Int32, InitMode)
NativeScript.Bindings:OpenPlugin(InitMode) (at Assets\NativeScript\Bindings.cs:836)
NativeScript.Bindings:Open(Int32) (at Assets\NativeScript\Bindings.cs:622)
NativeScript.BootScript:Awake() (at Assets\NativeScript\BootScript.cs:36)
 
(Filename: Assets/NativeScript/Bindings.cs Line: 1372)

Crash!!!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions