citizenfx / fivem

The source code for the Cfx.re modification frameworks, such as FiveM, RedM and LibertyM, as well as FXServer.
https://cfx.re/
3.47k stars 2.06k forks source link

C# Export Server Crash 8978+ #2653

Open isingrel opened 1 month ago

isingrel commented 1 month ago

What happened?

Invoking an export from C# results in a server crash.

Exports["c_sharp"].csharp("from c#");

Expected result

export should be executed

Reproduction steps

Invoke an export from with in a C# server script dll Exports worked in 8965 Exports do not work in 8978, 8981

using System;
using System.Threading.Tasks;

using CitizenFX.Core;
using static CitizenFX.Core.Native.API;

namespace c_sharp
{
  public class C_Sharp : BaseScript
  {
    public static C_Sharp Self { get; private set; }

    public C_Sharp()
    {
      Self = this;
    }

    private void CSharp(string text)
    {
      Console.WriteLine($"c# {text}");
    }

    [EventHandler("onResourceStart")]
    private void OnResourceStart(string resourceName)
    {
      if (GetCurrentResourceName() == resourceName)
      {
        Exports.Add("csharp", (Action<string>)CSharp);
        Console.WriteLine("invoke c# export from c#");
        Exports["c_sharp"].csharp("from c#");
      }
    }
  }
}

Importancy

Crash

Area(s)

FXServer

Specific version(s)

Server 8978

Additional information

=================================================================
        Native Crash Reporting
=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================

=================================================================
        Managed Stacktrace:
=================================================================
          at <unknown> <0xffffffff>
          at CitizenFX.Core.GameInterface:InvokeFunctionReference <0x000bc>
          at CitizenFX.Core.RemoteFunctionReference:_InvokeNative <0x000ba>
          at CitizenFX.Core.RemoteFunctionReference:InvokeNative <0x0004a>
          at <>c__DisplayClass36_0:<CreateRemoteFunctionReference>b__0 <0x00092>
          at <Module>:runtime_invoke_object__this___object <0x0013f>
          at <unknown> <0xffffffff>
          at System.Reflection.RuntimeMethodInfo:InternalInvoke <0x000a2>
          at System.Reflection.RuntimeMethodInfo:Invoke <0x00162>
          at System.Reflection.MethodBase:Invoke <0x0006b>
          at System.Delegate:DynamicInvokeImpl <0x00402>
          at System.MulticastDelegate:DynamicInvokeImpl <0x0006a>
          at System.Delegate:DynamicInvoke <0x0004b>
          at CitizenFX.Core.ExportDictionary:Invoke <0x0014a>
          at CitizenFX.Core.InternalManager:TriggerEvent <0x0086a>
          at CitizenFX.Core.InternalManager:TriggerEvent <0x000d2>
          at CitizenFX.Core.InternalManager:TriggerEvent <0x002e2>
          at CitizenFX.Core.InternalManager:TriggerEvent <0x001a0>
          at CitizenFX.Core.InternalManager:TriggerEvent <0x00092>
          at CitizenFX.Core.MonoScriptRuntime:TriggerEvent <0x000a2>
          at CitizenFX.Core.IScriptEventRuntime:TriggerEvent <0x0008b>
          at CitizenFX.Core.IScriptEventRuntime:TriggerEvent <0x00132>
          at <unknown> <0xffffffff>
          at WrapScriptHost:InvokeNative <0x001f2>
          at WrapScriptHost:InvokeNative <0x00209>
          at CitizenFX.Core.ScriptContext:InvokeInternal <0x00084>
          at CitizenFX.Core.ScriptContext:InvokeInternal <0x000ea>
          at CitizenFX.Core.ScriptContext:Invoke <0x0004a>
          at CitizenFX.Core.Native.Function:InvokeInternal <0x000fa>
          at CitizenFX.Core.Native.Function:Call <0x00052>
          at CitizenFX.Core.BaseScript:TriggerEventInternal <0x00302>
          at CitizenFX.Core.BaseScript:TriggerEvent <0x00062>
          at CitizenFX.Core.ExportSet:TryInvokeMember <0x001f2>
          at System.Object:CallSite.Target <0x001f2>
          at System.Dynamic.UpdateDelegates:UpdateAndExecuteVoid2 <0x0081c>
          at com.twitchrp.log.C_Sharp:OnResourceStart <0x002da>
          at <Module>:runtime_invoke_void__this___object <0x00137>
          at <unknown> <0xffffffff>
          at System.Reflection.RuntimeMethodInfo:InternalInvoke <0x000a2>
          at System.Reflection.RuntimeMethodInfo:Invoke <0x00162>
          at System.Reflection.MethodBase:Invoke <0x0006b>
          at System.Delegate:DynamicInvokeImpl <0x00402>
          at System.MulticastDelegate:DynamicInvokeImpl <0x0006a>
          at System.Delegate:DynamicInvoke <0x0004b>
          at <Invoke>d__5:MoveNext <0x0026a>
          at System.Runtime.CompilerServices.AsyncTaskMethodBuilder:Start <0x000ea>
          at CitizenFX.Core.EventHandlerEntry:Invoke <0x001a2>
          at <Invoke>d__5:MoveNext <0x0018a>
          at System.Runtime.CompilerServices.AsyncTaskMethodBuilder:Start <0x00102>
          at CitizenFX.Core.EventHandlerDictionary:Invoke <0x001da>
          at <>c__DisplayClass38_2:<TriggerEvent>b__0 <0x0017a>
          at System.Threading.Tasks.Task`1:InnerInvoke <0x0009d>
          at System.Threading.Tasks.Task:Execute <0x0004b>
          at System.Threading.Tasks.Task:ExecutionContextCallback <0x0007a>
          at System.Threading.ExecutionContext:RunInternal <0x0023e>
          at System.Threading.ExecutionContext:Run <0x0005a>
          at System.Threading.Tasks.Task:ExecuteWithThreadLocal <0x0014a>
          at System.Threading.Tasks.Task:ExecuteEntry <0x0010a>
          at System.Threading.Tasks.TaskScheduler:TryExecuteTask <0x00072>
          at CitizenFX.Core.CitizenTaskScheduler:InvokeTryExecuteTask <0x0004a>
          at CitizenFX.Core.CitizenTaskScheduler:Tick <0x0053a>
          at CitizenFX.Core.InternalManager:TriggerEvent <0x00892>
          at CitizenFX.Core.InternalManager:TriggerEvent <0x000d2>
          at CitizenFX.Core.InternalManager:TriggerEvent <0x002e2>
          at CitizenFX.Core.InternalManager:TriggerEvent <0x001a0>
          at CitizenFX.Core.InternalManager:TriggerEvent <0x00092>
          at CitizenFX.Core.MonoScriptRuntime:TriggerEvent <0x000a2>
          at CitizenFX.Core.IScriptEventRuntime:TriggerEvent <0x0008b>
          at CitizenFX.Core.IScriptEventRuntime:TriggerEvent <0x00132>
=================================================================

================================================================
FXServer crashed.
A dump can be found at 8978\crashes\8f70a2a7-29dd-482a-8f42-71ecaf4774ef.dmp.
In addition to this, a full dump file has been generated at 8978\crashes\8f70a2a7-29dd-482a-8f42-71ecaf4774ef-full.dmp.

Crash report ID: 7891bbe8-5bc4-4810-8df8-d3ab10e1ff29
=================================================================
BGHDDevelopment commented 1 month ago

I was able to reproduce this on 8978 and 8981 as well.

FabianTerhorst commented 1 month ago

The fix will most likely be deployed on monday.

Legacy-TacticalGamingInteractive commented 1 month ago

The fix will most likely be deployed on monday.

Awesome. It appears this is affecting FivePD as well

7bananas77 commented 3 weeks ago

Have this been fixed? it still happen to me?