AFKMud icon indicating copy to clipboard operation
AFKMud copied to clipboard

Mudlet casues hotboot to hang / fail.

Open windu-ant opened this issue 1 year ago • 0 comments

hotboot_recover seems to fail on line ~810 due to fscanf not reading the client type provided properly. This causes the mud to hang indefinitely it seems, not just the connected player.

This seems to be caused by Mudlet providing the client name and version number, Mudlet 4.17.1, instead of just a name like 'mushclient' does.

I solved this by modifying how the hotboot file is written slightly.

#include <sstream> // For std::istringstream

// Add this function before do_hotboot

std::string firstWord(const std::string& str) {
    std::istringstream iss(str);
    std::string word;
    iss >> word; // This captures the first word up to the first whitespace
    return word;
}

// And then modifying do_hotboot slightly around line 708

// When writing to the file:
      fprintf(fp, "%d %d %d %d %d %d %d %s %s %s\n",
            d->descriptor, d->can_compress, d->is_compressing, d->msp_detected,
            och->in_room->vnum, d->client_port, d->idle, och->name, d->hostname.c_str(), firstWord(d->client).c_str());

This is the backtrace provided by gdb before the above fix:

Program received signal SIGINT, Interrupt.
0x00007ffff7a369ea in __vfscanf_internal (s=0x55555597de20, format=0x555555798e1f "%d %d %d %d %d %d %d %s %s %s\n", argptr=argptr@entry=0x7fffffffa100, mode_flags=mode_flags@entry=2) at ./stdio-common/vfscanf-internal.c:278
278     ./stdio-common/vfscanf-internal.c: No such file or directory.
(gdb) bt
#0  0x00007ffff7a369ea in __vfscanf_internal (s=0x55555597de20, format=0x555555798e1f "%d %d %d %d %d %d %d %s %s %s\n", argptr=argptr@entry=0x7fffffffa100,
    mode_flags=mode_flags@entry=2) at ./stdio-common/vfscanf-internal.c:278
#1  0x00007ffff7a3621d in __isoc99_fscanf (stream=stream@entry=0x55555597de20, format=format@entry=0x555555798e1f "%d %d %d %d %d %d %d %s %s %s\n")
    at ./stdio-common/isoc99_fscanf.c:30
#2  0x0000555555697ed5 in hotboot_recover () at hotboot.cpp:798
#3  0x0000555555656791 in init_mud (fCopyOver=fCopyOver@entry=true, gameport=<optimized out>, wsocket=wsocket@entry=-1, imcsocket=imcsocket@entry=-1) at comm.cpp:460
#4  0x00005555555a7ea8 in main (argc=<optimized out>, argv=0x7fffffffe488) at comm.cpp:1335

windu-ant avatar Mar 19 '24 12:03 windu-ant