ziggi / FCNPC

FCNPC - Fully Controllable NPC
Apache License 2.0
138 stars 31 forks source link

Crash: Signal 11 (Segmentation fault), address is 73c0 from f7c9dc72 #198

Closed Yousha closed 5 months ago

Yousha commented 5 years ago

What's the problem?

=========================== FCNPC Exception Handler ============================
Signal 11 (Segmentation fault), address is 73c0 from f7c9dc72

Backtrace:
  #0 in plugins/FCNPC.so(_ZN17CExceptionHandler24ExceptionHandlerCallbackEiP9siginfo_tPv+0xdc) [0xf69c30cc]
  #1 in [0xf7f6ebd0]
  #2 in /lib/i386-linux-gnu/libc.so.6(+0x8dc72) [0xf7c9dc72]
  #3 in ./samp03svr() [0x80eb3fc]
  #4 in ./samp03svr() [0x80950e4]
  #5 in plugins/crashdetect.so(_ZN18CrashDetectHandler15ProcessCallbackEiPiS0_+0x4bb) [0xf7be0b9b]
  #6 in plugins/crashdetect.so(+0x1cfc2) [0xf7be4fc2]
  #7 in plugins/crashdetect.so(amx_Exec+0xdc7) [0xf7be9bc7]

Information:
  System: GNU/Linux
  SA-MP: 0.3.7 R2
  FCNPC: 1.8.2

Functions:
  FUNC_CPlayerPool__DeletePlayer: 0x80d0a90
  FUNC_CPlayer__Kill: 0x80cb220
  FUNC_CPlayer__EnterVehicle: 0x80cc1c0
  FUNC_CPlayer__ExitVehicle: 0x80cc340
  FUNC_CPlayer__SpawnForWorld: 0x80ccfc0
  FUNC_GetVehicleModelInfo: 0x80d5e00
  FUNC_CConsole__GetIntVariable: 0x80a0070
  FUNC_ClientJoin_RPC: 0x80b0030

Pointers:
  VAR_ServerAuthentication: 0x81ab8ec
  VAR_NetVersion: 0xfd9

Offsets:
  OFFSET_RemoteSystemManager: 0x334
  OFFSET_RemoteSystemSize: 0xc69
  OFFSET_RemoteSystem__ConnectMode: 0xc62
  OFFSET_RemoteSystem__Unknown: 0xc67
=========================== FCNPC Exception Handler ============================
Yousha commented 4 years ago

Also I used strace and valgrind on FCNPC 2.0.0 and here are output:

strace:

execve("./FCNPC.so", ["./FCNPC.so"], 0x7ffd1df6e090 /* 26 vars */) = 0
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=NULL} ---
+++ killed by SIGSEGV (core dumped) +++
Segmentation fault

valgrind:

==3131== Memcheck, a memory error detector
==3131== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==3131== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==3131== Command: ./FCNPC.so
==3131== 
==3131== Invalid read of size 4
==3131==    at 0x177A23: std::basic_streambuf<char, std::char_traits<char> >::sputc(char) [clone .part.15] (in /home/yousha/Downloads/FCNPC-2.0.0-rc.7/plugins/FCNPC.so)
==3131==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==3131== 
==3131== 
==3131== Process terminating with default action of signal 11 (SIGSEGV)
==3131==  Access not within mapped region at address 0x0
==3131==    at 0x177A23: std::basic_streambuf<char, std::char_traits<char> >::sputc(char) [clone .part.15] (in /home/yousha/Downloads/FCNPC-2.0.0-rc.7/plugins/FCNPC.so)
==3131==  If you believe this happened as a result of a stack
==3131==  overflow in your program's main thread (unlikely but
==3131==  possible), you can try to increase the size of the
==3131==  main thread stack using the --main-stacksize= flag.
==3131==  The main thread stack size used in this run was 8388608.
==3131== 
==3131== HEAP SUMMARY:
==3131==     in use at exit: 0 bytes in 0 blocks
==3131==   total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==3131== 
==3131== All heap blocks were freed -- no leaks are possible
==3131== 
==3131== For lists of detected and suppressed errors, rerun with: -s
==3131== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
Segmentation fault (core dumped)
ziggi commented 4 years ago

Can i see used Pawn code?

On Mon, 28 Oct 2019 at 18:20 Yousha Aleayoub notifications@github.com wrote:

Also I used strace and valgrind and here are output:

strace:

execve("./FCNPC.so", ["./FCNPC.so"], 0x7ffd1df6e090 / 26 vars /) = 0 --- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=NULL} --- +++ killed by SIGSEGV (core dumped) +++ Segmentation fault

valgrind:

==3131== Memcheck, a memory error detector ==3131== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==3131== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info ==3131== Command: ./FCNPC.so ==3131== ==3131== Invalid read of size 4 ==3131== at 0x177A23: std::basic_streambuf<char, std::char_traits >::sputc(char) [clone .part.15] (in /home/yousha/Downloads/FCNPC-2.0.0-rc.7/plugins/FCNPC.so) ==3131== Address 0x0 is not stack'd, malloc'd or (recently) free'd ==3131== ==3131== ==3131== Process terminating with default action of signal 11 (SIGSEGV) ==3131== Access not within mapped region at address 0x0 ==3131== at 0x177A23: std::basic_streambuf<char, std::char_traits >::sputc(char) [clone .part.15] (in /home/yousha/Downloads/FCNPC-2.0.0-rc.7/plugins/FCNPC.so) ==3131== If you believe this happened as a result of a stack ==3131== overflow in your program's main thread (unlikely but ==3131== possible), you can try to increase the size of the ==3131== main thread stack using the --main-stacksize= flag. ==3131== The main thread stack size used in this run was 8388608. ==3131== ==3131== HEAP SUMMARY: ==3131== in use at exit: 0 bytes in 0 blocks ==3131== total heap usage: 0 allocs, 0 frees, 0 bytes allocated ==3131== ==3131== All heap blocks were freed -- no leaks are possible ==3131== ==3131== For lists of detected and suppressed errors, rerun with: -s ==3131== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0) Segmentation fault (core dumped)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ziggi/FCNPC/issues/198?email_source=notifications&email_token=AAHZBQ5C7EUGJDRSEQYOCG3QQ37LZA5CNFSM4IO4P7NKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECNIJBY#issuecomment-546997383, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHZBQYY32Q7Y2BXDMGS5ALQQ37LZANCNFSM4IO4P7NA .

Yousha commented 4 years ago

Sure

Variable:

new NPC[][E_NPC] =
{
   /*
   npc_Id,
   npc_DbId,
   npc_Class,
   npc_SkinId,
   Float:npc_Position[3],
   Float:npc_Angle,
   Float:npc_Health,
   bool:npc_IsInvulnerable,
   npc_Label[MAX_PLAYER_NAME],
   Text3D:npc_NameTagId,
   npc_ColorId,
   npc_VW,
   npc_Interior,
   npc_FightingStyle,
   npc_WeaponSkillLevel,
   npc_WeaponId,
   npc_WeaponAmmo,
   npc_KillerId
   */
   {INVALID_PLAYER_ID, 0, CLASS_POLICE, SKIN_WMYBOUN, {-1781.6638, 570.7713, 36.1}, 123.0, MAX_NPC_HEALTH, false, "Security", COLOR_WHITE, VIRTUALWORLD_OUTSIDE, INTERIOR_OUTSIDE, FIGHT_STYLE_BOXING, MAX_SKILL_WEAPON, WEAPON_DEAGLE, MAX_AMMO, INVALID_PLAYER_ID}, // VIP
   {INVALID_PLAYER_ID, 1, CLASS_POLICE, SKIN_WMYSGRD, {-1497.2490, 917.0767, 7.1}, 0.0, MAX_NPC_HEALTH, false, "Security", COLOR_WHITE, VIRTUALWORLD_OUTSIDE, INTERIOR_OUTSIDE, FIGHT_STYLE_BOXING, 1, WEAPON_COLT45, MAX_AMMO, INVALID_PLAYER_ID}, // Bank
   {INVALID_PLAYER_ID, 2, CLASS_POLICE, SKIN_WMYSGRD, {-1543.0, -439.7, 6.0}, 46.7, MAX_NPC_HEALTH, false, "Security", COLOR_WHITE, VIRTUALWORLD_OUTSIDE, INTERIOR_OUTSIDE, FIGHT_STYLE_BOXING, 1, WEAPON_COLT45, MAX_AMMO, INVALID_PLAYER_ID}, // Airport
   {INVALID_PLAYER_ID, 3, CLASS_POLICE, SKIN_WMYSGRD, {-2652.2876, 639.9208, 14.4}, 173.0, MAX_NPC_HEALTH, false, "Security", COLOR_TEAM_PARAMEDIC, VIRTUALWORLD_OUTSIDE, INTERIOR_OUTSIDE, FIGHT_STYLE_BOXING, 1, WEAPON_COLT45, MAX_AMMO, INVALID_PLAYER_ID}, // Hospital
   {INVALID_PLAYER_ID, 4, CLASS_POLICE, SKIN_WMYSGRD, {-2764.9436, 377.2141, 7.3}, 270.0, MAX_NPC_HEALTH, false, "Security", COLOR_WHITE, VIRTUALWORLD_OUTSIDE, INTERIOR_OUTSIDE, FIGHT_STYLE_BOXING, 1, WEAPON_COLT45, MAX_AMMO, INVALID_PLAYER_ID}, // City Hall
   {INVALID_PLAYER_ID, 5, CLASS_MILITARY, SKIN_ARMY, {-1543.1809, 475.2165, 23.0}, 30.0, MAX_NPC_HEALTH, false, "Army", COLOR_TEAM_MILITARY, VIRTUALWORLD_OUTSIDE, INTERIOR_OUTSIDE, FIGHT_STYLE_BOXING, MAX_SKILL_WEAPON, WEAPON_M4, MAX_AMMO, INVALID_PLAYER_ID},
   {INVALID_PLAYER_ID, 6, CLASS_MILITARY, SKIN_ARMY, {-1230.0475, 471.6303, 23.0}, 312.0, MAX_NPC_HEALTH, false, "Army", COLOR_TEAM_MILITARY, VIRTUALWORLD_OUTSIDE, INTERIOR_OUTSIDE, FIGHT_STYLE_BOXING, MAX_SKILL_WEAPON, WEAPON_M4, MAX_AMMO, INVALID_PLAYER_ID},
   {INVALID_PLAYER_ID, 7, CLASS_POLICE, SKIN_LAPD1, {-1603.7993, 711.2350, 13.8}, 5.0, MAX_NPC_HEALTH, false, "Police", COLOR_TEAM_POLICE, VIRTUALWORLD_OUTSIDE, INTERIOR_OUTSIDE, FIGHT_STYLE_BOXING, 1, WEAPON_COLT45, MAX_AMMO, INVALID_PLAYER_ID}, // Police HQ
   {INVALID_PLAYER_ID, 8, CLASS_FBI, SKIN_FBI, {-2454.8401, 503.8360, 30.1}, 267.0, MAX_NPC_HEALTH, false, "Agent", COLOR_TEAM_FBI, VIRTUALWORLD_OUTSIDE, INTERIOR_OUTSIDE, FIGHT_STYLE_BOXING, MAX_SKILL_WEAPON, WEAPON_MP5, MAX_AMMO, INVALID_PLAYER_ID}, // FBI HQ
   {INVALID_PLAYER_ID, 9, CLASS_SS, SKIN_WUZIMU, {-1763.4692, 764.3244, 24.8}, 180.0, MAX_NPC_HEALTH, false, "Agent", COLOR_TEAM_SS, VIRTUALWORLD_OUTSIDE, INTERIOR_OUTSIDE, FIGHT_STYLE_BOXING, MAX_SKILL_WEAPON, WEAPON_SILENCED, MAX_AMMO, INVALID_PLAYER_ID} // SS HQ
};

Enum:

enum E_NPC
{
   npc_Id,
   npc_DbId,
   npc_Class,
   npc_SkinId,
   Float:npc_Position[3],
   Float:npc_Angle,
   Float:npc_Health,
   bool:npc_IsInvulnerable,
   npc_Label[MAX_PLAYER_NAME],
   npc_ColorId,
   npc_VW,
   npc_Interior,
   npc_FightingStyle,
   npc_WeaponSkillLevel,
   npc_WeaponId,
   npc_WeaponAmmo,
   npc_KillerId
}

Creation:

CreateAllNPCs()
{
   new npcName[MAX_PLAYER_NAME];

   for (new i = 0; i < sizeof NPC; i ++)
   {
      format(npcName, sizeof npcName, "npc%i_%s", i, NPC[i][npc_Label]);
      NPC[i][npc_Id] = FCNPC_Create(npcName);
      if (NPC[i][npc_Id] == INVALID_PLAYER_ID)
      {
         printf("[Error] Failed to create NPC %s.", npcName);
         continue;
      }
      FCNPC_Spawn(NPC[i][npc_Id], NPC[i][npc_SkinId], NPC[i][npc_Position][0], NPC[i][npc_Position][1], NPC[i][npc_Position][2]);
      FCNPC_SetAngle(NPC[i][npc_Id], NPC[i][npc_Angle]);
      FCNPC_SetHealth(NPC[i][npc_Id], NPC[i][npc_Health]);
      FCNPC_SetInvulnerable(NPC[i][npc_Id], NPC[i][npc_IsInvulnerable]);
      FCNPC_SetVirtualWorld(NPC[i][npc_Id], NPC[i][npc_VW]);
      FCNPC_SetInterior(NPC[i][npc_Id], NPC[i][npc_Interior]);
      FCNPC_SetFightingStyle(NPC[i][npc_Id], NPC[i][npc_FightingStyle]);
      SetNPCWeaponSkill(NPC[i][npc_Id], NPC[i][npc_WeaponSkillLevel]);
      FCNPC_SetWeapon(NPC[i][npc_Id], NPC[i][npc_WeaponId]);
      FCNPC_SetAmmo(NPC[i][npc_Id], NPC[i][npc_WeaponAmmo]);
      Attach3DTextLabelToPlayer(Create3DTextLabel(NPC[i][npc_Label], NPC[i][npc_ColorId], 0.0, 0.0, 0.0, DRAWDISTANCE_FARAWAY, NPC[i][npc_VW], LOS_DISABLE), NPC[i][npc_Id], 0.0, 0.0, 0.2);
   }
}