Data Realms Fan Forums

How to debug a full crash?
Page 1 of 1

Author:  The5 [ Sat Aug 05, 2017 11:59 pm ]
Post subject:  How to debug a full crash?

I can reproduce the crash... 50/50 chance it seems.
But how would i go about finding what function call causes it?

Putting prints before everything and subsequently narrowing down the line in question, trying to keep the console open so you see when it happens?

I suspect the use of MOSRotating.SetObjectValue() in a guns script and then in the projectiles on create() MOSRotating.GetObjectValue() and then querying the target information might be related to the crash. Since the crash appears to occur once the actor the projectile is fired at dies.
So something with looking up the c++ values behind that lua table might cause it, once that c++ object is gone.

If you got any experience with dealing with such hard crashes, let me know.
At this point I have not even found any log file locations or such that might help.

Author:  Bad Boy [ Thu Aug 10, 2017 4:49 am ]
Post subject:  Re: How to debug a full crash?

Haven't used getting and setting object values since they weren't around when I was still modding cc actively, but in general you're correct - hard crashes are caused by trying to run a C++ function on an object that doesn't exist anymore.
For what it's worth, you can call ConsoleMan:SaveAllText("SomeFileNameHere.txt") to save everything in the console at any time. You might be able to use this to have a better time with your prints by saving your console often and seeing exactly where things stop working.

Author:  The5 [ Tue Aug 15, 2017 6:51 pm ]
Post subject:  Re: How to debug a full crash?

Same here, I actively modded 6 years ago.
Good call on the saving to text file, i was unsing this before in the console, didn't think about using it in the script.

Though, i would effectively have to put it into "every line" for the time being to figure it out.

155 views by now, no Dev around to chime in? All busy with Planetoid Pioneers huh? :P

Sadly the log saving does not appear to work. Naturally I suppose, since the crash also prevents the saving/closing of the file stream.

Printing to the console is not helping either, the last line that appears is the print at the very end of the update method of the projectile.

Author:  CaveCricket48 [ Tue Aug 15, 2017 7:37 pm ]
Post subject:  Re: How to debug a full crash?

Not sure if the majority of the dev team has a DRLFF account at this point.

Probably not too helpful, but determine what actions cause the crash (seems like you have it 50/50, which is good). Once you can isolate the chain of events that lead to the crash, comment out chunks of your script. Determine what chunks don't crash, and what chunks do crash. Slowly comment in/out parts within the crashing chunk until you figure out what specific line the issue is.

Pretty brute force, but it'll find the issue.

Author:  The5 [ Tue Aug 15, 2017 8:03 pm ]
Post subject:  Re: How to debug a full crash?

Yep, commenting out proves a bit difficult though.
The script basically goes like this.

in Weapon.Update()
1.) get object pointed at
2.) self.SetObjectValue("target", object)

in Projectile.Create()
3.) get weapon (weapon closest to projectile on spawning)
4.) get weapon.GetObjectValue("target")

in Projectile.Update()
5.) if ~= nil
6.) get target.pos
7.) adjust velocity to reach target
8.) --- last debug print is at the very end of this update(), not in weapon update() ---

So, I can only really comment out the adjust velocity and get target pos parts before nothing actually happens anymore.
And since the crash happens when the target dies it its most likely related to the get target pos part.
Yet, to the best of my knowledge I check all cases where it might become nil in lua. And if not I would get a lua error trying to access pos.
The strange thing is that I still reach that last print too. So the point where it crashes appears to actually be past my scripts scope.

I know there is other ways to make homing projectiles, but the point here is actually writing a tiny library of helper functions to utilize the SetObjectValue/GetObjectValue methods. Streamlining the creation of a homing weapon is just the usecase.

Author:  CaveCricket48 [ Tue Aug 15, 2017 8:47 pm ]
Post subject:  Re: How to debug a full crash?

I don't remember if a pointer to a dead MO is actually nil. You should check if the id is 255 to see if it's dead (or whatever the check-if-MO-is-dead function is if you want) (assuming the MO was GetsHitByMOs = 1 in the first place) or IsActor() if your targets are specifically actors.

Edit: Typo. Meant IsActor(), not ToActor()

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group