Reconnecting characters causes a crash?

Hi everyone! I’ve resurrected my old dear MUD, corrected all the syntax errors and warnings and it is up and stable… that is, until someone tries to reconnect to an existing session. After being prompted if they want to reconnect, everything goes down. I’m just starting my journey into competency with coding, so if there is more information that is needed, I’m happy to provide it, or a better way to troubleshoot it, I’m all ears.
Line 2992 of db.c is a part of the alloc_mem function, which I can’t imagine is actually the culprit.

GDB:

Wed May 29 11:06:32 2019 :: ROM is ready to rock on port 9000.
Wed May 29 11:06:38 2019 :: Sock.sinaddr: 192.168.20.150
Wed May 29 11:06:39 2019 :: Loading TheImm.
Wed May 29 11:06:39 2019 :: TheImm@localhost has connected.
Wed May 29 11:06:43 2019 :: Sock.sinaddr: 192.168.20.150
Wed May 29 11:06:43 2019 :: Loading TheImm.
Wed May 29 11:06:45 2019 :: Closing link to TheImm.
Wed May 29 11:06:45 2019 :: Time for character TheImm when quitting is 14531.
Wed May 29 11:06:45 2019 :: {yLord Talus announces TheImm has left the realms.{x
Wed May 29 11:06:45 2019 :: [] BUG: Char_from_room: ch not found.
Wed May 29 11:06:45 2019 :: [
] BUG: Extract_char: char not found.
Wed May 29 11:06:45 2019 :: Closing link to TheImm
Wed May 29 11:06:45 2019 :: [*****] BUG: Close_socket: dclose not found.
Wed May 29 11:06:45 2019 :: Sock.sinaddr: 192.168.20.150

Program received signal SIGSEGV, Segmentation fault.
0x00000000004506e2 in alloc_mem (sMem=2004) at db.c:2992
2992 rgFreeList[iList] = * ((void **) rgFreeList[iList]);
(gdb) print iList
$1 = 6
(gdb) print pMem
$2 = (void *) 0x6f636552f67be6e8

Valgrind:

Wed May 29 11:52:38 2019 :: [] BUG: Char_from_room: ch not found.
Wed May 29 11:52:38 2019 :: [
] BUG: Extract_char: char not found.
Wed May 29 11:52:38 2019 :: Closing link to TheImm.
Wed May 29 11:52:38 2019 :: [*****] BUG: Close_socket: dclose not found.
Wed May 29 11:52:39 2019 :: Sock.sinaddr: 192.168.20.150
==33174== Invalid read of size 8
==33174== at 0x4506E2: alloc_mem (db.c:2992)
==33174== by 0x492DFD: new_descriptor (recycle.c:133)
==33174== by 0x443AFC: init_descriptor (comm.c:934)
==33174== by 0x443279: game_loop_unix (comm.c:733)
==33174== by 0x442DE7: main (comm.c:437)
==33174== Address 0x6f636552069896e8 is not stack’d, malloc’d or (recently) free’d
==33174==
==33174==
==33174== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==33174== General Protection Fault
==33174== at 0x4506E2: alloc_mem (db.c:2992)
==33174== by 0x492DFD: new_descriptor (recycle.c:133)
==33174== by 0x443AFC: init_descriptor (comm.c:934)
==33174== by 0x443279: game_loop_unix (comm.c:733)
==33174== by 0x442DE7: main (comm.c:437)
==33174==
==33174== HEAP SUMMARY:
==33174== in use at exit: 20,023,056 bytes in 7 blocks
==33174== total heap usage: 314 allocs, 307 frees, 20,544,828 bytes allocated
==33174==
==33174== LEAK SUMMARY:
==33174== definitely lost: 0 bytes in 0 blocks
==33174== indirectly lost: 0 bytes in 0 blocks
==33174== possibly lost: 0 bytes in 0 blocks
==33174== still reachable: 20,023,056 bytes in 7 blocks
==33174== suppressed: 0 bytes in 0 blocks
==33174== Rerun with --leak-check=full to see details of leaked memory
==33174==
==33174== For counts of detected and suppressed errors, rerun with: -v
==33174== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
Segmentation fault (core dumped)

Thank you in advance for any help!

Specifically the dereferencing of rgFreeList look problematic:

rgFreeList[iList] = * ((void **) rgFreeList[iList]);

Valgrind is saying there’s nothing appropriately allocated here… so either rgFreeList or rgFreeList[6] which you’re trying to dereference. Is rgFreeList a local variable or a global? I would check the initialisation.

It’s a global variable:

#define MAX_MEM_LIST 11
void * rgFreeList [MAX_MEM_LIST];

Looks like the global is being initialised fine which means it must be the value that isn’t valid or the dereferencing of the value isn’t valid. I’m not familiar with this particular structure so I don’t think I can help much more.

This link might help shed some light on your problem: http://www.mudbytes.net/forum/comment/71361/