TFS 1.X+ Server Crash...Or maybe not?

Discussion in 'Support' started by Ramirow, Nov 10, 2018.

  1. Ramirow

    Ramirow Active Member

    Joined:
    Aug 22, 2009
    Messages:
    331
    Likes Received:
    95
    Best Answers:
    0
    Hello everyone, I'm facing an strange issue with my server, running TFS 1.2
    Sometimes, when I login within my local network or some player (from the internet) logs in WHILE im online, the server just hangs.
    No error code, the console just stays open but everyone gets Connection Lost and server basically closes.

    What I did:
    Thought that I was something with the player, after restarting server he just logged in fine.
    After that, thought it was something caused by login itself. Tried to logout and login more than 100 times with no luck.

    It happens sometimes, and sometimes it doesn't, what could possibly be? Or what additional data I need to have for you guys to help me identify the issue? Thanks in advance!
     
  2. Bogart

    Bogart ...has super panda powers

    Joined:
    Jun 21, 2009
    Messages:
    8,001
    Likes Received:
    546
    Best Answers:
    23
    Check your login scripts in data/creaturescripts/scripts
     
    Ramirow likes this.
  3. Stigma

    Stigma Support Team Support Team

    Joined:
    Feb 14, 2015
    Messages:
    4,227
    Likes Received:
    1,974
    Best Answers:
    341
    if the server hangs it's caused by an infinite loop, which most likely means it's a script unless you've made recent source changes
    like bogart said, it's most likely a login script you have in creaturescripts but it could also be some new system you added which has a loop with a condition that can result in an infinite loop
     
  4. Ramirow

    Ramirow Active Member

    Joined:
    Aug 22, 2009
    Messages:
    331
    Likes Received:
    95
    Best Answers:
    0
    Hmmm...my login script is the following:
    Code (Text):
    1.  
    2. function onLogin(player)
    3.     local loginStr = "Welcome to " .. configManager.getString(configKeys.SERVER_NAME) .. "!"
    4.     if player:getLastLoginSaved() <= 0 then
    5.         loginStr = loginStr .. " Please choose your outfit."
    6.         player:sendOutfitWindow()
    7.     else
    8.         if loginStr ~= "" then
    9.             player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
    10.         end
    11.         loginStr = string.format("Your last visit was on %s.", os.date("%a %b %d %X %Y", player:getLastLoginSaved()))
    12.     end
    13.     player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
    14.  
    15.     -- Stamina
    16.     nextUseStaminaTime[player.uid] = 0
    17.  
    18.     -- Promotion
    19.     local vocation = player:getVocation()
    20.     local promotion = vocation:getPromotion()
    21.     if player:isPremium() then
    22.         local value = player:getStorageValue(STORAGEVALUE_PROMOTION)
    23.         if not promotion and value ~= 1 then
    24.             player:setStorageValue(STORAGEVALUE_PROMOTION, 1)
    25.         elseif value == 1 then
    26.             player:setVocation(promotion)
    27.         end
    28.     elseif not promotion then
    29.         player:setVocation(vocation:getDemotion())
    30.     end
    31.  
    32.     -- Events
    33.     player:registerEvent("statHP")
    34.     player:registerEvent("dragonKill")
    35.     player:registerEvent("cycKill")
    36.     player:registerEvent("boneKill")
    37.     player:registerEvent("rotKill")
    38.     player:registerEvent("wolfKill")
    39.     player:registerEvent("spiderKill")
    40.     player:registerEvent("PlayerDeath")
    41.     player:registerEvent("DropLoot")
    42.     return true
    43. end
    44.  
     
  5. Stigma

    Stigma Support Team Support Team

    Joined:
    Feb 14, 2015
    Messages:
    4,227
    Likes Received:
    1,974
    Best Answers:
    341
    go to data/global.lua and put this code at the bottom:
    Code (Lua):
    1. local start = os.mtime()
    2. local linecount = 0
    3. debug.sethook(function(event, line)
    4.     linecount = linecount + 1
    5.     if os.mtime() - start >= 1000 then
    6.         if linecount >= 30000 then
    7.             print(string.format("possible infinite loop in file %s near line %s", debug.getinfo(2).source, line))
    8.             debug.sethook()
    9.         end
    10.         linecount = 0
    11.         start = os.mtime()
    12.     end
    13. end, "l")
    now when you have a possible infinite loop somewhere in your code it will print out something like this
    Code (Text):
    1. possible infinite loop in file @data/global.lua near line 80
    you just have to wait for it to hang again, if nothing pops up in the server after a few seconds then it's related to source and not a script
     
    Last edited: Nov 11, 2018
    luptonicedtea and Ramirow like this.
  6. Ramirow

    Ramirow Active Member

    Joined:
    Aug 22, 2009
    Messages:
    331
    Likes Received:
    95
    Best Answers:
    0
    Thank you sir! I have already inserted the code, got a similar message after starting the server:

    Code (Text):
    1. possible infinite loop in file @data/npc/lib/npc.lua near line 2
    That line contains:
    Code (Text):
    1. dofile('data/npc/lib/npcsystem/npcsystem.lua')
    I think I can ignore that event as my issue arises at login, I don't see how an NPC file could affect that, I will just wait now!
     
  7. Stigma

    Stigma Support Team Support Team

    Joined:
    Feb 14, 2015
    Messages:
    4,227
    Likes Received:
    1,974
    Best Answers:
    341
    change >= 30000 to >= 500000 so it's less likely to give a false positive, if you still get false positives change it to higher
    the highest line count i've tested was 1million
     
    luptonicedtea likes this.

Share This Page

Loading...