Closed Frag1337 closed 3 years ago
What happens when you install libffi6 using this method? Of course, don't forget to remove the symbolic link to libffi7.
What happens when you install libffi6 using this method? Of course, don't forget to remove the symbolic link to libffi7.
I removed the symlink and used that method but it gave me an error with the package not being compitable.
So I downloaded the file manually, dropped it into /home/user/
and ran it with sudo apt install ./libffi6_3.2.1-9_i386.deb
successfully. Sadly the same results from top.
Can someone replicate this? Is it a wrong offset or something different? I sadly have no idea about solving crashes :/
In another issue (https://github.com/Source-Python-Dev-Team/Source.Python/issues/334#issuecomment-744646437) I mentioned that I've reinstalled 2x VMs on my Windows 10 PC with Debian and Ubuntu and both crashed when using this snippet aswell. With Debian not requiring a workaround for libffi6, but sadly resulted in the same crash.
What happens if you try this code?
Change player.drop_weapon(weapon)
to drop_weapon_test(player, weapon)
.
def drop_weapon_test(player, weapon):
import ctypes
from memory.hooks import set_hooks_disabled
functype = ctypes.CFUNCTYPE(None, *(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p))
drop_weapon = functype(player.drop_weapon.address)
player_p = ctypes.c_void_p(player.pointer.address)
weapon_p = ctypes.c_void_p(weapon.pointer.address)
set_hooks_disabled(True)
print("Drop the weapon by ctypes.")
drop_weapon(player_p, weapon_p, None, None)
print("Success.")
set_hooks_disabled(False)
player.equip_weapon(weapon)
set_hooks_disabled(True)
print("Drop the weapon.")
player.drop_weapon(player, weapon)
print("Success.")
set_hooks_disabled(False)
What happens if you try this code?
sp plugin load test
[SP] Loading plugin 'test'...
1.1 Trying to remove weapons from Frag..
1.1 Found weapon_knife from Frag. Lets drop it.
2.1 Drop the weapon by ctypes.
2.2 Success.
Segmentation fault (core dumped)
Add "-debug" to the ./srcds_run command line to generate a debug.log to help with solving this problem
Thu Dec 17 22:04:45 UTC 2020: Server restart in 10 seconds
import ctypes
from memory.hooks import set_hooks_disabled
from filters.players import PlayerIter
def drop_weapon_test(player, weapon):
functype = ctypes.CFUNCTYPE(None, *(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p))
drop_weapon = functype(player.drop_weapon.address)
player_p = ctypes.c_void_p(player.pointer.address)
weapon_p = ctypes.c_void_p(weapon.pointer.address)
set_hooks_disabled(True)
print("2.1 Drop the weapon by ctypes.")
drop_weapon(player_p, weapon_p, None, None)
print("2.2 Success.")
set_hooks_disabled(False)
player.equip_weapon(weapon)
set_hooks_disabled(True)
print("2.3 Drop the weapon.")
player.drop_weapon(player, weapon)
print("2.4 Success.")
set_hooks_disabled(False)
for player in PlayerIter():
print('1.1 Trying to remove weapons from {}..'.format(player.name))
for weapon in player.weapons():
print('1.1 Found {} from {}. Lets drop it.'.format(weapon.classname, player.name))
drop_weapon_test(player, weapon)
Server crashed :/
I should have disabled the hook in equip_weapon as well... my bad.
How about this code?
Code:
def drop_weapon_test(player, weapon):
set_hooks_disabled(True)
print("2.1 Drop the weapon.")
player.drop_weapon(player, weapon)
print("2.2 Success.")
set_hooks_disabled(False)
How about this code?
sp plugin load test
[SP] Loading plugin 'test'...
1.1 Trying to remove weapons from Frag..
1.1 Found weapon_knife from Frag. Lets drop it.
2.1 Drop the weapon.
Segmentation fault (core dumped)
Add "-debug" to the ./srcds_run command line to generate a debug.log to help with solving this problem
Thu Dec 17 22:32:55 UTC 2020: Server restart in 10 seconds
test.py
import ctypes
from memory.hooks import set_hooks_disabled
from filters.players import PlayerIter
def drop_weapon_test(player, weapon):
set_hooks_disabled(True)
print("2.1 Drop the weapon.")
player.drop_weapon(player, weapon)
print("2.2 Success.")
set_hooks_disabled(False)
for player in PlayerIter():
print('1.1 Trying to remove weapons from {}..'.format(player.name))
for weapon in player.weapons():
print('1.1 Found {} from {}. Lets drop it.'.format(weapon.classname, player.name))
drop_weapon_test(player, weapon)
Still crashes.
Still crashes.
Thanks for the test.
Yes, this seems to be an error caused by libffi. Other users are experiencing the same issue on Ubuntu 20.04.
The problem is that I don't know how to solve it.
You can use ctypes
to work around it, but that's not a solution at all.
I'll do some testing on Ubuntu.
Thanks for trying to help me, very appreciated!
It's so frustrating to have a perfect working plugin on a local windows srcds, but the moment you want to run them publicly on a linux machine, some features which usually worked before doesnt anymore.. Should I reinstall and downgrade to Ubuntu 18, should I switch to Debian? I just dont know because sadly I'm not experienced enough to solve these crashes by myself. Kind of out of my hands.
Yes, this seems to be an error caused by libffi.
My guess of libffi was wrong. I've added a fix to the problem. #375
Thank you so much for investigating this issue! Very appreciated. I hope it gets pushed very soon!
It would be awesome from you if you could checkout my other issues related to linux.. 👍
Edit: Sorry I havent seen you mentioned my issues in your pull request. You just made my day.
Hello,
when using following snippet while being on a team/alive on the server:
I get following crash:
The server also crashes on
weapon.remove()
by uncommenting
player.drop_weapon(weapon)
Not sure if its helpful, but I've used this fix to make Source.Python work:
https://forums.sourcepython.com/viewtopic.php?p=13976#p13976 Method 2