If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Evil crash bites my butt again

But this time I found a script that actually trigger it rather easily...

function OnInit() //run upon initialization
end

function OnPostInit() //run during the entity's first logic update
thisMap = this:GetMap();
--if --thisMap == GetMapManager:GetActiveMap() and
--not thisMap:GetName() == "Gui_Stuff" then
SpawnDefaultGui(); -- I am using a function in case I decide to support multiple GUIs
--end
end

function safe_delete(entity)
if entity then entity:SetDeleteFlag(true); end
end

First, the "safe_delete" is totally non-safe, because it generate a error when entity is nil "big_bar does not exist"

Anyway, it sorta worked, but as soon as I delete some object and re-loaded the script, the engine crashed...

The same crash as the mentioned "random" crash in other topic.

I realized that the engine hates when you call SetDeleteFlag(true) twice, it plainly crashes sometimes when you do that... So, there are a way to fix any of the issues I mentioned here? Including a way to allow me to "delete" stuff that is not even created yet?

The game is not frequently crashing, it crashes when closing, it crashes when unloading a map, it crashes when manipulating Watch Manager, and so on...

But in all crashes, no matter how the stack trace looks (sometimes it look wildly different) one line is ALWAYS present:

sig_delete(m_ID); (BaseGameEntity.cpp line 52)

This is greatly bothering me, obviously the deleteflag thing is deleting invalid stuff, but I am not figuring how to figure if something is valid or not (specially because m_ID is a int, not a pointer, thus I cannot just verify if m_ID is valid or not).

Hey Speeder, I'm back at the computer in IRC if you want to try again there btw..

I think you are using Novashell in a way that I didn't plan, because the examples don't seem to have this problem.

Is it possible for you to make a tiny test project that shows the error and attach it? If so I'd be glad to take a look at it. This test should cause the crash on my version of Novashell. (if it doesn't, it might point to a chance you made as the culprit)

But this does not guarantee you won't trigger this bug by accident in other manner.

The other solution is somehow prevent any call to SetDeleteFlag on a non-existing object, on C++ calls this is done (you check if the pointer is null), but on Lua it blindly calls the method...

I thought of many possibilities, but I could not figure a way to prevent a dangling pointer on Lua to call a method of a non-existing thing, at least not without causing a error message.

EDIT: I am not hanging on IRC because someone on Ludumdare dislike me, and keep complaining to ops (even of other channels), once even I said something on Ludumdare that a op in Gamedev disagreed, and I got banned from there... Since Afternet banned msot of IPs of my country, I won't go to the hassle of getting on Afternet to get banned on Ludumdare or Gamedev because of some guy that never cared to show himself.