Welcome to the Builder Academy

Question Event Cancel Crash

More
18 Jun 2014 05:03 #4923 by WhiskyTest
Hi all!

I have a crash challenge that I would welcome some help with :)

Platform: Windows7 Cygwin
Source: tbaMUD 3.65
Changes: snippet for event driven point regeneration : Event Regen (but updated to use the mud_event system that Vatican added to stock)

The regeneration appears to work in-game just fine until:
A player with less than full hitpoints dies or quits. That is when the MUD crashes, the GDB output is below.

If a player quits with full health, but less than full Mana or Move the MUD is fine.

Mobs can be killed without crashes.

I haven't used the debugger before but hopefully this output might give someone a clue as to where I should be looking :)

Jun 18 16:54:36 :: Entering game loop.
Jun 18 16:54:36 :: No connections. Going to sleep.
[New Thread 5972.0x2234]
Jun 18 16:54:46 :: New connection. Waking up.
[New Thread 5972.0x2130]
Jun 18 16:54:48 :: Test has connected.
Jun 18 16:54:49 :: Test had no variable file
Jun 18 16:54:49 :: Test un-renting and entering game.
Jun 18 16:54:49 :: Test (level 1) has 0 object (max 30).
Jun 18 16:55:00 :: Test killed by the Black Rook at A Black Square

Program received signal SIGABRT, Aborted.
event_cancel (event=0x0) at dg_event.c:89
89 if (event->event_obj)
(gdb) bt
#0 event_cancel (event=0x0) at dg_event.c:89
#1 0x00000000000000b0 in ?? ()
#2 0xffffffffdc3cba00 in ?? ()
#3 0x0000000000000048 in ?? ()
#4 0x0000000100000001 in ?? ()
#5 0x0000000000000000 in ?? ()
(gdb) info local
No locals.
(gdb) list
84 if (!event->q_el) {
85 log("SYSERR: Attempted to cancel a non-NULL unqueued event, freeing anyway");
86 } else
87 queue_deq(event_q, event->q_el);
88
89 if (event->event_obj)
90 cleanup_event_obj(event);
91
92 free(event);
93 }
(gdb) print event
$1 = (struct event *) 0x0
(gdb) print event_q
$2 = (struct dg_queue *) 0x60004f2c0
(gdb) print event->q_el
Cannot access memory at address 0x10
(gdb) print event_q
$3 = (struct dg_queue *) 0x60004f2c0
(gdb)


I've also attached the regen.c file with the events re-written so you can see what is going on in there.

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

More
18 Jun 2014 07:13 #4924 by thomas
Replied by thomas on topic Event Cancel Crash
Can't seem to see the regen.c file. Anyway, your event is NULL. Maybe add a null-check to the beginning of event_cancel() as a stop-gap measure.
To me it seems as if you're calling event_cancel twice on the same list.

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

More
18 Jun 2014 22:41 - 18 Jun 2014 22:44 #4925 by WhiskyTest
Replied by WhiskyTest on topic Event Cancel Crash
Oh it didn't attach, I'm doing something wrong lol, try this link:
Link to Regen.C


I think you are right with the doubling on event cancels, this is the event_cancel code, it's just from stock 3.65


Code:
void event_cancel(struct event *event) { if (!event) { log("SYSERR: Attempted to cancel a NULL event"); return; } if (!event->q_el) { log("SYSERR: Attempted to cancel a non-NULL unqueued event, freeing anyway"); } else queue_deq(event_q, event->q_el); if (event->event_obj) cleanup_event_obj(event); free(event); }
Last edit: 18 Jun 2014 22:44 by WhiskyTest. Reason: attachment not working

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

More
19 Jun 2014 09:20 #4926 by thomas
Replied by thomas on topic Event Cancel Crash
Hmm. So there's already a check for that NULL.

I notice you've made som changes to alter_hit that aren't in the other alter_* functions:
Code:
void alter_hit(struct char_data *ch, int amount) { int gain; gain = hit_gain(ch); gain = (PULSES_PER_MUD_HOUR / (gain ? gain : 1)); GET_HIT(ch) = MIN(GET_HIT(ch) - amount, GET_MAX_HIT(ch)); /* if (!char_has_mud_event(ch, eHIT_REGEN) && (GET_HIT(ch) < GET_MAX_HIT(ch))) { gain = hit_gain(ch); NEW_EVENT(eHIT_REGEN, ch, NULL, PULSES_PER_MUD_HOUR / (gain ? gain : 1)); }*/ /* Each time you take damage the timer is reset */ if (GET_HIT(ch) < GET_MAX_HIT(ch) && char_has_mud_event(ch, eHIT_REGEN)) change_event_duration(ch, eHIT_REGEN, gain); else if (GET_HIT(ch) < GET_MAX_HIT(ch)) NEW_EVENT(eHIT_REGEN, ch, NULL, gain); update_pos(ch); }
If you switch back, does this fix the issue?
How does change_event_duration look (is it stock)?

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

More
19 Jun 2014 20:00 #4927 by WhiskyTest
Replied by WhiskyTest on topic Event Cancel Crash
I redid the alter_hit and the EVENTFUNC for hit regen to look exactly like the mana/move ones, but the crash persists.

I feel it's a bit over my head at the moment so I put the code in with the original struct changes and event cancels that are in the patch file. This works fine.

I'm almost tempted to blame strange Windows/Cygwin things that perhaps wouldn't be an issue on a Linux copy. In fact what I might do is make a CentOS virtual machine and see if I can replicate the crash..

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

Time to create page: 0.338 seconds