Skip to content

NPC Vector3 input APIs crash or receive <0,0,0> due to native proxy marshalling mismatch #605

Description

@AgustinIbanez00

Npc.SetPosition(...) crashes the server with a segmentation fault (SIGSEGV / exit 139), and INpcService.AddPointToPath(...) silently stores <0, 0, 0> instead of the point passed in. Both stem from the same cause: the native proxies for these NPC APIs declare their Vector3 input argument as const Vector3& (a pointer at the ABI boundary), while the source-generated managed P/Invoke marshals Vector3 by value.

Affected APIs:

  • Npc.SetPosition — crashes the server.
  • INpcService.AddPointToPath — stores <0, 0, 0>; an NPC driven with MoveByPath glides to the world origin instead of following the path.
  • Npc.Shoot, Npc.AimAt, Npc.AimAtPlayer, INpcService.HasPathPointInRange — same Vector3-input mismatch.

Minimal reproduction:

// spawned NPC, valid path service
npc.SetPosition(new Vector3(1260f, -2342.25f, 16f), true); // (1) crashes the server (SIGSEGV)

var path = npcService.CreatePath();
npcService.AddPointToPath(path, new Vector3(1260.875f, -2335.375f, 16.066f), 1f);
npcService.GetPathPoint(path, 0, out var stored, out _);    // (2) stored == <0, 0, 0>

Observed behavior:

  • SetPosition → server exits with code 139 (SIGSEGV) before the next line runs.
  • AddPointToPathGetPathPoint reads back <0, 0, 0>; MoveByPath drives the NPC straight to the world origin.

Expected behavior:

  • SetPosition moves the NPC to the requested coordinates.
  • AddPointToPath stores the exact point; MoveByPath follows the path.

Notes:

  • Proxies already declared by-value (e.g. Npc.MoveTo) are unaffected and always worked.
  • Native-only defect: the managed assemblies are correct; the fix is in src/sampsharp-component/proxies/api.cpp.
  • Seen on Linux with 1.0.0-prerelease2.

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

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions