Posts: 6,485
Threads: 176
Joined: Jan 2012
Thanks: 131
Given 1075 thank(s) in 852 post(s)
I have analysed the crashdump tonibm9 has provided and the cause is quite simple - a plugin is trying to call cItems:Get() for an item index that is not in the cItems object. Now, I haven't checked the plugin's source yet (I suppose it's the one by STR_Warrior to fix pickups), but I suppose it has an off-by-one error, too - the cItems object is indexed starting at zero, so valid indices are 0 .. (Size() - 1).
I'll fix the cItems interface to be resistant to these kinds of errors - instead of crashing it will log an error and return a nil object. Pity, that's a bit of performance lost (but hey, it's no big deal here, it's not like you'll be calling this 500k times a second.)
Posts: 1,450
Threads: 53
Joined: Feb 2011
Thanks: 15
Given 120 thank(s) in 91 post(s)
Or make a safe and unsafe version of the function for it if performance is important.
Posts: 1,162
Threads: 68
Joined: Mar 2013
Thanks: 245
Given 125 thank(s) in 100 post(s)
I tried PickupFix with Ubuntu, and it worked!
The error is with CentOS
but please fix it, ubuntu is too slow for me! CentOS is better!
Posts: 6,485
Threads: 176
Joined: Jan 2012
Thanks: 131
Given 1075 thank(s) in 852 post(s)
05-13-2013, 01:59 AM
(This post was last modified: 05-13-2013, 02:00 AM by xoft.)
Rev 1472 should be working, but it will produce warnings whenever the old version would crash because of the plugin
(05-13-2013, 01:56 AM)FakeTruth Wrote: Or make a safe and unsafe version of the function for it if performance is important.
Nah, here it's really not important, safety is much better here.
Posts: 1,162
Threads: 68
Joined: Mar 2013
Thanks: 245
Given 125 thank(s) in 100 post(s)
(05-13-2013, 01:59 AM)xoft Wrote: Rev 1472 should be working, but it will produce warnings whenever the old version would crash because of the plugin Ok, I will try, but, can you remove warnings?
Posts: 6,485
Threads: 176
Joined: Jan 2012
Thanks: 131
Given 1075 thank(s) in 852 post(s)
05-13-2013, 02:01 AM
(This post was last modified: 05-13-2013, 02:02 AM by xoft.)
(05-13-2013, 01:58 AM)tonibm19 Wrote: I tried PickupFix with Ubuntu, and it worked!
It might have worked, but it could have also corrupted memory somewhere, which would cause MCServer to crash later on.
(05-13-2013, 02:00 AM)tonibm19 Wrote: [...] can you remove warnings?
I could, but I did put them there on purpose in the first place - it's to warn plugin authors that their plugin is doing something wrong and they should fix it. The problem here isn't with MCServer, but it's the plugin that's to blame. Ask STR to fix it
Posts: 4,635
Threads: 115
Joined: Dec 2011
Thanks: 695
Given 495 thank(s) in 424 post(s)
05-13-2013, 02:02 AM
(This post was last modified: 05-13-2013, 02:05 AM by NiLSPACE.)
Quote:to avoid server crashes with badly written
plugins.
well i did write it in 3-7 minutes
this is the code i used: function Initialize(Plugin)
PLUGIN = Plugin
Plugin:SetName("PickupFix")
Plugin:SetVersion(1)
PluginManager = cRoot:Get():GetPluginManager()
cPluginManager:Get():AddHook(Plugin, cPluginManager.HOOK_BLOCK_TO_PICKUPS)
LOGINFO("Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion() )
return true
end
function OnBlockToPickups(World, Digger, BlockX, BlockY, BlockZ, BlockType, BlockMeta, Pickups)
Item = Pickups:Get( 0 )
Pickups:Clear()
local Pickup = cItems();
Pickup:Add( Item )
World:SpawnItemPickups( Pickup, BlockX, BlockY, BlockZ, 0, 0, 0 )
end
Posts: 6,485
Threads: 176
Joined: Jan 2012
Thanks: 131
Given 1075 thank(s) in 852 post(s)
Can you send the plugin to me? I'd like to see how it fixes the pickups and maybe fix int in the server itself, so that there's no need for a plugin.
Posts: 4,635
Threads: 115
Joined: Dec 2011
Thanks: 695
Given 495 thank(s) in 424 post(s)
05-13-2013, 02:16 AM
(This post was last modified: 05-13-2013, 02:16 AM by NiLSPACE.)
(05-13-2013, 02:10 AM)xoft Wrote: Can you send the plugin to me? I'd like to see how it fixes the pickups and maybe fix int in the server itself, so that there's no need for a plugin.
https://forum.cuberite.org/attachment.php?aid=282
but what it does is that it calls OnBlockToPickups, it gets all the items from the Pickups object, then clears it and then spawns the item using cWorld::SpawnItemPickups.
Posts: 6,485
Threads: 176
Joined: Jan 2012
Thanks: 131
Given 1075 thank(s) in 852 post(s)
05-13-2013, 02:19 AM
(This post was last modified: 05-13-2013, 02:19 AM by xoft.)
So effectively all it does is reset the velocity parameters to zero. I'll try putting that in the server directly.
Btw, you could have just used this, does the same thing, even better (in case there are 2 or more kinds of pickups):
function OnBlockToPickups(World, Digger, BlockX, BlockY, BlockZ, BlockType, BlockMeta, Pickups)
World:SpawnItemPickups(Pickups, BlockX, BlockY, BlockZ, 0, 0, 0);
Pickups:Clear();
end
|