Infinite loop on latest stock TBA

  • lacrc
  • lacrc's Avatar Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
More
3 months 5 days ago - 3 months 5 days ago #7906 by lacrc
Infinite loop on latest stock TBA was created by lacrc
Hi Guys!
Not sure if this is the correct way of reporting this but, I just got the latest version of stock TBA from GitHub and circle is freezing after I try to use "where guard" or "vnum m guard".

After a while it aborted with the log:
Apr 12 16:37:01 2018 :: SYSERR: CHECKPOINT shutdown: tics not updated. (Infinite loop suspected)
Then I was able to get this from the thread:
    frame #5: 0x000000010008a1ab circle`isname_tok(str="guard", namelist="Guardian guard") at handler.c:97 [opt]
    frame #6: 0x000000010008a2bb circle`isname(str=<unavailable>, namelist="Guardian guard") at handler.c:125 [opt]
I'm not sure if it's an issue with the "Multiple keyword support" commit or if it's something related to the zone #291: Black Forest which is where I think those mobs are located (I found that looking for the keywords "Guardian guard" on the world file).

Can anyone try to reproduce that? Or is it just me?
I'm currently running circle on Mac OSX and I haven't tried it on other OSs but I can try on windows or linux later.

Here is the complete thread backtrace from lldb:
(lldb) thread backtrace all
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
  * frame #0: 0x00007fff53dd5e3e libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x00007fff53f14150 libsystem_pthread.dylib`pthread_kill + 333
    frame #2: 0x00007fff53d32312 libsystem_c.dylib`abort + 127
    frame #3: 0x000000010005126b circle`checkpointing(sig=<unavailable>) at comm.c:2255 [opt]
    frame #4: 0x00007fff53f07f5a libsystem_platform.dylib`_sigtramp + 26
    frame #5: 0x00007fff53e2e1a1 libsystem_malloc.dylib`malloc_zone_malloc + 7
    frame #6: 0x00007fff53e2d50b libsystem_malloc.dylib`malloc + 24
    frame #7: 0x00007fff53d2f707 libsystem_c.dylib`strdup + 32
    frame #8: 0x000000010008a199 circle`isname_tok(str="guard", namelist="Guardian guard") at handler.c:96 [opt]
    frame #9: 0x000000010008a2bb circle`isname(str=<unavailable>, namelist="Guardian guard") at handler.c:125 [opt]
    frame #10: 0x000000010000c140 circle`do_where [inlined] perform_immort_where(ch=0x0000000103d044a0, arg="") at act.informative.c:1652 [opt]
    frame #11: 0x000000010000bfc0 circle`do_where(ch=0x0000000103d044a0, argument=<unavailable>, cmd=<unavailable>, subcmd=<unavailable>) at act.informative.c:1681 [opt]
    frame #12: 0x000000010009d668 circle`command_interpreter(ch=0x0000000103d044a0, argument=<unavailable>) at interpreter.c:584 [opt]
    frame #13: 0x000000010004cf17 circle`game_loop(local_mother_desc=<unavailable>) at comm.c:895 [opt]
    frame #14: 0x000000010004aed1 circle`main [inlined] init_game(local_port=<unavailable>) at comm.c:532 [opt]
    frame #15: 0x000000010004aaa4 circle`main(argc=<unavailable>, argv=<unavailable>) at comm.c:352 [opt]
    frame #16: 0x00007fff53c86115 libdyld.dylib`start + 1
    frame #17: 0x00007fff53c86115 libdyld.dylib`start + 1
Last edit: 3 months 5 days ago by lacrc.

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

More
3 months 5 days ago #7907 by thomas
Replied by thomas on topic Infinite loop on latest stock TBA
You are right. The commit for multiple keywords caused an infinite loop on mobs/objects with duplicated substrings in the name field.

I have reverted the commit in master.

Thank you for the bug report.
The following user(s) said Thank You: lacrc

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

  • lacrc
  • lacrc's Avatar Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
More
3 months 4 days ago - 3 months 4 days ago #7909 by lacrc
Replied by lacrc on topic Infinite loop on latest stock TBA
Alrighty then!

mobs/objects with duplicated substrings in the name field

Yeah I thought it wasn't a coincidence that it always reported the same "Guardian guard" as the search string. I'm tinkering with the isname_tok() and isname() functions, if I get anywhere around a decent fix I'll post back here.
Last edit: 3 months 4 days ago by lacrc.

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

  • lacrc
  • lacrc's Avatar Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
More
3 months 4 days ago #7910 by lacrc
Replied by lacrc on topic Infinite loop on latest stock TBA
Hmm, I think that the problem is that isname and isname_tok both uses strtok() and since the calls are "nested" the strtok() is messing up the pointer (since it can only register one pointer for subsequent strtok(NULL, ...) calls.

This that make any sense? lol

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

  • lacrc
  • lacrc's Avatar Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
More
3 months 4 days ago - 3 months 4 days ago #7911 by lacrc
Replied by lacrc on topic Infinite loop on latest stock TBA
Ok so, I was able to fix the Multiple Keywords Patch infinite loop by replacing strtok() with strsep().
man7.org/linux/man-pages/man3/strsep.3.html
Is it portable enough for circle?

If anyone is interested here are the versions of isname_tok() and isname() using strsep(). I had to create a temporary pointer to the namelist and substr variables so they can be freed later, I also moved a free up to avoid leaks (would it have caused any leaks anyway? I'm not entirely sure.)
/* allow abbreviations */
#define WHITESPACE " \t"
#define KEYWORDJOIN "_"
int isname_tok(const char *str, const char *namelist)
{
  char *newlist;
  char *curtok;
  char *tempnl;

  if (!str || !*str || !namelist || !*namelist)
    return 0;

  if (!strcmp(str, namelist)) /* the easy way */
    return 1;

  tempnl = newlist = strdup(namelist); /* make a copy since strtok 'modifies' strings */
  for (curtok = strsep(&newlist, WHITESPACE); curtok; curtok = strsep(&newlist, WHITESPACE))
    if (curtok && is_abbrev(str, curtok)) {
      /* Don't allow abbreviated numbers. - Sryth */
      free(tempnl);
      if (isdigit(*str) && (atoi(str) != atoi(curtok)))
        return 0;
      return 1;
    }
  free(tempnl);
  return 0;
}
int isname(const char *str, const char *namelist)
{
  char *strlist;
  char *substr;
  char *tempstr;

  if (!str || !*str || !namelist || !*namelist)
    return 0;

  if (!strcmp(str, namelist)) /* the easy way */
    return 1;

  tempstr = strlist = strdup(str);
  for (substr = strsep(&strlist, KEYWORDJOIN); substr; substr = strsep(&strlist, KEYWORDJOIN)) {
    if (!substr) continue;
    if (!isname_tok(substr, namelist)) {
      free(tempstr);
      return 0;
    }
  }
  /* If we didn't fail, assume we succeded because every token was matched */
  free(tempstr);
  return 1;
}
Last edit: 3 months 4 days ago by lacrc.

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

More
3 months 3 days ago #7915 by Moss
Replied by Moss on topic Infinite loop on latest stock TBA
would this be the reason why my MUD hangs when i try to 'vnum obj fountain'?
i also drank from a fountain once and it seemed to hang too, feels like someone made a bad fountain somewhere..
and where do you actually see the traceback? in a log file somewhere?

sorry i'm from MOO where the traceback spits out on your screen when something goes wrong

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

  • lacrc
  • lacrc's Avatar Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
More
3 months 3 days ago - 3 months 3 days ago #7916 by lacrc
Replied by lacrc on topic Infinite loop on latest stock TBA
Well that looks like it might be the same issue.
But the Multiple Keyword support is fairly recent, the commit is from 26 days ago, if your TBA source was updated from the master during this time then yes, that might be the case.

You could try to replace your isname_tok() and isname() functions with the ones I posted earlier, BUT it might be wiser to simply update your source from the master on github again (since the commit has been reverted) and wait for and answer from thomas or anyone else for that matter since I'm fairly new around here and not sure of what I am doing :D

Edit: and btw for the trace you need to use gdb to run circle, I think there's some tutorials around here on the forums on how to do it
Another edit: So here's some examples.
www.tbamud.com/forum/2-general/4364-crashing-on-shutdown#7741
This thread has some info (from thomas himself) on how to attach gdb to a running process.

www.tbamud.com/forum/2-general/4348-crash-need-help#7674
This one there's thomas (yep, him again, dude is all over the place!) walking someone over on how to walk through frames and print variables in gdb.

There's a lot more probably, but I think those can get you started.
Last edit: 3 months 3 days ago by lacrc.

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

Time to create page: 1.233 seconds