23 Jul, 2012, arholly wrote in the 1st comment:
Votes: 0
Hi there:
I've noticed that I am crashing on shutdown and cannot figure out why. I get two different core files usually when I do, each one showing a different error.
Program received signal SIGSEGV, Segmentation fault.
aggr_update () at update.c:1502
1502 wch_next = wch->next;
(gdb) bt
#0 aggr_update () at update.c:1502
#1 0x0810a387 in update_handler () at update.c:1708
#2 0x08092276 in game_loop_unix (control=8) at comm.c:1075
#3 0x08092b81 in main (argc=1701147238, argv=0xbfffd824) at comm.c:674
(gdb) frame 0
#0 aggr_update () at update.c:1502
1502 wch_next = wch->next;
(gdb) list
1497 CHAR_DATA *vch_next;
1498 CHAR_DATA *victim;
1499
1500 for ( wch = char_list; wch != NULL; wch = wch_next )
1501 {
1502 wch_next = wch->next;
1503 if ( IS_NPC(wch)
1504 || wch->trust >= LEVEL_IMMORTAL
1505 || wch->in_room == NULL
1506 || wch->in_room->area->empty
(gdb) info locals
wch = 0x616d2065
wch_next = 0x616d2065
ch = 0x8
ch_next = 0xbfffd578
vch = 0x8088ebf
vch_next = 0x8355579
victim = 0x8355479
(gdb) frame 1
#1 0x0810a387 in update_handler () at update.c:1708
1708 aggr_update( );
(gdb) list
1703 {
1704 run_election();
1705 }
1706 */
1707
1708 aggr_update( );
1709 game_update( );
1710 tail_chain( );
1711 return;
1712 }
(gdb) info locals
pulse_area = 429
pulse_mobile = 13
pulse_violence = 21
pulse_time = 189
pulse_point = 189
pulse_msdp = 1
(gdb)

the other:
Program received signal SIGSEGV, Segmentation fault.
0x08060df2 in find_croupier_game (game=0x81fab08) at act_move.c:5249
5249 if(croupier->game == game)
(gdb) bt
#0 0x08060df2 in find_croupier_game (game=0x81fab08) at act_move.c:5249
#1 0x08061a64 in blackjack_update (game=0x81fab08) at act_move.c:5723
#2 0x08109d30 in game_update () at update.c:488
#3 0x0810a44c in update_handler () at update.c:1709
#4 0x080922b6 in game_loop_unix (control=8) at comm.c:1075
#5 0x08092bc1 in main (argc=Cannot access memory at address 0x6b
) at comm.c:674
(gdb) frame 0
#0 0x08060df2 in find_croupier_game (game=0x81fab08) at act_move.c:5249
5249 if(croupier->game == game)
(gdb) list
5244 if(game == NULL)
5245 return NULL;
5246
5247 for(croupier = char_list;croupier != NULL;croupier = croupier->next_in_room)
5248 {
5249 if(croupier->game == game)
5250 {
5251 return croupier;
5252 }
5253 }
(gdb) info locals
croupier = 0xf1
(gdb) frame 1
#1 0x08061a64 in blackjack_update (game=0x81fab08) at act_move.c:5723
5723 CHAR_DATA *croup = find_croupier_game(game);
(gdb) list
5718 }
5719
5720 void blackjack_update(GAME_DATA *game)
5721 {
5722 int i, playercount = 0, dealerhand, playerhand;
5723 CHAR_DATA *croup = find_croupier_game(game);
5724
5725 if(croup == NULL) return; /* Handling using same data type/set for index */
5726
5727 if(game->start_timer > 0) game->start_timer–;
(gdb) info locals
i = <value optimized out>
playercount = <value optimized out>
dealerhand = 137727424
playerhand = <value optimized out>
croup = 0x0
(gdb) frame 2
#2 0x08109d30 in game_update () at update.c:488
488 blackjack_update(game);
(gdb) list
483
484 for(game = game_list; game != NULL; game = game_next)
485 {
486 game_next = game->next;
487 if(!str_cmp(game->name, "blackjack"))
488 blackjack_update(game);
489 }
490 }
491
492
(gdb) info locals
game = 0x81fab08
game_next = 0x0
__FUNCTION__ = "game_update"
(gdb) frame 3
#3 0x0810a44c in update_handler () at update.c:1709
1709 game_update( );
(

Can anyone help?
Arholly
23 Jul, 2012, Kline wrote in the 2nd comment:
Votes: 0
First one: What is in wch? Your wch and wch_next are the same memory address (0x616d2065). Is it actually a valid character? Print it and see.
Second one: Croupier looks invalid given its memory address of 0xf1. Has it already been freed, or not allocated yet?
23 Jul, 2012, arholly wrote in the 3rd comment:
Votes: 0
Kline said:
First one: What is in wch? Your wch and wch_next are the same memory address (0x616d2065). Is it actually a valid character? Print it and see.
Second one: Croupier looks invalid given its memory address of 0xf1. Has it already been freed, or not allocated yet?

How do I do the print for the first one? I've never used that command before.
24 Jul, 2012, arholly wrote in the 4th comment:
Votes: 0
Is that what you mean:
(gdb) print/c wch_next
$2 = 4 '\004'
(gdb) print/c wch->next
Cannot access memory at address 0x6c690004
(gdb)
24 Jul, 2012, Kline wrote in the 5th comment:
Votes: 0
arholly said:
How do I do the print for the first one? I've never used that command before.


Working from memory, so this may be incorrect, but you need to cast the pointer to what it is and print that (so print knows what data structure to use to figure out how to show you the data). So, try print (CHAR_DATA*)wch. Also, set print pretty beforehand helps and will give you a more readable output (with fancy things like linebreaks).
24 Jul, 2012, arholly wrote in the 6th comment:
Votes: 0
(gdb) print (CHAR_DATA*)wch
$1 = (CHAR_DATA *) 0x6c690004
(gdb) print (CHAR_DATA*)wch_next
$2 = (CHAR_DATA *) 0x6c690004
(gdb) print (CHAR_DATA*)wch->next

That's what I got.
25 Jul, 2012, Kline wrote in the 7th comment:
Votes: 0
Yeah I had it wrong from memory, you need to defreference it to print it: print *wch

Have you read the Gammon Guide to GDB? You should if you haven't, very useful info that covers this and more.
25 Jul, 2012, Lyanic wrote in the 8th comment:
Votes: 0
I don't know this is the case here, as I haven't even bothered to look at the gdb output…..but more often than not, when you have a crash on shutdown, it's due to freeing the same memory twice.
25 Jul, 2012, arholly wrote in the 9th comment:
Votes: 0
No, I've not read Gammon's guide, I will though. I got this:
Quote
Log Rayal: shutdown
Closing link to Rayal.

Program received signal SIGSEGV, Segmentation fault.
aggr_update () at update.c:1502
1502 wch_next = wch->next;
(gdb) print *wch
Cannot access memory at address 0x6c690004
(gdb) print/c *wch
Cannot access memory at address 0x6c690004
(gdb)
25 Jul, 2012, Kline wrote in the 10th comment:
Votes: 0
Lyanic said:
I don't know this is the case here, as I haven't even bothered to look at the gdb output…..but more often than not, when you have a crash on shutdown, it's due to freeing the same memory twice.

arholly said:
Log Rayal: shutdown
Closing link to Rayal.

Program received signal SIGSEGV, Segmentation fault.
aggr_update () at update.c:1502
1502 wch_next = wch->next;
(gdb) print *wch
Cannot access memory at address 0x6c690004
(gdb) print/c *wch
Cannot access memory at address 0x6c690004
(gdb)


Seems about right. You need to breakpoint in that loop and see where and why you are iterating over a wch that has already been freed or is otherwise invalid.
0.0/10