Bromvlieg / gm_bromsock

Networking module for Garrysmod
MIT License
62 stars 11 forks source link

Crash #41

Open Be1zebub opened 1 year ago

Be1zebub commented 1 year ago

crash when call BromSock() in coroutine.

reproduce:

coroutine.wrap(function()
    local socket = BromSock()
end)()

env: debian 11, kvm vps x86-x64 arch, server running in pterodactyl, gmsv_bromsock_linux_ubuntu.dll binary (because debian builds seems to be outdated & require libssl installed - idk how to get & install libssl.so properly)

Bromvlieg commented 1 year ago

There's several issues with how the GC references are reacting, one of that is that it causes wierd crashes like yours. I cannot help what that sadly, I am however in the process in the past days to rewrite it with all the stuff I've learned from C++ over the years. So I cannot help you at the moment. But I hope to deliver a new version of BromSock within 1-2 weeks that should solve the crashes. In the weekend I hope that I'm far enough to be able to push a V2 branch. (trying to keep all the lua functions the same)

Bromvlieg commented 1 year ago

It appears to be a Garrysmod issue with coroutine btw, https://github.com/Facepunch/gmod-module-base/issues/3

Bromvlieg commented 1 year ago

@Be1zebub I'm not sure if it's already usable for your case, but I've set up ci/cd for linux 32&64 binaries for the v2 branch. If you go to actions -> last one -> artifacts you can download them. Perhaps it already helps, I will continue to work on it, as i am not 100% sure it works for all old cases yet.

Be1zebub commented 1 year ago

It appears to be a Garrysmod issue with coroutine btw, Facepunch/gmod-module-base#3

chttp, reqwest, mysqloo, tmysql4 - have solved it, or have not encountered this problem.

Be1zebub commented 1 year ago

@Be1zebub I'm not sure if it's already usable for your case, but I've set up ci/cd for linux 32&64 binaries for the v2 branch. If you go to actions -> last one -> artifacts you can download them. Perhaps it already helps, I will continue to work on it, as i am not 100% sure it works for all old cases yet.

where i can get libc & install it on gmod? i cant require new build

lua_run require("bromsock")
> require("bromsock")...
[ERROR] lua_run:1: Couldn't load module library! (/lib/i386-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /home/container/garrysmod/lua/bin/gmsv_bromsock_linux.dll))
  1. require - [C]:-1
   2. unknown - lua_run:1
Bromvlieg commented 1 year ago

It seems Debian 11 uses glibc (2.31-13+deb11u5), where Ubuntu 22.04 uses glibc 2.33. (on my WSL install, i got glibc2.34, which also conflicts) If I staticly link it, it fails to work sadly. Seems I will have to set up a debian runner to provide a working build for you. Which, github does not provide 😢

Just to be sure, you are on latest version of Debian 11 Bullseye correct?

Be1zebub commented 1 year ago

Just to be sure, you are on latest version of Debian 11 Bullseye correct?

yeah image

Be1zebub commented 1 year ago

It appears to be a Garrysmod issue with coroutine btw, Facepunch/gmod-module-base#3

chttp, reqwest, mysqloo, tmysql4 - have solved it, or have not encountered this problem.

asked chttp developer about it image are you building it with master module_base? seems like its fixed in "development" branch

Bromvlieg commented 1 year ago

Yeah I've integrated the development branch as that's the one with CMake supported files, in such a way that I dont have to update any gmod headers myself. So then V2 branch should fix the corotine atleast.

If you have access to install any package yourself on your Debian, you could also try compiling it yourself. To do a full compile, i run the following commands:

### clone the V2 git repo
git clone git@github.com:Bromvlieg/gm_bromsock.git
cd gm_bromsock
git checkout v2

### setup compiler dependencies
sudo apt update
sudo apt install python3-pip
sudo apt install build-essential gcc-10 libgl1-mesa-glx libgl1-mesa-dev libglew-dev ninja-build sudo python3-pip libx11-dev libx11-xcb-dev libfontenc-dev libice-dev libsm-dev libxau-dev libxaw7-dev libxcomposite-dev libxcursor-dev libxdamage-dev libxdmcp-dev libxext-dev libxfixes-dev libxft-dev libxi-dev libxinerama-dev libxkbfile-dev libxmu-dev libxmuu-dev libxpm-dev libxrandr-dev libxrender-dev libxres-dev libxss-dev libxt-dev libxtst-dev libxv-dev libxvmc-dev libxxf86vm-dev xtrans-dev libxcb-render0-dev libxcb-render-util0-dev libxcb-xkb-dev libxcb-icccm4-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-randr0-dev libxcb-shape0-dev libxcb-sync-dev libxcb-xfixes0-dev libxcb-xinerama0-dev xkb-data libxcb-dri3-dev uuid-dev libxcb-util-dev
sudo pip install conan==1.59.0

### install all conan dev headers / libs
conan install . -c tools.system.package_manager:mode=install -c tools.system.package_manager:sudo=True --build=missing

### do the actual build
mkdir build
cd build
CXX=g++-10
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release
ninja

### now the build artifacts should be ready in the next folder
cd ../bromsock/artifacts
Be1zebub commented 1 year ago

image image i got x64 builds. how to build x32?

Bromvlieg commented 1 year ago

Derp, sorry.

boils down to adding :i386 to all libs and set conan to use m32.

Heres the steps again but for x32 binary, taken from the github workflow I made. Remove the build folder first tho, or use build32 at the mkdir and cd step

### clone the V2 git repo
git clone git@github.com:Bromvlieg/gm_bromsock.git
cd gm_bromsock
git checkout v2

### setup compiler dependencies
sudo dpkg --add-architecture i386
sudo apt update
sudo apt install build-essential gcc-10 libgl1-mesa-glx libgl1-mesa-dev libglew-dev ninja-build sudo python3-pip libx11-dev libx11-xcb-dev libfontenc-dev libice-dev libsm-dev libxau-dev libxaw7-dev libxcomposite-dev libxcursor-dev libxdamage-dev libxdmcp-dev libxext-dev libxfixes-dev libxft-dev libxi-dev libxinerama-dev libxkbfile-dev libxmu-dev libxmuu-dev libxpm-dev libxrandr-dev libxrender-dev libxres-dev libxss-dev libxt-dev libxtst-dev libxv-dev libxvmc-dev libxxf86vm-dev xtrans-dev libxcb-render0-dev libxcb-render-util0-dev libxcb-xkb-dev libxcb-icccm4-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-randr0-dev libxcb-shape0-dev libxcb-sync-dev libxcb-xfixes0-dev libxcb-xinerama0-dev xkb-data libxcb-dri3-dev uuid-dev libxcb-util-dev gcc-multilib g++-multilib g++-10-multilib gcc-10-multilib
sudo apt install libgl1-mesa-glx:i386 libgl1-mesa-dev:i386 libx11-dev:i386 libx11-xcb-dev:i386 libfontenc-dev:i386 libice-dev:i386 libsm-dev:i386 libxau-dev:i386 libxaw7-dev:i386 libxcomposite-dev:i386 libxcursor-dev:i386 libxdamage-dev:i386 libxdmcp-dev:i386 libxext-dev:i386 libxfixes-dev:i386 libxft-dev:i386 libxi-dev:i386 libxinerama-dev:i386 libxkbfile-dev:i386 libxmu-dev:i386 libxmuu-dev:i386 libxpm-dev:i386 libxrandr-dev:i386 libxrender-dev:i386 libxres-dev:i386 libxss-dev:i386 libxt-dev:i386 libxtst-dev:i386 libxv-dev:i386 libxvmc-dev:i386 libxxf86vm-dev:i386 xtrans-dev:i386 libxcb-render0-dev:i386 libxcb-render-util0-dev:i386 libxcb-xkb-dev:i386 libxcb-icccm4-dev:i386 libxcb-image0-dev:i386 libxcb-keysyms1-dev:i386 libxcb-randr0-dev:i386 libxcb-shape0-dev:i386 libxcb-sync-dev:i386 libxcb-xfixes0-dev:i386 libxcb-xinerama0-dev:i386 xkb-data:i386 libxcb-dri3-dev:i386 uuid-dev:i386 libxcb-util-dev:i386 libgl1-mesa-dev:i386 libopengl-dev:i386 libx11-dev:i386 libz-dev:i386 libz-dev:i386 libgl1-mesa-dev:i386 libopengl-dev:i386 libx11-dev:i386 libglu-dev:i386
sudo pip install conan==1.59.0

### install all conan dev headers / libs
conan profile new default --detect
conan profile update settings.arch=x86 default
conan install . -c tools.system.package_manager:mode=install -c tools.system.package_manager:sudo=True --build=missing

### do the actual build
mkdir build
cd build
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS=-m32 -DCMAKE_C_FLAGS=-m32 -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10
ninja

### now the build artifacts should be ready in the next folder
cd ../bromsock/artifacts
Be1zebub commented 1 year ago

i stuck at conan stage image

Bromvlieg commented 1 year ago

Wierd, it should auto fill that. conan profile update settings.compiler.libcxx=libstdc++ default

If that doesn't work, try adding me on steam under bromvlieg, Might be easier to debug than github issue 😄

Be1zebub commented 1 year ago

okey, ive tested new build & still get crash.

Bromvlieg commented 1 year ago

I'll try to debug some things on my end with the coroutine. meanwhile got a few more things working regarding UDP so having progress.