Skip to content

Access Violation in IServerService.SendRconCommand during OnGameModeInit #599

Description

@DevD4v3

Calling IServerService.SendRconCommand("loadfs ...") from OnGameModeInit intermittently crashes the server with an Access Violation (0xC0000005).

Minimal reproduction:

[Event]
public void OnGameModeInit()
{
    Console.WriteLine("BEFORE");

    serverService.SendRconCommand("loadfs EntryMap");

    Console.WriteLine("AFTER");
}

The crash occurs before "AFTER" is printed.

Stack trace:

Fatal error.
0xC0000005
   at SampSharp.OpenMp.Core.Api.IConsoleComponent.<Send>g____PInvoke|3_0(IntPtr, SampSharp.OpenMp.Core.Std.StringView, SampSharp.OpenMp.Core.Api.ConsoleCommandSenderData ByRef)
   at SampSharp.OpenMp.Core.Api.IConsoleComponent.Send(System.String, SampSharp.OpenMp.Core.Api.ConsoleCommandSenderData ByRef)
   at SampSharp.Entities.SAMP.ServerService.SendRconCommand(System.String)
   at CTF.Host.GameModeInit.OnGameModeInit()
   at DynamicClass.lambda_method194(System.Runtime.CompilerServices.Closure, System.Object, System.Object[], System.IServiceProvider, SampSharp.Entities.IEntityManager)
   at SampSharp.Entities.EventDispatcher+<>c__DisplayClass16_0.<CreateTargetSite>b__0(System.Object, SampSharp.Entities.EventContext)
   at SampSharp.Entities.EventDispatcher.InnerInvoke(SampSharp.Entities.EventContext, Event, System.Object)
   at SampSharp.Entities.EventDispatcher+<>c__DisplayClass17_0.<CreateEventInvoke>b__0(SampSharp.Entities.EventContext)
   at CTF.Host.Middlewares.GlobalExceptionHandler.Invoke(SampSharp.Entities.EventContext)
   at SampSharp.Entities.EventDispatcher+<>c__DisplayClass17_0.<CreateEventInvoke>b__1(System.ReadOnlySpan`1<System.Object>)
   at SampSharp.Entities.EventDispatcher.Invoke(System.String, System.ReadOnlySpan`1<System.Object>)
   at SampSharp.Entities.EcsHost.OnGameModeInit()
   at SampSharp.Entities.EcsHost.Start(SampSharp.OpenMp.Core.IStartupContext)
   at SampSharp.Entities.HostContextBinder.OnContextInitialized(System.Object, System.EventArgs)
   at SampSharp.OpenMp.Core.StartupContext.InitializeUsing(SampSharp.OpenMp.Core.IStartup)
   at SampSharp.Entrypoint.Initialize(SampSharp.OpenMp.Core.SampSharpInitParams)

Notes:

  • The issue is intermittent.
  • Sometimes the command succeeds, sometimes it crashes.
  • The filterscript being loaded does not appear to matter.
  • Delaying the call (e.g. await Task.Delay(5000)) prevents the crash.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions