Welcome to the Builder Academy

Question Freeing dg_events

More
28 Aug 2012 04:34 #749 by zusuk
Freeing dg_events was created by zusuk
I've had a few crashes when killing a mob that has a dg_event attached. It happens rarely, but it happens. Has there been any recorded issues with anyone else? I traced the crash to this part of the code in dg_event.c (which I have never touched):

I'm afraid to say "it could be a stock bug" because my code in general is so heavily modified, but I haven't changed how MOBs die, so I'm a bit puzzled.
Code:
void event_process(void) { struct event *the_event; long new_time; while ((long) pulse >= queue_key(event_q)) { if (!(the_event = (struct event *) queue_head(event_q))) { log("SYSERR: Attempt to get a NULL event"); return; } /* Set the_event->q_el to NULL so that any functions called beneath * event_process can tell if they're being called beneath the actual * event function. */ the_event->q_el = NULL; /* call event func, reenqueue event if retval > 0 */ if ((new_time = (the_event->func)(the_event->event_obj)) > 0) the_event->q_el = queue_enq(event_q, the_event, new_time + pulse); else { if (the_event->isMudEvent && the_event->event_obj != NULL) free_mud_event((struct mud_event_data *) the_event->event_obj); /* It is assumed that the_event will already have freed ->event_obj. */ free(the_event); <------------ } } }

Website
www.luminariMUD.com

Main Game Port
luminariMUD.com:4100

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

More
28 Aug 2012 18:26 #750 by thomas
Replied by thomas on topic Re: Freeing dg_events
Have you gotten a corefile so you have some info on the variables here? It would be real nice to see what the_event actually pointed at, for instance..

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

More
28 Aug 2012 19:12 #751 by Vatiken
Replied by Vatiken on topic Re: Freeing dg_events
Event_process() simply cycles through events and, if ready, fires them off then frees them if necessary. My guess is its attempting to free something that may have been incorrectly freed during the EVENT_FUNC(). That or a corrupted event is being placed in the queue.

tbaMUD developer/programmer

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

More
28 Aug 2012 22:52 #752 by Liko
Replied by Liko on topic Re: Freeing dg_events

zusuk wrote: I've had a few crashes when killing a mob that has a dg_event attached. It happens rarely, but it happens. Has there been any recorded issues with anyone else? I traced the crash to this part of the code in dg_event.c (which I have never touched):

I'm afraid to say "it could be a stock bug" because my code in general is so heavily modified, but I haven't changed how MOBs die, so I'm a bit puzzled.

Code:
void event_process(void) { struct event *the_event; long new_time; while ((long) pulse >= queue_key(event_q)) { if (!(the_event = (struct event *) queue_head(event_q))) { log("SYSERR: Attempt to get a NULL event"); return; } /* Set the_event->q_el to NULL so that any functions called beneath * event_process can tell if they're being called beneath the actual * event function. */ the_event->q_el = NULL; /* call event func, reenqueue event if retval > 0 */ if ((new_time = (the_event->func)(the_event->event_obj)) > 0) the_event->q_el = queue_enq(event_q, the_event, new_time + pulse); else { if (the_event->isMudEvent && the_event->event_obj != NULL) free_mud_event((struct mud_event_data *) the_event->event_obj); /* It is assumed that the_event will already have freed ->event_obj. */ free(the_event); <------------ } } }


Any chance you can catch the crash with gdb?

Randian(0.0.0)
Owner/Developer

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

More
29 Aug 2012 02:49 #756 by Vatiken
Replied by Vatiken on topic Re: Freeing dg_events
I took a peek through tbaMUD to see if perhaps I had forgotten to remove the event from the queue upon a player's death, but everything "seems" to be in working order. So I'm gonna need some more info if I'm going to offer any sort of credible assistance.

Post up some gbd data of the crash, as well as whether or not is was a base DG event or a "mud_event". Assuming it's a mud event, which event is it? I specifically designed the mud event system to be over-informative to help in any sort of diagnostic issue. If you followed the procedure for creating a new event, which I assume you did from a post in a prior thread, you should have given a string name to each event in mud_event.c. You can use this to easily send to a syslog which events are trying to be freed/created/called etc...

tbaMUD developer/programmer

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

Time to create page: 0.200 seconds