- Posts: 345
- Thank you received: 73
Crash In free_list()
- WhiskyTest
-
Topic Author
- Offline
- Platinum Member
-
Less
More
6 years 4 months ago - 6 years 4 months ago #6762
by WhiskyTest
Crash In free_list() was created by WhiskyTest
Hi all,
I have found/created a crash that I'd like to run past the community:
It happened immediately after implementing my points regeneration patch that I posted in the Snippets section (haha yeah I know..)
So the crash happens like this:
Log a character into the Mud and run around a bit - this creates the event to regenerate movement points.
Reconnect to the Mud and log in using the same character, as soon as you enter the password the crash happens.
In this case free_list() is called from free_char(), it's when all the events are being cleaned up. For some reason NULL is being sent to free_list().
And it is here that I made the following change:
This fixes the crash.
So I'm wondering, is skipping free_list(ch->events) in this case OK ? Or am I causing memory troubles further down the road?
If someone could idiot check my thinking here it would be much appreciated :)
I have found/created a crash that I'd like to run past the community:
It happened immediately after implementing my points regeneration patch that I posted in the Snippets section (haha yeah I know..)
So the crash happens like this:
Log a character into the Mud and run around a bit - this creates the event to regenerate movement points.
Reconnect to the Mud and log in using the same character, as soon as you enter the password the crash happens.
free_list (pList=0x0)
free_char (ch=0x601476180)
perform_dupe_check (d=0x601477790)
nanny (d=0x601477790, d@entry=0x601477790, arg=0xffffc480 \"Password1\", arg@entry=0xffffc480 \"Password1\")
game_loop (local_mother_desc=3)
init_game (local_port=4000)
main (argc=1, argv=<optimized out>)
In this case free_list() is called from free_char(), it's when all the events are being cleaned up. For some reason NULL is being sent to free_list().
And it is here that I made the following change:
db.c, free_char() @ line 3222
/* Mud Events */
if (ch->events != NULL) {
if (ch->events->iSize > 0) {
struct event * pEvent;
while ((pEvent = simple_list(ch->events)) != NULL)
event_cancel(pEvent);
}
+ if(ch->events)
free_list(ch->events);
ch->events = NULL;
}
So I'm wondering, is skipping free_list(ch->events) in this case OK ? Or am I causing memory troubles further down the road?
If someone could idiot check my thinking here it would be much appreciated :)
Last edit: 6 years 4 months ago by WhiskyTest.
Please Log in or Create an account to join the conversation.
- WhiskyTest
-
Topic Author
- Offline
- Platinum Member
-
Less
More
- Posts: 345
- Thank you received: 73
6 years 4 months ago #6763
by WhiskyTest
Replied by WhiskyTest on topic Crash In free_list()
Further testing reveals the above changes do NOT fix the crash, they merely delay it.
I get the following warnings immediately before the next crash:
I have undone the changes I made above, and slowly disabled and tested each part of the event regeneration.
I appears that when check_regen_rates() is called and it creates a new event, this will cause the crash if you reconnect while that event is still queued up to fire.
Here is that piece of code:
Hopefully I'm just missing something simple, if anyone has any pointers sing out :D
I get the following warnings immediately before the next crash:
May 22 17:02:53 201 :: WARNING: Attempting to merge iterator to NULL list.
May 22 17:02:53 201 :: WARNING: Attempting to remove iterator from NULL list.
May 22 17:02:53 201 :: WARNING: Attempting to remove contents that don't exist in list.
I have undone the changes I made above, and slowly disabled and tested each part of the event regeneration.
I appears that when check_regen_rates() is called and it creates a new event, this will cause the crash if you reconnect while that event is still queued up to fire.
Here is that piece of code:
void check_regen_rates(struct char_data *ch)
{
int gain = 0;
long time;
/* Incapacitated or worse won't regenerate */
if (GET_POS(ch) < POS_STUNNED)
return;
/* Check movement regeneration */
if (GET_MOVE(ch) < GET_MAX_MOVE(ch))
{
gain = move_gain(ch);
time = (SECS_PER_MUD_HOUR*PASSES_PER_SEC) / (gain ? gain : 1);
/* If there is no eHIT_REGEN create one, otherwise update the existing event with the new time */
if (!char_has_mud_event(ch, eMOVE_REGEN))
NEW_EVENT(eMOVE_REGEN, ch, NULL, time);
else
change_event_duration(ch, eMOVE_REGEN, time);
}
Hopefully I'm just missing something simple, if anyone has any pointers sing out :D
Please Log in or Create an account to join the conversation.
- WhiskyTest
-
Topic Author
- Offline
- Platinum Member
-
Less
More
- Posts: 345
- Thank you received: 73
6 years 4 months ago #6767
by WhiskyTest
Replied by WhiskyTest on topic Crash In free_list()
When a character disconnects and reconnects their events get cleared.
If an event that was created prior to the disconnect then fires, it will crash when trying to free/cancel itself because it's trying to free events from ch that are already free due to the disconnect.
I think.
If an event that was created prior to the disconnect then fires, it will crash when trying to free/cancel itself because it's trying to free events from ch that are already free due to the disconnect.
I think.
Please Log in or Create an account to join the conversation.
- Sascha
-
- Offline
- Elite Member
-
5 years 8 months ago #7451
by Sascha
Will you stand against the coming Storm? After the Breaking: STORMRIDERS MUD - atbmud.dune.net port 4000
Replied by Sascha on topic Crash In free_list()
I just saw this come up here:
Alycia the Trapper leaves east.
i1 510H 110M 92V >
[ WARNING: Attempting to get content from iterator with NULL list. ]
[ WARNING: Attempting to remove iterator from NULL list. ]
i1 510H 110M 92V >
Alycia the Trapper has arrived.
Since I'm running your event regen patch, I think you're on the right track. I haven't crashed yet, though. (knock on wood)
Alycia the Trapper leaves east.
i1 510H 110M 92V >
[ WARNING: Attempting to get content from iterator with NULL list. ]
[ WARNING: Attempting to remove iterator from NULL list. ]
i1 510H 110M 92V >
Alycia the Trapper has arrived.
Since I'm running your event regen patch, I think you're on the right track. I haven't crashed yet, though. (knock on wood)
Will you stand against the coming Storm? After the Breaking: STORMRIDERS MUD - atbmud.dune.net port 4000
Please Log in or Create an account to join the conversation.
- WhiskyTest
-
Topic Author
- Offline
- Platinum Member
-
Less
More
- Posts: 345
- Thank you received: 73
5 years 8 months ago #7453
by WhiskyTest
Replied by WhiskyTest on topic Crash In free_list()
This was only happening in the original event regen which used mud_events.
The patch you have doesn't generate the above warnings.
I am wondering though, Welcor fixed an issue where if a character logs out and back in they get a different pointer. That would explain the crash in the original post. I might revisit the mud_event regen with that fix in place.
Thanks for reminding me :D
The patch you have doesn't generate the above warnings.
I am wondering though, Welcor fixed an issue where if a character logs out and back in they get a different pointer. That would explain the crash in the original post. I might revisit the mud_event regen with that fix in place.
Thanks for reminding me :D
Please Log in or Create an account to join the conversation.
- Sascha
-
- Offline
- Elite Member
-
5 years 8 months ago #7456
by Sascha
Will you stand against the coming Storm? After the Breaking: STORMRIDERS MUD - atbmud.dune.net port 4000
Replied by Sascha on topic Crash In free_list()
Awesome, thanks for the updated info regarding the current patch!
Will you stand against the coming Storm? After the Breaking: STORMRIDERS MUD - atbmud.dune.net port 4000
Please Log in or Create an account to join the conversation.
Time to create page: 0.117 seconds