• 0
Co0L

open crashcore

Question

Hello m2dev , i am working on my server and i solved a lot in it but with this problem i need some help .

I don't know how to make this crashcore or when it happens and i don't have any idea of what is wrong.

 

Here are the crashcore details:

https://gyazo.com/d5389b58387bc32da6992095e06561f2

 

clearitem function:

 

void CHARACTER::ClearItem()
{
	int		i;
	LPITEM	item;
	
	for (i = 0; i < INVENTORY_AND_EQUIP_SLOT_MAX; ++i)
	{
		if ((item = GetInventoryItem(i)))
		{
			item->SetSkipSave(true);
			ITEM_MANAGER::instance().FlushDelayedSave(item);

			item->RemoveFromCharacter();
			M2_DESTROY_ITEM(item);

			SyncQuickslot(QUICKSLOT_TYPE_ITEM, i, 255);
		}
	}
	for (i = 0; i < DRAGON_SOUL_INVENTORY_MAX_NUM; ++i)
	{
		if ((item = GetItem(TItemPos(DRAGON_SOUL_INVENTORY, i))))
		{
			item->SetSkipSave(true);
			ITEM_MANAGER::instance().FlushDelayedSave(item);

			item->RemoveFromCharacter();
			M2_DESTROY_ITEM(item);
		}
	}
}

 

and destroy function:

void ITEM_MANAGER::DestroyItem(LPITEM item)
{
	if (item->GetSectree())
		item->RemoveFromGround();

	if (item->GetOwner())
	{
		if (CHARACTER_MANAGER::instance().Find(item->GetOwner()->GetPlayerID()) != NULL)
		{
			sys_err("DestroyItem: GetOwner %s %s!!", item->GetName(), item->GetOwner()->GetName());
			item->RemoveFromCharacter();
		}
		else
		{
			sys_err ("WTH! Invalid item owner. owner pointer : %p", item->GetOwner());
		}
	}

	TR1_NS::unordered_set<LPITEM>::iterator it = m_set_pkItemForDelayedSave.find(item);

	if (it != m_set_pkItemForDelayedSave.end())
		m_set_pkItemForDelayedSave.erase(it);

	DWORD dwID = item->GetID();
	sys_log(2, "ITEM_DESTROY %s:%u", item->GetName(), dwID);

	if (!item->GetSkipSave() && dwID)
	{
		DWORD dwOwnerID = item->GetLastOwnerPID();

		db_clientdesc->DBPacketHeader(HEADER_GD_ITEM_DESTROY, 0, sizeof(DWORD) + sizeof(DWORD));
		db_clientdesc->Packet(&dwID, sizeof(DWORD));
		db_clientdesc->Packet(&dwOwnerID, sizeof(DWORD));
	}
	else
	{
		sys_log(2, "ITEM_DESTROY_SKIP %s:%u (skip=%d)", item->GetName(), dwID, item->GetSkipSave());
	}

	if (dwID)
		m_map_pkItemByID.erase(dwID);

	m_VIDMap.erase(item->GetVID());
	M2_DELETE(item);
}
 
any idea is welcome , thank you for your time.

Share this post


Link to post
Share on other sites

16 answers to this question

  • 0

it was deleted on clear.sh , i will post it when the server will make the crashcore again

Share this post


Link to post
Share on other sites
  • 0

You logged out with an item bugged in your inventory.

Bugged I mean the item is bad setted in the item_proto sql.

 

Doesn't matter the clear function problem is your item.

  • Like 1

Share this post


Link to post
Share on other sites
  • 0

The crash occured after a disconnect as you can see in the bt, the Disconnect() method and the ~CHARACTER destructor are called, for what i can see there's no problem with ClearItems() and DestroyItem(), post your CHARACTER::Destroy() method maybe there are more clues on what happened. It might be a double deletion of something since you get undefined behaviour if you try to delete an object through a pointer more that once. But the pointers in func args seem ok they don't look like bogus pointers.

Or maybe @WeedHex is right and you got db incosistencies.

  • Like 1

Share this post


Link to post
Share on other sites
  • 0
void CHARACTER::Destroy()
{
    CloseMyShop();

    if (m_pkRegen)
    {
        if (m_pkDungeon) {
            if (m_pkDungeon->IsValidRegen(m_pkRegen, regen_id_)) {
                --m_pkRegen->count;
            }
        } else {
            if (is_valid_regen(m_pkRegen))
                --m_pkRegen->count;
        }
        m_pkRegen = NULL;
    }

    if (m_pkDungeon)
    {
        SetDungeon(NULL);
    }

#ifdef __PET_SYSTEM__
    if (m_petSystem)
    {
        m_petSystem->Destroy();
        delete m_petSystem;

        m_petSystem = 0;
    }
#endif

#ifdef ENABLE_MOUNT_COSTUME_SYSTEM
    if (m_mountSystem)
    {
        m_mountSystem->Destroy();
        delete m_mountSystem;
        m_mountSystem = 0;
    }
    
    if(GetMountVnum())
    {
        RemoveAffect(AFFECT_MOUNT);
        RemoveAffect(AFFECT_MOUNT_BONUS);
    }
#endif

    HorseSummon(false);

    if (GetRider())
        GetRider()->ClearHorseInfo();

    if (GetDesc())
        GetDesc()->BindCharacter(NULL);

    if (m_pkExchange)
        m_pkExchange->Cancel();

    SetVictim(NULL);

    if (GetShop())
    {
        GetShop()->RemoveGuest(this);
        SetShop(NULL);
    }

    ClearStone();
    ClearSync();
    ClearTarget();

    if (NULL == m_pkMobData)
    {
        DragonSoul_CleanUp();
        ClearItem();
    }

    LPPARTY party = m_pkParty;
    if (party)
    {
        if (party->GetLeaderPID() == GetVID() && !IsPC())
        {
            M2_DELETE(party);
        }
        else
        {
            party->Unlink(this);

            if (!IsPC())
                party->Quit(GetVID());
        }

        SetParty(NULL);
    }

    if (m_pkMobInst)
    {
        M2_DELETE(m_pkMobInst);
        m_pkMobInst = NULL;
    }

    m_pkMobData = NULL;

    if (m_pkSafebox)
    {
        M2_DELETE(m_pkSafebox);
        m_pkSafebox = NULL;
    }

    if (m_pkMall)
    {
        M2_DELETE(m_pkMall);
        m_pkMall = NULL;
    }

    m_set_pkChrSpawnedBy.clear();
    StopMuyeongEvent();
    event_cancel(&m_pkWarpNPCEvent);
    event_cancel(&m_pkRecoveryEvent);
    event_cancel(&m_pkDeadEvent);
    event_cancel(&m_pkSaveEvent);
    event_cancel(&m_pkTimedEvent);
    event_cancel(&m_pkStunEvent);
    event_cancel(&m_pkFishingEvent);
    event_cancel(&m_pkPoisonEvent);
    event_cancel(&m_pkFireEvent);
    event_cancel(&m_pkPartyRequestEvent);
    event_cancel(&m_pkWarpEvent);
    event_cancel(&m_pkCheckSpeedHackEvent);
    event_cancel(&m_pkMiningEvent);

    for (itertype(m_mapMobSkillEvent) it = m_mapMobSkillEvent.begin(); it != m_mapMobSkillEvent.end(); ++it)
    {
        LPEVENT pkEvent = it->second;
        event_cancel(&pkEvent);
    }
    
    m_mapMobSkillEvent.clear();
    ClearAffect();

    for (TMapBuffOnAttrs::iterator it = m_map_buff_on_attrs.begin();  it != m_map_buff_on_attrs.end(); it++)
    {
        if (NULL != it->second)
        {
            M2_DELETE(it->second);
        }
    }
    m_map_buff_on_attrs.clear();

    event_cancel(&m_pkDestroyWhenIdleEvent);

    if (m_pSkillLevels)
    {
        M2_DELETE_ARRAY(m_pSkillLevels);
        m_pSkillLevels = NULL;
    }

    CEntity::Destroy();

    if (GetSectree())
        GetSectree()->RemoveEntity(this);
    
#ifdef ENABLE_SYNC_HACK_FIX
    sync_hack = 0;
    sync_count = 0;
    sync_time = 0;
#endif
}

 

Share this post


Link to post
Share on other sites
  • 0

I can't see anything wrong neither in this function, so probably you should check your db item_proto entries as suggested (you can also have a sys_err("deleting %d", item->GetVnum()) at the beginning of your DestroyItem() function, after /ip or /ipurge command load your character, with your latest item_proto entries (most likely there's nothing wrong with vanilla items) and then disconnect, if you get a core again you can check which item caused it in your sys_err since it will be last line before crash).

Share this post


Link to post
Share on other sites
  • 0

i found this in syserr

 

DestroyItem: WTH! Invalid item owner. owner pointer : 0x32e92000

 

Share this post


Link to post
Share on other sites
  • 0

Find the dwID of the item in your database, maybe is still there.

 

-Error with inventory cells

-Error on the item_proto (wronge size etc.)

-Other...

  • Like 1

Share this post


Link to post
Share on other sites
  • 0
Quote

Find the dwID of the item in your database, maybe is still there.

 

-Error with inventory cells

-Error on the item_proto (wronge size etc.)

-Other...

run this query in player db and report the results:
SELECT * FROM player.item WHERE id = 10019575;

according to bt thats the ID of the item that crashes core when you try to remove it.

  • Like 1

Share this post


Link to post
Share on other sites
  • 0

the object in your bag or game is not in the memory of the server or any machine. That's why your kernel crashes. Assumes it has been deleted for review in the server's memory.

I had the same problem and fixed it.

Share this post


Link to post
Share on other sites
  • 0

The problem is that the item is deleted immediately after the crash and I can't figure out what's wrong with it..

  • Haha 1

Share this post


Link to post
Share on other sites
  • 0

You can try and add the following to get more debug info on what item you actually have here.

Change:

sys_err ("WTH! Invalid item owner. owner pointer : %p", item->GetOwner());

 

to:

sys_err ("WTH! Invalid item owner. %d owner pointer : %p", item->GetVnum(), item->GetOwner());

 

This should print out the vnum that's causing problems. Additionally, if you wanna try to make it crash-safe you'd return the function after it raises such an error. Though that could cause undefined behavior, so be careful with that.

Actually a missing owner is not the problem here. I think your core crashes when it tries to access a wrong pointer to your item. In short: It tries to access invalid memory. Thus leading to the crash. Please look at char_item.cpp on line 550 and tell us what this line exactly is, so we can see what's getting called exactly that causes the crash.

Share this post


Link to post
Share on other sites
  • 0

I said the problem, do not discuss the problem in vain.

Problem: Your inventory or market or trade or almost any object is not in memory. The core crashes because it is not in memory.
You cannot use the object that is not in memory in your bag or anywhere.

First of all, the object must be in memory.

Share this post


Link to post
Share on other sites
  • 0

I think i solved it , i was using in shop.cpp autogiveitem() instead of createitem() when buy an item cause i made a multi buy system and i think that was the problem , the server wasn't saving the items correctly.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.