[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUDs
. -> [Folder]  General
. . -> [Subject]  My mud will not start ??!!!??? (fixed)

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: My mud will not start ??!!!??? (fixed)
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please).
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Pages: 1 2  3  

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Wed 16 Dec 2009 07:06 PM (UTC)  quote  ]

Amended on Wed 16 Dec 2009 07:25 PM (UTC) by Nick Gammon

Message
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".

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Dextermovies   (65 posts)  [Biography] bio
Date Tue 08 Dec 2009 03:46 PM (UTC)  quote  ]
Message
Ok it is the load_artifact command, I commented it out and put in return; and the mud works wonderfully now.
[Go to top] top

Posted by Zeno   USA  (2,867 posts)  [Biography] bio   Moderator
Date Mon 07 Dec 2009 01:27 AM (UTC)  quote  ]
Message
http://www.gammon.com.au/forum/?id=3653

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
[Go to top] top

Posted by Dextermovies   (65 posts)  [Biography] bio
Date Mon 07 Dec 2009 01:19 AM (UTC)  quote  ]
Message
How might I go about doing that ?
[Go to top] top

Posted by Zeno   USA  (2,867 posts)  [Biography] bio   Moderator
Date Mon 07 Dec 2009 12:53 AM (UTC)  quote  ]
Message
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.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
[Go to top] top

Posted by Dextermovies   (65 posts)  [Biography] bio
Date Sun 06 Dec 2009 11:47 PM (UTC)  quote  ]
Message
There is nothing in there.
[Go to top] top

Posted by Zeno   USA  (2,867 posts)  [Biography] bio   Moderator
Date Sun 06 Dec 2009 11:46 PM (UTC)  quote  ]
Message
Look in /txt/artifacts.txt for anything corrupt.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
[Go to top] top

Posted by Dextermovies   (65 posts)  [Biography] bio
Date Sun 06 Dec 2009 11:24 PM (UTC)  quote  ]
Message
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);
}
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Sun 06 Dec 2009 10:17 PM (UTC)  quote  ]
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Dextermovies   (65 posts)  [Biography] bio
Date Sun 06 Dec 2009 10:04 PM (UTC)  quote  ]
Message
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.
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Sun 06 Dec 2009 07:53 PM (UTC)  quote  ]
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Zeno   USA  (2,867 posts)  [Biography] bio   Moderator
Date Sun 06 Dec 2009 05:51 PM (UTC)  quote  ]
Message
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.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
[Go to top] top

Posted by Dextermovies   (65 posts)  [Biography] bio
Date Sun 06 Dec 2009 04:16 PM (UTC)  quote  ]
Message
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
[Go to top] top

Posted by Dextermovies   (65 posts)  [Biography] bio
Date Sun 06 Dec 2009 11:46 AM (UTC)  quote  ]
Message
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) 
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Sun 06 Dec 2009 08:39 AM (UTC)  quote  ]

Amended on Sun 06 Dec 2009 08:42 AM (UTC) by Nick Gammon

Message
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

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


7,470 views.

This is page 1, subject is 3 pages long: 1 2  3  [Next page]

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]