Welcome to the Builder Academy

Question tba having "Heart Attacks" - signal 10, Bus error

More
11 Feb 2016 05:12 - 11 Feb 2016 22:14 #5586 by krell
I know other people running tba on other platforms have also had trouble with this. I've done something which seems to be working, at least with tba running on OpenBSD, by making a small modification in dg_triggers.c.

Code:
void timer_otrigger(struct obj_data *obj) { trig_data *t; if (!SCRIPT_CHECK(obj, OTRIG_TIMER)) return; for (t = TRIGGERS(SCRIPT(obj)); t; t = t->next) { if (TRIGGER_CHECK(t, OTRIG_TIMER)) { script_driver(&obj, t, OBJ_TRIGGER, TRIG_NEW); + break; } } - return; }

Hopefully someone finds this helpful.
Last edit: 11 Feb 2016 22:14 by krell. Reason: putting the question mark in title that should have been there in the firstly damn place

Please Log in or Create an account to join the conversation.

More
11 Feb 2016 21:58 #5587 by thomas
doesn't this prevent you from having multiple timer triggers on one entity?

Please Log in or Create an account to join the conversation.

More
11 Feb 2016 22:06 - 11 Feb 2016 22:16 #5588 by krell
I haven't tried that. Also my title was supposed to say " - Resolved?" as in I was asking for input and not making a definite claim.

I'll have to try it when I get the chance. Would it have been better to put the return statement where I put the break statement or would that cause the same issue?
Last edit: 11 Feb 2016 22:16 by krell. Reason: putting question mark in title...again.

Please Log in or Create an account to join the conversation.

More
11 Feb 2016 22:44 #5589 by thomas
I think that would have the same consequences.

I also think that the fact that this solves the problem means the bug is caused by changing the object pointer.

Since it's passed by pointer-to-pointer, the call to script_driver may actually change the obj-pointer here. Which in turn causes the next loop iteration to be handling garbage - which then in turn causes a crash.

will this work?
Code:
void timer_otrigger(struct obj_data *obj) { trig_data *t; + obj_data *tmp = obj; if (!SCRIPT_CHECK(obj, OTRIG_TIMER)) return; for (t = TRIGGERS(SCRIPT(obj)); t; t = t->next) { + if (obj != tmp) { + // log that we hit a problem + break; + } if (TRIGGER_CHECK(t, OTRIG_TIMER)) { script_driver(&obj, t, OBJ_TRIGGER, TRIG_NEW); } } return; }

That last "return;" is optional, by the way. You can remove it with no bad effects.

Please Log in or Create an account to join the conversation.

More
11 Feb 2016 22:46 #5590 by thomas
Actually, t->next also could point to garbage - if the object has been free'd, so would the triggers be.

Please Log in or Create an account to join the conversation.

More
11 Feb 2016 23:41 #5591 by krell
I'll try that code out when I get the chance, hopefully tonight. I'll post my results when I do.

Please Log in or Create an account to join the conversation.

Time to create page: 0.196 seconds