Source-Python-Dev-Team / Source.Python

This plugin aims to use boost::python and create an easily accessible wrapper around the Source Engine API for scripter use.
http://forums.sourcepython.com
GNU General Public License v3.0
164 stars 32 forks source link

Server crash with Player.get_view_coordinates() and @EntityPreHook #233

Closed ThaPwned closed 5 years ago

ThaPwned commented 6 years ago

Info:

Date          : 2017-12-17 20:33:10.774142
OS            : Linux-4.9.13eorfix-x86_64-with-debian-8.9
Game          : csgo
SP version    : 622
Server plugins:
   00: Source.Python, (C) 2012-2016, Source.Python Team.
SP plugins:
   00: crash_test

Code to reproduce the crash:

from entities.hooks import EntityCondition
from entities.hooks import EntityPreHook
from memory import make_object
from players import UserCmd
from players.constants import PlayerButtons
from players.entity import Player

@EntityPreHook(EntityCondition.is_player, 'run_command')
def run_command(stack):
    player = make_object(Player, stack[0])

    if not player.dead and player.steamid != 'BOT':
        usercmd = make_object(UserCmd, stack[1])

        if usercmd.buttons & PlayerButtons.FORWARD and not player.buttons & PlayerButtons.FORWARD:
            player.get_view_coordinates()
Ayuto commented 6 years ago

Thanks! I'm able to reproduce the crash with CS:GO. Here is a crash dump:

----------------------------------------------
CRASH: Tue Dec 19 10:46:11 PST 2017
Start Line: ./srcds_linux -game csgo -console +game_type 0 +game_mode 0 +map de_dust2 -condebug -debug +developer 1 -timeout 999999
[New LWP 4003]
[New LWP 4005]
[New LWP 4011]
[New LWP 4022]
[New LWP 4021]
[New LWP 4023]
[New LWP 4015]
[New LWP 4017]
[New LWP 4012]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1".
Core was generated by `./srcds_linux -game csgo -console +game_type 0 +game_mode 0 +map de_dust2 -cond'.
Program terminated with signal SIGABRT, Aborted.
#0  0xb7787d4c in __kernel_vsyscall ()
#0  0xb7787d4c in __kernel_vsyscall ()
#1  0xb7587687 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#2  0xb758aab3 in __GI_abort () at abort.c:89
#3  0xb751ee8b in Plat_SetBenchmarkMode () from /home/ayuto/Desktop/Server/csgo/bin/libtier0.so
#4  0xb753524c in ?? () from /home/ayuto/Desktop/Server/csgo/bin/libtier0.so
#5  <signal handler called>
#6  0xac93c438 in AsmJit::AssemblerCore::_emitInstruction(unsigned int, AsmJit::Operand const*, AsmJit::Operand const*, AsmJit::Operand const*) () from /home/ayuto/Desktop/Server/csgo/csgo/addons/source-python/bin/core.so
#7  0xac93bd94 in AsmJit::AssemblerCore::_emitInstruction(unsigned int, AsmJit::Operand const*, AsmJit::Operand const*, AsmJit::Operand const*) () from /home/ayuto/Desktop/Server/csgo/csgo/addons/source-python/bin/core.so
#8  0xac939023 in copy_bytes () from /home/ayuto/Desktop/Server/csgo/csgo/addons/source-python/bin/core.so
#9  0xab925a1b in ?? ()
#10 0xb1f38bde in ?? () from /home/ayuto/Desktop/Server/csgo/csgo/bin/server.so
#11 0xb1f3982b in ?? () from /home/ayuto/Desktop/Server/csgo/csgo/bin/server.so
#12 0xb1ebc453 in ?? () from /home/ayuto/Desktop/Server/csgo/csgo/bin/server.so
#13 0xb5fe7d21 in ?? () from /home/ayuto/Desktop/Server/csgo/bin/engine.so
#14 0xb1e0a4d5 in ?? () from /home/ayuto/Desktop/Server/csgo/csgo/bin/server.so
#15 0xb1f05422 in ?? () from /home/ayuto/Desktop/Server/csgo/csgo/bin/server.so
#16 0xb1f7d29f in ?? () from /home/ayuto/Desktop/Server/csgo/csgo/bin/server.so
#17 0xb1f6045c in ?? () from /home/ayuto/Desktop/Server/csgo/csgo/bin/server.so
#18 0xb2306daf in ?? () from /home/ayuto/Desktop/Server/csgo/csgo/bin/server.so
#19 0xab925500 in ?? ()
#20 0xb1f35eb4 in ?? () from /home/ayuto/Desktop/Server/csgo/csgo/bin/server.so
#21 0xb1f36153 in ?? () from /home/ayuto/Desktop/Server/csgo/csgo/bin/server.so
#22 0xb1ebe866 in ?? () from /home/ayuto/Desktop/Server/csgo/csgo/bin/server.so
#23 0xb5eba8ae in ?? () from /home/ayuto/Desktop/Server/csgo/bin/engine.so
#24 0xb5ebb9c7 in ?? () from /home/ayuto/Desktop/Server/csgo/bin/engine.so
#25 0xb5f6ddbe in ?? () from /home/ayuto/Desktop/Server/csgo/bin/engine.so
#26 0xb5f6ea5c in ?? () from /home/ayuto/Desktop/Server/csgo/bin/engine.so
#27 0xb5f6f1c8 in ?? () from /home/ayuto/Desktop/Server/csgo/bin/engine.so
#28 0xb5f78414 in ?? () from /home/ayuto/Desktop/Server/csgo/bin/engine.so
#29 0xb5f786e6 in ?? () from /home/ayuto/Desktop/Server/csgo/bin/engine.so
#30 0xb5f787f9 in ?? () from /home/ayuto/Desktop/Server/csgo/bin/engine.so
#31 0xb5fdabba in ?? () from /home/ayuto/Desktop/Server/csgo/bin/engine.so
#32 0xb5fd7b06 in ?? () from /home/ayuto/Desktop/Server/csgo/bin/engine.so
#33 0xb6fc64ed in ?? () from /home/ayuto/Desktop/Server/csgo/bin/dedicated.so
#34 0xb6fc6578 in ?? () from /home/ayuto/Desktop/Server/csgo/bin/dedicated.so
#35 0xb5fd7bfd in ?? () from /home/ayuto/Desktop/Server/csgo/bin/engine.so
#36 0xb610c090 in ?? () from /home/ayuto/Desktop/Server/csgo/bin/engine.so
#37 0xb5fd8def in ?? () from /home/ayuto/Desktop/Server/csgo/bin/engine.so
#38 0xb6fc6654 in ?? () from /home/ayuto/Desktop/Server/csgo/bin/dedicated.so
#39 0xb7023890 in ?? () from /home/ayuto/Desktop/Server/csgo/bin/dedicated.so
#40 0xb7024abe in ?? () from /home/ayuto/Desktop/Server/csgo/bin/dedicated.so
#41 0xb7023890 in ?? () from /home/ayuto/Desktop/Server/csgo/bin/dedicated.so
#42 0xb6fbf8f3 in ?? () from /home/ayuto/Desktop/Server/csgo/bin/dedicated.so
#43 0x080486f9 in main ()
No symbol table info available.
eax            0x0  0
ecx            0xfa3    4003
edx            0x6  6
ebx            0xfa3    4003
esp            0xbfe93944   0xbfe93944
ebp            0xbfe93aa8   0xbfe93aa8
esi            0x1  1
edi            0xb7705000   -1217376256
eip            0xb7787d4c   0xb7787d4c <__kernel_vsyscall+16>
eflags         0x200206 [ PF IF ID ]
cs             0x73 115
ss             0x7b 123
ds             0x7b 123
es             0x7b 123
fs             0x0  0
gs             0x33 51
From        To          Syms Read   Shared Object Library
0xb772f600  0xb775d33b  Yes         /lib/i386-linux-gnu/libm.so.6
0xb7726ad0  0xb772796c  Yes         /lib/i386-linux-gnu/libdl.so.2
0xb770d840  0xb771a467  Yes         /lib/i386-linux-gnu/libpthread.so.0
0xb7570490  0xb76a3cee  Yes         /lib/i386-linux-gnu/libc.so.6
0xb778a860  0xb77a276c  Yes         /lib/ld-linux.so.2
0xb7518190  0xb75348ec  Yes (*)     /home/ayuto/Desktop/Server/csgo/bin/libtier0.so
0xb74b9ad0  0xb74e9eec  Yes (*)     /home/ayuto/Desktop/Server/csgo/bin/libvstdlib.so
0xb6fbf4a0  0xb704c6c8  Yes (*)     /home/ayuto/Desktop/Server/csgo/bin/dedicated.so
0xb6f80d60  0xb6f961b4  Yes (*)     /home/ayuto/Desktop/Server/csgo/bin/libsteam_api.so
0xb6ee4914  0xb6f2ac78  Yes         /home/ayuto/Desktop/Server/csgo/bin/libstdc++.so.6
0xb6e8ae04  0xb6e9a4b8  Yes         /home/ayuto/Desktop/Server/csgo/bin/libgcc_s.so.1
0xb5e39060  0xb62692f0  Yes (*)     /home/ayuto/Desktop/Server/csgo/bin/engine.so
0xb56ccc70  0xb57b2a5c  Yes (*)     /home/ayuto/Desktop/Server/csgo/bin/materialsystem.so
0xb515d0d0  0xb5217c6c  Yes (*)     /home/ayuto/Desktop/Server/csgo/bin/studiorender.so
0xb4f61b80  0xb50bf99c  Yes (*)     /home/ayuto/Desktop/Server/csgo/bin/vphysics.so
0xb4e4cd80  0xb4ecf704  Yes (*)     /home/ayuto/Desktop/Server/csgo/bin/datacache.so
0xb4d724b0  0xb4dee054  Yes (*)     /home/ayuto/Desktop/Server/csgo/bin/vscript.so
0xb4d2a330  0xb4d47050  Yes (*)     /home/ayuto/Desktop/Server/csgo/bin/shaderapiempty.so
0xb339c4c0  0xb4012b04  Yes (*)     /home/ayuto/Desktop/Server/csgo/bin/steamclient.so
0xb777c9b0  0xb77800ba  Yes         /lib/i386-linux-gnu/librt.so.1
0xb32aff60  0xb32d51c0  Yes (*)     /home/ayuto/Desktop/Server/csgo/bin/crashhandler.so
0xb2df1b00  0xb2e4ef88  Yes (*)     /home/ayuto/Desktop/Server/csgo/csgo/bin/matchmaking_ds.so
0xb1c29850  0xb270071c  Yes (*)     /home/ayuto/Desktop/Server/csgo/csgo/bin/server.so
0xb1884ad0  0xb18b67e4  Yes (*)     /home/ayuto/Desktop/Server/csgo/bin/soundemittersystem.so
0xb184a6a0  0xb186611c  Yes (*)     /home/ayuto/Desktop/Server/csgo/bin/scenefilecache.so
0xb1627a10  0xb1637ffd  Yes (*)     /home/ayuto/Desktop/Server/csgo/csgo/addons/source-python.so
0xb660da90  0xb660e437  Yes         /lib/i386-linux-gnu/libutil.so.1
0xaccdd040  0xacf78fa4  Yes         /home/ayuto/Desktop/Server/csgo/csgo/addons/source-python/Python3/plat-linux/libpython3.6m.so.1.0
0xac3eb010  0xac9436b4  Yes         /home/ayuto/Desktop/Server/csgo/csgo/addons/source-python/bin/core.so
0xb6600750  0xb66015ce  Yes         /home/ayuto/Desktop/Server/csgo/csgo/addons/source-python/Python3/lib-dynload/_heapq.cpython-36m-i386-linux-gnu.so
0xb1611970  0xb1619e04  Yes         /home/ayuto/Desktop/Server/csgo/csgo/addons/source-python/Python3/lib-dynload/math.cpython-36m-i386-linux-gnu.so
0xabef6350  0xabf04434  Yes         /home/ayuto/Desktop/Server/csgo/csgo/addons/source-python/Python3/lib-dynload/_datetime.cpython-36m-i386-linux-gnu.so
0xb1609190  0xb160bfb8  Yes         /home/ayuto/Desktop/Server/csgo/csgo/addons/source-python/Python3/lib-dynload/zlib.cpython-36m-i386-linux-gnu.so
0xabe47670  0xabe57d34  Yes (*)     /lib/i386-linux-gnu/libz.so.1
0xb1603ea0  0xb1605392  Yes         /home/ayuto/Desktop/Server/csgo/csgo/addons/source-python/Python3/lib-dynload/_bz2.cpython-36m-i386-linux-gnu.so
0xabe34e30  0xabe41d34  Yes (*)     /lib/i386-linux-gnu/libbz2.so.1.0
0xabe6c660  0xabe6fbc1  Yes         /home/ayuto/Desktop/Server/csgo/csgo/addons/source-python/Python3/lib-dynload/_lzma.cpython-36m-i386-linux-gnu.so
0xabdfb850  0xabe130f4  Yes (*)     /lib/i386-linux-gnu/liblzma.so.5
0xabe67b10  0xabe681c2  Yes         /home/ayuto/Desktop/Server/csgo/csgo/addons/source-python/Python3/lib-dynload/grp.cpython-36m-i386-linux-gnu.so
0xabe62390  0xabe64254  Yes         /home/ayuto/Desktop/Server/csgo/csgo/addons/source-python/Python3/lib-dynload/_hashlib.cpython-36m-i386-linux-gnu.so
0xabc84bc0  0xabd7e034  Yes (*)     /lib/i386-linux-gnu/libcrypto.so.1.0.0
0xabe26270  0xabe30d24  Yes         /home/ayuto/Desktop/Server/csgo/csgo/addons/source-python/Python3/lib-dynload/_blake2.cpython-36m-i386-linux-gnu.so
0xabc44760  0xabc4a104  Yes         /home/ayuto/Desktop/Server/csgo/csgo/addons/source-python/Python3/lib-dynload/_sha3.cpython-36m-i386-linux-gnu.so
0xabe217d0  0xabe2200a  Yes         /home/ayuto/Desktop/Server/csgo/csgo/addons/source-python/Python3/lib-dynload/_bisect.cpython-36m-i386-linux-gnu.so
0xabc3fc30  0xabc408b1  Yes         /home/ayuto/Desktop/Server/csgo/csgo/addons/source-python/Python3/lib-dynload/_random.cpython-36m-i386-linux-gnu.so
0xb1600610  0xb160085a  Yes         /home/ayuto/Desktop/Server/csgo/csgo/addons/source-python/Python3/lib-dynload/_opcode.cpython-36m-i386-linux-gnu.so
0xabb7ae40  0xabb7bf34  Yes         /home/ayuto/Desktop/Server/csgo/csgo/addons/source-python/Python3/lib-dynload/_posixsubprocess.cpython-36m-i386-linux-gnu.so
0xabb74420  0xabb764ed  Yes         /home/ayuto/Desktop/Server/csgo/csgo/addons/source-python/Python3/lib-dynload/select.cpython-36m-i386-linux-gnu.so
0xabb699e0  0xabb6ded2  Yes         /home/ayuto/Desktop/Server/csgo/csgo/addons/source-python/Python3/lib-dynload/_struct.cpython-36m-i386-linux-gnu.so
0xabb61de0  0xabb641e4  Yes         /home/ayuto/Desktop/Server/csgo/csgo/addons/source-python/Python3/lib-dynload/binascii.cpython-36m-i386-linux-gnu.so
0xabb088b0  0xabb16804  Yes         /home/ayuto/Desktop/Server/csgo/csgo/addons/source-python/Python3/lib-dynload/_socket.cpython-36m-i386-linux-gnu.so
0xab8cebc0  0xab8dd3a4  Yes         /home/ayuto/Desktop/Server/csgo/csgo/addons/source-python/Python3/lib-dynload/_pickle.cpython-36m-i386-linux-gnu.so
0xab7c13c0  0xab7f7b54  Yes         /home/ayuto/Desktop/Server/csgo/csgo/addons/source-python/Python3/lib-dynload/_decimal.cpython-36m-i386-linux-gnu.so
0xab473440  0xab47991e  Yes         /home/ayuto/Desktop/Server/csgo/csgo/addons/source-python/Python3/lib-dynload/_json.cpython-36m-i386-linux-gnu.so
0xab3593a0  0xab35c114  Yes         /home/ayuto/Desktop/Server/csgo/csgo/addons/source-python/Python3/lib-dynload/unicodedata.cpython-36m-i386-linux-gnu.so
0xab339ad0  0xab33f9ab  Yes         /lib/i386-linux-gnu/libnss_files.so.2
0xab334890  0xab3355e4  Yes (*)     /lib/i386-linux-gnu/libnss_mdns4_minimal.so.2
0xab32dc40  0xab330ce1  Yes         /lib/i386-linux-gnu/libnss_dns.so.2
0xab317750  0xab3241c4  Yes         /lib/i386-linux-gnu/libresolv.so.2
0xab34fd20  0xab354c6c  Yes         /home/ayuto/Desktop/Server/csgo/csgo/addons/source-python/Python3/lib-dynload/audioop.cpython-36m-i386-linux-gnu.so
0xab349210  0xab34b274  Yes         /home/ayuto/Desktop/Server/csgo/csgo/addons/source-python/Python3/lib-dynload/mmap.cpython-36m-i386-linux-gnu.so
0xab0fd2e0  0xab10c294  Yes         /home/ayuto/Desktop/Server/csgo/csgo/addons/source-python/Python3/lib-dynload/_ctypes.cpython-36m-i386-linux-gnu.so
0xab0def50  0xab0e2554  Yes (*)     /usr/lib/i386-linux-gnu/libffi.so.6
0xaafe6400  0xab079814  Yes (*)     /home/ayuto/Desktop/Server/csgo/csgo/addons/source-python/Python3/plat-linux/libsqlite3.so.0
(*): Shared library is missing debugging information.
Dump of assembler code for function __kernel_vsyscall:
   0xb7787d3c <+0>: push   %ecx
   0xb7787d3d <+1>: push   %edx
   0xb7787d3e <+2>: push   %ebp
   0xb7787d3f <+3>: mov    %esp,%ebp
   0xb7787d41 <+5>: sysenter 
   0xb7787d43 <+7>: nop
   0xb7787d44 <+8>: nop
   0xb7787d45 <+9>: nop
   0xb7787d46 <+10>:    nop
   0xb7787d47 <+11>:    nop
   0xb7787d48 <+12>:    nop
   0xb7787d49 <+13>:    nop
   0xb7787d4a <+14>:    int    $0x80
=> 0xb7787d4c <+16>:    pop    %ebp
   0xb7787d4d <+17>:    pop    %edx
   0xb7787d4e <+18>:    pop    %ecx
   0xb7787d4f <+19>:    ret    
End of assembler dump.
Stack level 0, frame at 0xbfe93954:
 eip = 0xb7787d4c in __kernel_vsyscall; saved eip = 0xb7587687
 called by frame at 0xbfe93960
 Arglist at 0xbfe9394c, args: 
 Locals at 0xbfe9394c, Previous frame's sp is 0xbfe93954
 Saved registers:
  ebp at 0xbfe93944, eip at 0xbfe93950
End of Source crash report
----------------------------------------------

The funny thing is that it seems like it's crashing while a hook is being created. I will investigate this.

KhaimovMR commented 5 years ago

I think I've got related problem on linux.

from players.entity import Player
from events.hooks import PreEvent

@PreEvent('weapon_fire')
def on_weapon_fire(event):
    player = Player.from_userid(event['userid'])

    if player.view_player:
        player.view_coordinates = player.view_player.eye_location

The problem only comes out when this code executes on PreEvent. Everything works fine If we change PreEvent to Event. If not - dedicaded linux server is crashing.

The crash is occurred on the line:

    if player.view_player: