Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash during startup garbage collector when spawned npc memory is mislinked #1362

Open
mtwango opened this issue Dec 27, 2024 · 4 comments
Open

Comments

@mtwango
Copy link
Contributor

mtwango commented Dec 27, 2024

When Sphere is starting, world and characters are loaded and Garbage Collector starts, if spawned NPC has memory item, that should be linked to spawn (or anything existing really) is mislinked (link ID doesn't exists), Sphere crashes without error and without any info in logs.

It used to work in rev 3720 it printed debug log and critical error (no id or anything usefull actually), but rev 3882 / 3888 crashes silently.

rev 3720 log:
obrazek

Expected behaviour would be logging item id with wrong link and removing it during GC (and maybe remove container for this memory, if it is npc?)

@Jhobean
Copy link
Contributor

Jhobean commented Dec 28, 2024

Could be link to #1307

@mtwango
Copy link
Contributor Author

mtwango commented Jan 2, 2025

I was able to track this error here:

CCSpawn *pSpawn = static_cast<CCSpawn*>(m_uidLink.ItemFind()->GetComponent(COMP_SPAWN));

The m_uidLink.ItemFind() returns null pointer, which would be the reason for crash, since it can call GetComponent(COMP_SPAWN) on that.

Fixing it should be something like checking for valid return from ItemFind(). I'm not sure if code bellow is production ready, but I was able to pass GC.

CItem *pItemDef = m_uidLink.ItemFind();
if (pItemDef == nullptr)
{
    // return some error code here.
}

CCSpawn *pSpawn = static_cast<CCSpawn*>(pItemDef->GetComponent(COMP_SPAWN));

@Jhobean
Copy link
Contributor

Jhobean commented Jan 2, 2025

What about just add this
Does it fixe?

if (pItemDef == nullptr)
	return nullptr;

@mtwango
Copy link
Contributor Author

mtwango commented Jan 2, 2025

It should return integer (int CItemMemory::FixWeirdness()). I was returning 0 to pass it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants