Segmentation fault.

Started by Xmair, Oct 11, 2015, 07:59 AM

Previous topic - Next topic

Xmair

Hello everyone, I was hosting my server from the @S.L.C 's vps, I was playing on it with some players but suddenly I lost the connection and when I saw on PuTty there was something like "Segmentation fault" I asked @NE.CrystalBlue about it and said him to try, But he is also getting the same error.
Can someone tell me how to fix this error and why is this error coming?
Don't mind me please because I'm still learning debian.

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

DizzasTeR

This is happening due to the squirrel plugin.

Thijn

You're probably doing something wrong with timers.
Do you have a file named "core" in your server directory? If so, upload that somewhere and I'll take a look.

.

#3
Yeah, you're not the only one with this issue. The problem is that the Squirrel plugin passes a bunch of raw pointers (mostly entities) to the squirrel VM which allows you to store them and pretty much do what you do with them. So, when the Squirrel plugin has finished working with those instances it deletes them to free up memory. The only problem now is that your script (the VM) is still having a reference to that instance and when that reference is finally released the VM tries to delete that instance as well. And now you're trying to delete the same object twice.

Therefore, DO NOT keep a reference to an instance after that reference was deleted. Imagine the following:
local some_instance;
local other_instance;

function onPlayerJoin(player)
{
    // This player instance now has a reference in our script
    // And therefore it's reference counter is 1
    some_instance = player;
    // Now we make another reference to this player instance
    // And therefore it's reference counter is 2
    other_instance = player;
}

function onPlayerPart(player, reason)
{
    // We only release one of those references here
    some_instance = null;
    // And therefore it's reference counter is 1
    print("we forget to release that other reference!");
    // The plugin deletes this player instance!
}

function onServerStop()
{
    print("bla, blah, blah we were careless...");
    // After this function the VM will shut down and release the remaining references automatically
    // The reference counter goes to all the way to 0 and that means it must delete the instance
    // The only problme is that instance was already deleted after onPlayerPart(...)
}

The reference counter tells how many times you have stored that instance in a variable in the script somewhere (including arrays, tables etc.) Each time you store it somewhere the counter goes up by 1 and each time you release it from somewhere the counter goes down by 1. And when the counter reaches 0 that means nobody is referencing that instance and that it's safe to delete it and recover memory.
.