Skip to content

Segfault when setting up SDKCall with SDKType_Vector and SDKPass_ByValue on 1.10 #1059

@nosoop

Description

@nosoop

Help us help you

  • I have checked that my issue doesn't exist yet.
  • I have tried my absolute best to reduce the problem-space and have provided the absolute smallest test-case possible.
  • I can always reproduce the issue with the provided description below.

Environment

  • Operating System version: Ubuntu 16.04 Linux
  • Current SourceMod snapshot: 1.10.0.6434 (b8fd7db)

Description

SourceMod crashes on startup when setting up a parameter of type SDKType_Vector and SDKPass_ByValue pass method. This is a regression in 1.10.

Reported error is SIGSEGV /SEGV_MAPERR accessing 0x8 on this line, which suggests that the info->fields isn't being initialized.

Problematic Code (or Steps to Reproduce)

#pragma semicolon 1
#include <sourcemod>

#include <sdktools>

#pragma newdecls required

Handle g_SDKCallGetProjectileFireSetup;

public void OnPluginStart() {
  // using hardcoded vtable offset here for the sake of example,
  // shouldn't matter since it's not being called
  
  // CTFWeaponBase::GetProjectileFireSetup(CTFPlayer*, Vector, Vector*, QAngle*, bool, float)
  StartPrepSDKCall(SDKCall_Entity);
  PrepSDKCall_SetVirtual(400);
  PrepSDKCall_AddParameter(SDKType_CBasePlayer, SDKPass_Pointer);
  PrepSDKCall_AddParameter(SDKType_Vector, SDKPass_ByValue); // crashes here
  PrepSDKCall_AddParameter(SDKType_Vector, SDKPass_Pointer,
  		.encflags = VENCODE_FLAG_COPYBACK);
  PrepSDKCall_AddParameter(SDKType_QAngle, SDKPass_Pointer,
  		.encflags = VENCODE_FLAG_COPYBACK);
  PrepSDKCall_AddParameter(SDKType_Bool, SDKPass_Plain);
  PrepSDKCall_AddParameter(SDKType_Float, SDKPass_Plain);
  if ((g_SDKCallGetProjectileFireSetup = EndPrepSDKCall()) == INVALID_HANDLE) {
  	SetFailState("gamedata oopsie");
  }
}

Logs

Accelerator link.

Metadata

Metadata

Assignees

Labels

Buggeneral bugs; can be anything

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions