• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

tfs.service: Main process exited, code=killed, status=11/SEGV

nowitsky

Member
Joined
Jun 26, 2016
Messages
88
Solutions
2
Reaction score
13
Problem with fresh version of TFS 1.3.
Don't need to nothing, character can stay afk in temple and server crashes some times.

Any solutions?

crash 3.pngcrash 2.pngcrash 1.png
 
1. Some bugged LUA script may allocated all RAM in 1 second [generate big table/string in 'while' / 'for'], so you don't see it goes out of RAM.
2. There can be some C++ bug that crashes TFS.

You need to run it with 'ulimit -c unlimited' to generate 'core' file on crash. 'core' file is dump of RAM in moment of crash.
You can detect problem nr 1 (is this file 600MB or 3GB?). If it's 600MB, you can try to find C++ problem with 'gdb'.
 
@EDIT
@Gesior.pl
finally i relog on noobchat from god, kill 2 rotworms and server shutdown.

segmentation fault.png

Code:
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See coredump.conf(5) for details.

[Coredump]
#Storage=external
#Compress=yes
#ProcessSizeMax=2G
#ExternalSizeMax=2G
#JournalSizeMax=767M
#MaxUse=
#KeepFree=

what i need to do now?

before edit:
1. Some bugged LUA script may allocated all RAM in 1 second [generate big table/string in 'while' / 'for'], so you don't see it goes out of RAM.
2. There can be some C++ bug that crashes TFS.

You need to run it with 'ulimit -c unlimited' to generate 'core' file on crash. 'core' file is dump of RAM in moment of crash.
You can detect problem nr 1 (is this file 600MB or 3GB?). If it's 600MB, you can try to find C++ problem with 'gdb'.

i start the server with this command what you gave me and half hour working o right (using autoloot, and killing monsters all the time), we will see what's will be after few hours.
is it o right before ulimit -c unlimited my core file size is 0?

konsola 1.pngkonsola 2.png
 
Last edited:
@Gesior.pl

backtrace.png

what i remember, 1 week ago i didn't have this problem.

in last time i just add npc task, npc mission, daily creatures boost, modal addon doll.

@edit
i delete creature boost and see how long server can work without it

@edit2
still crash, i delete tasks and missions aswell

@Gesior.pl
i will try it now
 
Last edited:
From frames #11 and #10 we know it's something about Scheduler and there were many changes in Scheduler 4 days ago:
@nowitsky
I reported possible problem after changes from commit above. There are some new answers in PR: Implement scheduler timers using asio deadline timers by ranisalt · Pull Request #3278 · otland/forgottenserver (https://github.com/otland/forgottenserver/pull/3278#issuecomment-779525741)

Maybe someone will find reason of crash and fix it soon.
 
Last edited:
From frames #11 and #10 we know it's something about Scheduler and there were many changes in Scheduler 4 days ago:
@nowitsky
I reported possible problem after changes from commit above. There are some new answers in PR: Implement scheduler timers using asio deadline timers by ranisalt · Pull Request #3278 · otland/forgottenserver (https://github.com/otland/forgottenserver/pull/3278#issuecomment-779525741)

Maybe someone will find reason of crash and fix it soon.

Thank you, i will use my older version at this moment beacuse i download fresh one and i still have a problem.
 
Thank you, i will use my older version at this moment beacuse i download fresh one and i still have a problem.
They fixed bug 3 hours ago:
It's merge to 'master', so you can download newest sources and it should not crash.
 
They fixed bug 3 hours ago:
It's merge to 'master', so you can download newest sources and it should not crash.

so why sheduler.cpp is different in newest sources? it's not same
(33 line is different, and difference in quantity of lines)

i try to edit it manually.

sheduler.cpp from newest source
C++:
/**
* The Forgotten Server - a free and open-source MMORPG server emulator
* Copyright (C) 2019  Mark Samman <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#include "otpch.h"

#include "scheduler.h"
#include <boost/asio/post.hpp>
#include <memory>

uint32_t Scheduler::addEvent(SchedulerTask* task)
{
    // check if the event has a valid id
    if (task->getEventId() == 0) {
        task->setEventId(++lastEventId);
    }

    // insert the event id in the list of active events
    auto it = eventIdTimerMap.emplace(task->getEventId(), boost::asio::steady_timer{io_context});
    auto& timer = it.first->second;

    timer.expires_from_now(std::chrono::milliseconds(task->getDelay()));
    timer.async_wait([this, task](const boost::system::error_code& error) {
        eventIdTimerMap.erase(task->getEventId());

        if (error == boost::asio::error::operation_aborted || getState() == THREAD_STATE_TERMINATED) {
            // the timer has been manually cancelled(timer->cancel()) or Scheduler::shutdown has been called
            delete task;
            return;
        }

        g_dispatcher.addTask(task, true);
    });

    return task->getEventId();
}

void Scheduler::stopEvent(uint32_t eventId)
{
    if (eventId == 0) {
        return;
    }

    boost::asio::post(io_context, [this, eventId]() {
        // search the event id..
        auto it = eventIdTimerMap.find(eventId);
        if (it != eventIdTimerMap.end()) {
            it->second.cancel();
        }
    });
}

void Scheduler::shutdown()
{
    setState(THREAD_STATE_TERMINATED);
    boost::asio::post(io_context, [this]() {
        // cancel all active timers
        for (auto& it : eventIdTimerMap) {
            it.second.cancel();
        }

        io_context.stop();
    });
}

SchedulerTask* createSchedulerTask(uint32_t delay, std::function<void (void)> f)
{
    return new SchedulerTask(delay, std::move(f));
}

sheduler.cpp after ranisalt fix
C++:
/**
* The Forgotten Server - a free and open-source MMORPG server emulator
* Copyright (C) 2019  Mark Samman <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#include "otpch.h"

#include "scheduler.h"
#include <boost/asio/post.hpp>
#include <memory>

uint32_t Scheduler::addEvent(SchedulerTask* task)
{
    // check if the event has a valid id
    if (task->getEventId() == 0) {
        task->setEventId(++lastEventId);
    }

    io_context.post([this, task]() {
        // insert the event id in the list of active events
        auto it = eventIdTimerMap.emplace(task->getEventId(), boost::asio::steady_timer{io_context});
        auto& timer = it.first->second;

        timer.expires_from_now(std::chrono::milliseconds(task->getDelay()));
        timer.async_wait([this, task](const boost::system::error_code& error) {
            eventIdTimerMap.erase(task->getEventId());

            if (error == boost::asio::error::operation_aborted || getState() == THREAD_STATE_TERMINATED) {
                // the timer has been manually cancelled(timer->cancel()) or Scheduler::shutdown has been called
                delete task;
                return;
            }

            g_dispatcher.addTask(task, true);
        });
    });

    return task->getEventId();
}

void Scheduler::stopEvent(uint32_t eventId)
{
    if (eventId == 0) {
        return;
    }

    boost::asio::post(io_context, [this, eventId]() {
        // search the event id..
        auto it = eventIdTimerMap.find(eventId);
        if (it != eventIdTimerMap.end()) {
            it->second.cancel();
        }
    });
}

void Scheduler::shutdown()
{
    setState(THREAD_STATE_TERMINATED);
    boost::asio::post(io_context, [this]() {
        // cancel all active timers
        for (auto& it : eventIdTimerMap) {
            it.second.cancel();
        }

        io_context.stop();
    });
}

SchedulerTask* createSchedulerTask(uint32_t delay, std::function<void (void)> f)
{
    return new SchedulerTask(delay, std::move(f));
}

and i have another problem:
freePremium = yes
and nobody have free premium :p

i know i can add flag alwayspremiym to players but i want to know why this function in config don't working :p

Lua:
allowChangeOutfit = true
freePremium = yes
kickIdlePlayerAfterMinutes = 30
maxMessageBuffer = 4
emoteSpells = false
classicEquipmentSlots = false
classicAttackSpeed = false
showScriptsLogInConsole = true
showOnlineStatusInCharlist = false
yellMinimumLevel = 2
yellAlwaysAllowPremium = false
forceMonsterTypesOnLoad = true
cleanProtectionZones = false
luaItemDesc = false

@Gesior.pl finally got crash newest source is added 17 hours ago, they fix it 3 hours ago.

backtrace 2.png
 
Last edited:
Back
Top