otland / forgottenserver

A free and open-source MMORPG server emulator written in C++
https://otland.net
GNU General Public License v2.0
1.59k stars 1.06k forks source link

[Bug]: Thread 2 "tfs" received signal SIGSEGV, Segmentation fault #4772

Closed SONGOKOMETA closed 1 month ago

SONGOKOMETA commented 2 months ago

By submitting this bug issue, you agree to the following.

Does this bug crash tfs?

yes

Server Version

1.4.x (Release)

Operation System

Ubuntu 22.04

Bug description

Server crash on start up

Steps to reproduce

  1. gdb ./build/RelWithDebInfo/tfs
  2. run
  3. crash?

Im running the server on Oracle Cloud. Fresh instance (4 OCPUs, 24GB RAM). Pretty much followed the wiki tutorial 1:1, repo installed with vcpkg. The only modified file in my server folder is config.lua, i added mysql configuration (mysqlUser, mysqlPass, mysqlDatabase)

Actual Behavior

Running tfs in gdb results in:

Thread 2 "tfs" received signal SIGSEGV, Segmentation fault. [Switching to Thread 0xfffff6a93080 (LWP 88711)] 0x0000aaaaaada28e4 in lua_gettop ()

Further inspection with bt full results in: image

Expected Behavior

Server runs.

Backtrace

gdb) bt full
#0  0x0000aaaaaada28e4 in lua_gettop ()
No symbol table info available.
#1  0x0000aaaaaada7800 in luaL_loadfilex ()
No symbol table info available.
#2  0x0000aaaaaac83100 in LuaScriptInterface::loadFile (this=0xaaaaab4fc9b8 <g_luaEnvironment>, file="data/global.lua", npc=npc@entry=0x0) at /root/forgottenserver/src/luascript.cpp:511
        ret = <optimized out>
        env = <optimized out>
        __func__ = "loadFile"
#3  0x0000aaaaaab9e598 in ScriptingManager::loadScriptSystems (this=this@entry=0xaaaaab4fc888 <ScriptingManager::getInstance()::instance>) at /root/forgottenserver/src/scriptmanager.cpp:48
No locals.
#4  0x0000aaaaaac043cc in (anonymous namespace)::mainLoader (services=0xfffffffff1f8) at /root/forgottenserver/src/scriptmanager.h:20
        configFile = <optimized out>
        c_test = <incomplete type>
        worldType = ""
        rentPeriod = <optimized out>
        strRentPeriod = "OTB v3.65.62"
#5  0x0000aaaaaab72268 in std::function<void ()>::operator()() const (this=0xaaaaab570930) at /usr/include/c++/11/bits/std_function.h:590
No locals.
#6  Task::operator() (this=0xaaaaab570920) at /root/forgottenserver/src/tasks.h:23
No locals.
#7  Dispatcher::threadMain (this=0xaaaaab4f4518 <g_dispatcher>) at /root/forgottenserver/src/tasks.cpp:37
        task = 0xaaaaab570920
        __for_range = <optimized out>
        __for_begin = <optimized out>
        __for_end = <optimized out>
Python Exception <class 'gdb.error'>: value has been optimized out
        tmpTaskList =
        taskLockUnique = {_M_device = 0xaaaaab4f4528 <g_dispatcher+16>, _M_owns = false}
#8  0x0000fffff7e631fc in ?? () from /lib/aarch64-linux-gnu/libstdc++.so.6
No symbol table info available.
#9  0x0000fffff7b8d5c8 in start_thread (arg=0x0) at ./nptl/pthread_create.c:442
        ret = <optimized out>
        pd = 0x0
        out = <optimized out>
        unwind_buf = {cancel_jmp_buf = {{jmp_buf = {281474820026496, 281474976706672, 281474976706670, 8448192, 281474976706671, 0, 281474811576320, 8448192, 281474842427328, 281474811576320, 281474820024224, 16867614693622816047, 0,
                16867614693607206547, 0, 0, 0, 0, 0, 0, 0, 0}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
        not_first_call = 0
#10 0x0000fffff7bf5edc in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:79
No locals.
Codinablack commented 2 months ago

Based off your call stack, it seems the issue is with loading global.lua, specifically it seems to have some information regarding an npc that reads to be nothing... if its not actually the global.lua perhaps you have an npc's xml file pointing to a nonexistent lua file, that seems like it could be the case maybe? Otherwise, my guess would be someone tried to make tfs have more threads and failed.

gesior commented 1 month ago

I cannot confirm. CLOSE this Issue?

I've followed Ubuntu build ( https://github.com/otland/forgottenserver/wiki/Compiling-on-Ubuntu ) on Ubuntu 20.04:

I ran that on my Oracle ARM 4 cores 24 GB RAM server (all TFS 0.2 to 1.x C++ libraries already installed):

wget https://github.com/otland/forgottenserver/archive/refs/heads/1.4.zip
unzip 1.4.zip
cd forgottenserver-1.4/
mkdir build
cd build/
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
make -j 4
mv tfs ../tfs
cd ..
mysql -e 'CREATE DATABASE tfs14test'
mysql tfs14test < schema.sql

-- edit SQL login data
pico config.lua

-- NO ERROR
./tfs

Edited data/global.lua:

pico data/global.lua
-- added 'idc' as first line of 'data/global.lua'
./tfs

TFS 1.4 thrown a lot of Lua errors ex.:

Lua Script Error: [Scripts Interface]
/root/forgottenserver-1.4/data/scripts/talkactions/position.lua
...orgottenserver-1.4/data/scripts/talkactions/position.lua:3: attempt to index local 'talk' (a userdata value)
stack traceback:
        [C]: in function '__newindex'
        ...orgottenserver-1.4/data/scripts/talkactions/position.lua:3: in main chunk

but it did not crash.

I'm 99% sure that vcpkg build ( https://github.com/otland/forgottenserver/wiki/Compiling-on-Linux-&-Mac-OS-X-(vcpkg) ) wasn't configured in TFS 1.4 times ex. vcpkg.json is missing in 1.4

SONGOKOMETA commented 1 month ago

It just might be an issue on my end, i cannot confirm or deny it for now. I will close the issue for now and mess around with the instalation again when i have some time.