View unanswered posts | View active topics It is currently Wed Dec 25, 2024 6:29 pm



Reply to topic  [ 6 posts ] 
 How to debug a full crash? 
Author Message
User avatar

Joined: Fri Aug 19, 2011 4:02 pm
Posts: 40
Reply with quote
Post 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.


Sat Aug 05, 2017 11:59 pm
Profile WWW

Joined: Fri Sep 10, 2010 1:48 am
Posts: 666
Location: Halifax, Canada
Reply with quote
Post 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.


Thu Aug 10, 2017 4:49 am
Profile
User avatar

Joined: Fri Aug 19, 2011 4:02 pm
Posts: 40
Reply with quote
Post 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


EDIT:
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.


Last edited by The5 on Tue Aug 15, 2017 7:53 pm, edited 1 time in total.



Tue Aug 15, 2017 6:51 pm
Profile WWW
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post 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.


Tue Aug 15, 2017 7:37 pm
Profile
User avatar

Joined: Fri Aug 19, 2011 4:02 pm
Posts: 40
Reply with quote
Post 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 self.target ~= 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.


Tue Aug 15, 2017 8:03 pm
Profile WWW
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post 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()


Tue Aug 15, 2017 8:47 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.223s | 14 Queries | GZIP : Off ]