Welcome to the Builder Academy

Important Infinite loop on latest stock TBA

More
12 Apr 2018 19:38 - 12 Apr 2018 19:45 #7906 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:
Code:
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:
Code:
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:
Code:
(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: 12 Apr 2018 19:45 by lacrc.

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

More
12 Apr 2018 20:53 #7907 by thomas
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.

More
13 Apr 2018 11:49 - 13 Apr 2018 11:51 #7909 by lacrc
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: 13 Apr 2018 11:51 by lacrc.

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

More
13 Apr 2018 14:42 #7910 by lacrc
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.

More
13 Apr 2018 14:42 - 13 Apr 2018 17:52 #7911 by lacrc
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.)
Code:
/* 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; }
Code:
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: 13 Apr 2018 17:52 by lacrc.

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

More
13 Apr 2018 23:13 #7915 by Moss
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.

Time to create page: 0.207 seconds