Welcome to the Builder Academy

Question Fight.c crash

More
20 Dec 2016 18:52 #6426 by JTP
Replied by JTP on topic Fight.c crash
Oh yes, its compiled and restarted :(

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

More
20 Dec 2016 19:02 #6427 by thomas
Replied by thomas on topic Fight.c crash
Also, the reason "killer &&" will work is because
Code:
if (killer && !IS_NPC(killer)) {

means
Code:
if (killer != 0x0 && !(killer->mob_flags & 4 == 1)) {

In this snippet you see two different uses of the ampersand (&):
Code:
&& means "short-circuit boolean AND" & means "boolean AND"

Short circuit operators stop when they are no longer able to become true (non-zero).
Consider this:
Code:
#include <stdio.h> int one(void) { printf("one()\r\n"); return 1; } int zero(void) { printf("zero()\r\n"); return 0; } int main(void) { printf("one && zero = %d\r\n", one() && zero()); printf("zero && one = %d\r\n", zero() && one()); printf("one && one = %d\r\n", one() && one()); printf("zero && zero = %d\r\n", zero() && zero()); return 0; }
The resulting output looks like this:
Code:
one() zero() one && zero = 0 zero() zero && one = 0 one() one() one && one = 1 zero() zero && zero = 0
As you can see, once the program receives a false (ie. a zero) it stops calling the other functions on the line.
You can see the code here to try it out: ideone.com/lN9DTy

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

More
20 Dec 2016 19:03 #6428 by thomas
Replied by thomas on topic Fight.c crash

JTP wrote: Oh yes, its compiled and restarted :(

Hmm.. Try expanding the check to
Code:
if (killer != NULL && !IS_NPC(killer)) {

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

More
20 Dec 2016 19:29 #6430 by JTP
Replied by JTP on topic Fight.c crash
Just added if (killer != NULL && !IS_NPC(killer)) {
compiled, restarted...mud was up like 2 mins noone on but me and i was just standing in board room. CRASH...had even done a make clean..make all

Code:
GNU gdb (GDB) CentOS (7.0.1-45.el5.centos) Copyright (C) 2009 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i386-redhat-linux-gnu". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... Reading symbols from /home/mud/jtpfoto/aoh-nyclan/bin/circle...done. [New Thread 9983] Reading symbols from /lib/libcrypt.so.1...(no debugging symbols found)...done. Loaded symbols for /lib/libcrypt.so.1 Reading symbols from /lib/libc.so.6...(no debugging symbols found)...done. Loaded symbols for /lib/libc.so.6 Reading symbols from /lib/ld-linux.so.2...(no debugging symbols found)...done. Loaded symbols for /lib/ld-linux.so.2 Reading symbols from /lib/libgcc_s.so.1...(no debugging symbols found)...done. Loaded symbols for /lib/libgcc_s.so.1 Core was generated by `bin/circle -q 6969'. Program terminated with signal 6, Aborted. #0 0x00569402 in __kernel_vsyscall ()


BT of core....getting more and more confused here.
Code:
(gdb) bt #0 0x00569402 in __kernel_vsyscall () #1 0x002e1b10 in raise () from /lib/libc.so.6 #2 0x002e3421 in abort () from /lib/libc.so.6 #3 0x0031a67b in __libc_message () from /lib/libc.so.6 #4 0x00326bb8 in free () from /lib/libc.so.6 #5 0x080aab51 in close_socket (d=0x94080f8) at comm.c:2213 #6 0x080ae7c1 in game_loop (local_mother_desc=3) at comm.c:901 #7 0x080afc67 in init_game (argc=Cannot access memory at address 0x26ff ) at comm.c:535 #8 main (argc=Cannot access memory at address 0x26ff ) at comm.c:355

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

More
20 Dec 2016 20:26 #6431 by thomas
Replied by thomas on topic Fight.c crash
This is a different error than your fight.c crash. We can relatively quickly establish that much.

What is happening here, then. Well, comm.c:2213 in stock tbamud looks like this:
Code:
#elif defined(CIRCLE_UNIX) || defined(CIRCLE_OS2) || defined(CIRCLE_MACINTOSH) #ifndef O_NONBLOCK #define O_NONBLOCK O_NDELAY #endif static void nonblock(socket_t s) { // <-- line #2213 int flags; flags = fcntl(s, F_GETFL, 0); flags |= O_NONBLOCK; if (fcntl(s, F_SETFL, flags) < 0) { perror("SYSERR: Fatal error executing nonblock (comm.c)"); exit(1); } } #endif /* CIRCLE_UNIX || CIRCLE_OS2 || CIRCLE_MACINTOSH */
and I think it's safe to say this isn't a line related to close_socket().

So, we need you to do the debugging dance - in your debugger, type the commands "list", "show local" and "up" until you get to the outermost frame. Post your output here.


I figure something bad is happening in the code, making it use too many resources for the shell. "Aborted" usually means the process has been taken down by the host.

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

More
20 Dec 2016 20:37 #6432 by JTP
Replied by JTP on topic Fight.c crash
Running on a few year old copy...my 2213 is:
Code:
/* Clear the command history. */ if (d->history) { int cnt; for (cnt = 0; cnt < HISTORY_SIZE; cnt++) if (d->history[cnt]) free(d->history[cnt]); <<<<---- free(d->history); }

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

Time to create page: 0.590 seconds