My mud will not start ??!!!??? (fixed)

Posted by Dextermovies on Sat 05 Dec 2009 10:19 PM — 38 posts, 135,761 views.

#0
I had my mud running before, it does this some times when I add new commands :( .. I had a whole lot of issues adding this last command as is evident by my forum postings.
But I do ./startup &
and I get this

[Josh@localhost src]$ ./startup &
[1] 8871
[Josh@localhost src]$ [1] 8873

[1]+  Done                    ./startup


When I do ps ux my mud is not running.
I can make it just fine, no errors and several warnings. I am trying to fox those warnings though. I have fixed most of them though, but a lot of them are beyond my knowledge.

~Josh

p.s if you need any code files or anything please let me know.
I am using Fedora core 12
Canada #1
What happens when you try to connect?
#2
It will not allow me to connect, as if my mud was not running at all.
USA #3
Try running without the & and see if it errors out during startup?
#4
Dec 5 12:52:56 :: [*****] BUG: Fread_word: word 'ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ' too long.
Canada #5
Have you changed your startup script in any way, shape or form? Maybe you could post it here for others to look at. The fact that it "does this some times" can't be a good thing and that error looks bad even to me, and I'm not a programmer.
#6
#!/bin/csh -f

set port = 2121
set logfile = ../log/output.log

nice
limit coredumpsize 32786k
limit filesize 32786k

cd ../area
../src/Dystopia $port >&! $logfile &
USA #7
Dextermovies said:

Dec 5 12:52:56 :: [*****] BUG: Fread_word: word 'ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ' too long.


This is a problem loading data from a file. Can you paste all of the errors? What exactly did you change, code-wise?
Amended on Sun 06 Dec 2009 12:08 AM by Nick Cash
#8
That is the only error I get. I have added a lot to the code, roughly 5 commands and a fight database.

Do you want the warnings I get when I compile ?
USA #9
Does it say what file it is trying to read from? Isn't there a boot log somewhere you can show us?
#10
I am using dystopia 2, I can not find one if there is one ...
USA #11
Did you modify any files it needs to load? Did you modify the loading code itself?
#12
Not that I am aware of, I am begining coder so I am generally unsure of what I am doing.
USA #13
Well, did you modify anything besides source files (those with the .c/.h extension)? Such as when you were adding commands?

You would probably know if you modified the loading code, though it depends on what features you have been adding.

This is an example of why it is generally best to add one thing at a time, that way, when it breaks, you know which file to turn to for fixing :)
#14
I add one command at a time ... but I modified several source files adding this command in. And no I did not modify any aside from source files.
Canada #15
Generally logs are in the log folder..

I think at this point you'll want to run gdb for more accurate results.
#16
What is gdb ?
Canada #17
Template:post=3653
Please see the forum thread: http://gammon.com.au/forum/?id=3653.
USA #18
Hanaisse is right, gdb will probably lead you to the answer quickly if you can follow the tutorial and use it effectively. Essentially, you need to figure out why you are failing to read a particular file. Without your boot log there is no way for us to determine what file that might be.

Have you added any fread_word() function calls, or modified the saving/loading of any particular object (mobs, classes, system data, etc)? If not, it seems likely you have corrupted some data somewhere that gets saved, though having filenames and an idea of what you changed would be the best. What commands did you add?
#19
setfdb,loadfdb,savefdb,testarm and distort .. all wiz commands..
#20
Ok, I can not get it to create a core dump :( I added the -g3 to the l_flags and c_flags .. Am I missing something ?

I alos editied the etc/secturity/limits.conf and added * soft core 10000 to it to allow for large core dumps, then I loged out and back in to make the change stick.
Amended on Sun 06 Dec 2009 01:47 AM by Dextermovies
Canada #21
Did you make clean?

Are you saying the error during startup is not producing any core files? They'll be in your main folder /Dystopia/ (or whatever it is.

Did you find the log files yet?
#22
Nope no log files, all it says is

(gdb) run file Dystopia
Starting program: /home/Josh/Desktop/dystopia2/src/Dystopia file Dystopia
[Thread debugging using libthread_db enabled]
Usage: /home/Josh/Desktop/dystopia2/src/Dystopia [port #]

Program exited with code 01.



I have done make clean and make distclean.
Australia Forum Administrator #23
You got an error message because you ran it with the arguments "file Dystopia" when it is expecting a port number.

What I normally do to debug is, change to the area directory, and then do gdb, like this:


cd ../area              # it needs to run in the area directory
gdb ../src/Dystopia     # or whatever the executable is

(gdb) run 4000          # run with port 4000



See: http://www.gammon.com.au/gdb
Amended on Sun 06 Dec 2009 08:42 AM by Nick Gammon
#24
I still get the same thing ...


[Josh@localhost area]$ gdb ../src/Dystopia
GNU gdb (GDB) Fedora (7.0-8.fc12)
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 "i686-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/Josh/Desktop/dystopia2/src/Dystopia...done.
(gdb) run 4000
Starting program: /home/Josh/Desktop/dystopia2/src/Dystopia 4000
[Thread debugging using libthread_db enabled]

Program exited with code 01.
(gdb) 
#25
Issue found I think..
In the other code fread_number is defined as
unsigned long long int	fread_number	args( ( FILE *fp ) ); 


But in the dystopia 2 code it is defined as
int   fread_number       (FILE * fp); 


Now if I change the code from the old mud to
unsigned long long int	fread_number	( FILE *fp ); 

I get

db.c:2268: error: conflicting types for ‘fread_number’
dystopia.h:3969: note: previous declaration of ‘fread_number’ was here


Any help here is greatly appreciated
USA #26
Code 01 means the code is executing exit(1) somewhere.

Is this log still showing up?
Dec 5 12:52:56 :: [*****] BUG: Fread_word: word 'ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ' too long.
Australia Forum Administrator #27
In your case gdb didn't show much because the MUD didn't actually crash, it chose to exit, as Zeno said. If you haven't found the problem, you can still find why it calls exit. First make your own exit function:


void my_exit (int status)
  {
  exit (status);
  }


And put a function prototype in mud.h or whatever it is called:



void my_exit (int status);


Then go through the rest of the code (using grep will help) and change every instance of:


exit (1);


to:


my_exit (1);


(And of course any other numbers you find).

Just don't change the one inside my_exit. ;P

Then fire up gdb again, and before typing "run" type in "break my_exit". That will put a breakpoint on your my_exit function. Then type "run" or "run 4000" and let it rip. Then when it tries to exit it will end up in my_exit. Then type "bt" to get a backtrace to see exactly where in the code it is calling exit.
#28
Now I get These errors while compiling the source

[12:00:59] Linking executable ...
obj/act_info.o: In function `my_exit':
/home/Josh/Desktop/dystopia2/src/dystopia.h:2600: multiple definition of `my_exit'
obj/act_comm.o:/home/Josh/Desktop/dystopia2/src/dystopia.h:2600: first defined here
obj/act_move.o: In function `my_exit':
/home/Josh/Desktop/dystopia2/src/dystopia.h:2600: multiple definition of `my_exit'
obj/act_comm.o:/home/Josh/Desktop/dystopia2/src/dystopia.h:2600: first defined here
obj/act_comm.o:/home/Josh/Desktop/dystopia2/src/dystopia.h:2600: first defined here
collect2: ld returned 1 exit status
make: *** [Dystopia] Error 1
[Josh@localhost src]$ 

There are several more of these.
Australia Forum Administrator #29
Put the actual function (my first box) only once in the code (eg. comms.c) otherwise the linker will complain it finds more than one of them. The function prototype I mentioned, which you put in your .h file, tells the other functions to expect it to be found at link time.
#30
Thanks I had them both in Dystopia.h ....
This seems to be the culprit.


/*
 * Read one word (into static buffer).
 */
char *fread_word(FILE * fp)
{
  static char word[MAX_INPUT_LENGTH];
  char buf[100];
  char *pword;
  char cEnd;

  do
  {
    cEnd = getc(fp);
  }
  while (isspace(cEnd));

  if (cEnd == '\'' || cEnd == '"')
  {
    pword = word;
  }
  else
  {
    word[0] = cEnd;
    pword = word + 1;
    cEnd = ' ';
  }

  for (; pword < word + MAX_INPUT_LENGTH; pword++)
  {
    *pword = getc(fp);
    if (cEnd == ' ' ? isspace(*pword) : *pword == cEnd)
    {
      if (cEnd == ' ')
        ungetc(*pword, fp);
      *pword = '\0';
      return word;
    }
  }

  word[20] = '\0';
  sprintf(buf, "Fread_word: word '%s' too long.", word);
  bug(buf, 0);
  my_exit(1);
  return NULL;
}


Also it makes reference to


    void boot_db(bool fCopyOver)
    load_artifact_table();

and 
    void load_artifact_table()
{
  FILE *fp;
  char *word;

  log_string("Loading Artifacts");

  if ((fp = fopen("../txt/artifacts.txt", "r")) == NULL)
  {
    bug("Unable to open artifacts.txt", 0);
    abort();
  }

  word = fread_word(fp);
  while (str_cmp(word, END_MARKER))
  {
    struct arti_type *artifact = malloc(sizeof(struct arti_type));

    artifact->owner = str_dup(word);
    artifact->vnum = fread_number(fp);
    artifact->active = fread_number(fp);
    artifact->fun = fread_string(fp);

    AttachToList(artifact, artifact_table);

    word = fread_word(fp);
  }

  fclose(fp);
}
USA #31
Look in /txt/artifacts.txt for anything corrupt.
#32
There is nothing in there.
USA #33
If you're sure load_artifact_table is causing this, set a breakpoint at it and then step into fread_word and print out any info there.
#34
How might I go about doing that ?
USA #35
http://www.gammon.com.au/forum/?id=3653
#36
Ok it is the load_artifact command, I commented it out and put in return; and the mud works wonderfully now.
Australia Forum Administrator #37
Another approach to capture if the MUD exits by calling exit(1) is to put a breakpoint on exit, like this example program:


#include <stdlib.h>

void a (void)
  {
  exit (1);
  }

void b (void)
  {
  a ();
  }


int main (void)
  {
  b ();
  return 0;
  }


Now if I run gdb, I want to find where in the code exit is called:


$ gdb test

GNU gdb 6.8-debian

(gdb) break exit

Function "exit" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y

Breakpoint 1 (exit) pending.

(gdb) run

Starting program: /home/nick/development/test

Breakpoint 1, 0xb7ea8d06 in exit () from /lib/tls/i686/cmov/libc.so.6

(gdb) bt

#0  0xb7ea8d06 in exit () from /lib/tls/i686/cmov/libc.so.6
#1  0x080483d6 in a ()
#2  0x080483e1 in b ()
#3  0x080483f9 in main ()

(gdb)


Note the warning message about exit not existing just yet, but it picked it up after the libraries were loaded. Then when exit was called, you can see it was indeed located in function "a" called by function "b" called by "main".