Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ SMAUG
➜ SMAUG coding
➜ Swfote core dump move to room with another player
Swfote core dump move to room with another player
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Pages: 1 2
Posted by
| MattJ820
(32 posts) Bio
|
Date
| Sun 05 Apr 2015 06:20 PM (UTC) Amended on Sun 05 Apr 2015 06:25 PM (UTC) by MattJ820
|
Message
| Hello,
I'm having my core dump whenever I move to a room with another character. I made a test character to test new features I coded but if i use goto to transfer to him, the mud crashes, if I transfer him to me it crashes, if I goto the room next to him and then manually move into his room, it crashes.
I used lldb on OSX to look at the core file and it gave me this out of comm.c. Anyone know how to fix this? I'm using swfote2.1.5
(lldb) target create "../bin/swr"
Current executable set to '../bin/swr' (x86_64).
(lldb) settings set -- target.run-args "core.15758"
(lldb) list
152 {
153 struct timeval now_time;
154 bool fCopyOver = !TRUE;
155
156 /*
157 * Memory debugging if needed.
158 */
159 #if defined(MALLOC_DEBUG)
160 malloc_debug( 2 );
161 #endif | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #1 on Sun 05 Apr 2015 08:56 PM (UTC) |
Message
| See my page about gdb: http://www.gammon.com.au/gdb
I would at the very least be typing "bt" to do a backtrace. Find which line it is crashing on. Maybe there is a NULL pointer. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| MattJ820
(32 posts) Bio
|
Date
| Reply #2 on Sun 05 Apr 2015 09:58 PM (UTC) |
Message
| Hey Nick,
I read your guide. I launched the mud from within lldb and caused the core dump so I could run the steps. bt is not showing as a valid process even though it's listed in the help file. Do you know if I'm doing this right?
Sun Apr 5 17:54:09 2015 :: Reading in area files...
Process 17017 exited with status = 1 (0x00000001)
(lldb) Abort (core dumped)
bt
error: invalid thread
(lldb) backtrace
error: 'backtrace' is not a valid command.
(lldb) bt
error: invalid thread
(lldb) bt 17017
error: invalid thread
(lldb) | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #3 on Mon 06 Apr 2015 06:29 AM (UTC) |
Message
| In your first post you seemed to have lldb working, in your more recent one, not.
Can you post everything from when you start up the MUD? Not just the last few lines. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| MattJ820
(32 posts) Bio
|
Date
| Reply #4 on Mon 06 Apr 2015 10:42 PM (UTC) Amended on Tue 07 Apr 2015 08:38 PM (UTC) by MattJ820
|
Message
| This is the snapshot I get when I run the mud in lldb. The core dump was caused by "at look Test' or goto Test or moving into the same room as Test. Test is a mortal I made to try out new skill code.
Still do not understand why I can't do a BT. I'm definitely in the debugger tool.. list works and so do a few other commands that are in the help file.
(lldb) run
Process 19224 launched: '../bin/swr' (x86_64)
Mon Apr 6 18:38:54 2015 :: Booting Database
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Mon Apr 6 18:38:54 2015 :: [*****] BOOT: ---------------------[ Boot Log ]--------------------
Mon Apr 6 18:38:54 2015 :: Initializing libdl support...
Mon Apr 6 18:38:54 2015 :: Loading commands
Mon Apr 6 18:38:54 2015 :: Loading spec_funs...
Mon Apr 6 18:38:54 2015 :: Loading sysdata configuration...
Mon Apr 6 18:38:54 2015 :: Loading socials
Mon Apr 6 18:38:54 2015 :: Sorting skill table...
Mon Apr 6 18:38:54 2015 :: Loading herb table
Mon Apr 6 18:38:54 2015 :: Making wizlist
Mon Apr 6 18:38:54 2015 :: Loading Changes List
Mon Apr 6 18:38:54 2015 :: Loading force skills...
Mon Apr 6 18:38:54 2015 :: Done force skills
Mon Apr 6 18:38:54 2015 :: Loading force helps...
Mon Apr 6 18:38:54 2015 :: Done force helps
Mon Apr 6 18:38:54 2015 :: Loading ship prototypes...
Mon Apr 6 18:38:54 2015 :: [*****] BUG: Load_prototype_header: no match: Type
Mon Apr 6 18:38:54 2015 :: [*****] BUG: Load_prototype_header: no match: 1
Mon Apr 6 18:38:54 2015 :: Done ship prototypes
Mon Apr 6 18:38:54 2015 :: Initializing random number generator
Mon Apr 6 18:38:54 2015 :: Setting time and weather
Mon Apr 6 18:38:54 2015 :: Assigning gsn's
ASSIGN_GSN: Skill split s not found.
ASSIGN_GSN: Skill addpatrol not found.
ASSIGN_GSN: Skill true sight not found.
ASSIGN_GSN: Skill ship design not found.
ASSIGN_GSN: Skill shieldwork not found.
ASSIGN_GSN: Skill detrap not found.
ASSIGN_GSN: Skill parry not found.
ASSIGN_GSN: Skill fourth attack not found.
ASSIGN_GSN: Skill fifth attack not found.
ASSIGN_GSN: Skill bite not found.
ASSIGN_GSN: Skill claw not found.
ASSIGN_GSN: Skill sting not found.
ASSIGN_GSN: Skill tail not found.
ASSIGN_GSN: Skill brew not found.
ASSIGN_GSN: Skill fireball not found.
ASSIGN_GSN: Skill chill touch not found.
ASSIGN_GSN: Skill force bolt not found.
ASSIGN_GSN: Skill aqua breath not found.
ASSIGN_GSN: Skill blindness not found.
ASSIGN_GSN: Skill affect mind not found.
ASSIGN_GSN: Skill curse not found.
ASSIGN_GSN: Skill mask not found.
ASSIGN_GSN: Skill group masking not found.
ASSIGN_GSN: Skill sleep not found.
ASSIGN_GSN: Skill possess not found.
ASSIGN_GSN: Skill asdarian not found.
ASSIGN_GSN: Skill droid not found.
ASSIGN_GSN: Skill makeempgrenade not found.
Mon Apr 6 18:38:54 2015 :: Reading in area files...
Process 19224 exited with status = 1 (0x00000001)
(lldb) Abort (core dumped) | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #5 on Tue 07 Apr 2015 12:02 AM (UTC) |
Message
| I don't see any messages there about a player connnecting. I don't understand either why you can't do a "bt". Maybe you have to switch threads or something, I'm not familiar with that particular version of the debugger. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #6 on Tue 07 Apr 2015 03:28 AM (UTC) |
Message
|
MattJ820 said:
I used lldb on OSX to look at the core file and it gave me this out of comm.c. Anyone know how to fix this? I'm using swfote2.1.5
Can you give a link to the exact zip file you got this source from? I can try to reproduce under Linux where at least I know how to use gdb.
Also, did you change anything at all? |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| MattJ820
(32 posts) Bio
|
Date
| Reply #7 on Tue 07 Apr 2015 08:42 PM (UTC) |
Message
| http://sourceforge.net/projects/swfote/files/swfote/SWFotE%202.1.5%20Source/
The only thing I changed was I included <stdbool.h>, commented out typedef unsigned char bool in mud.h
In the makfile, I commented out NEED-DL = -ldl, commented out export symbols = -export dynamic, and then I removed -lcrypt from $(CC) -o $(SWR) $(O_FILES) $(L_FLAGS) -lm
Thanks for your help Nick. I tried to follow your guide for debugging and I wish I knew why the commands don't work in lldb despite being listed. it would at least point me in the right direction. | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #8 on Wed 08 Apr 2015 02:46 AM (UTC) |
Message
|
MattJ820 said:
I made a test character to test new features I coded but if i use goto to transfer to him, the mud crashes
...
The only thing I changed was I included <stdbool.h>, commented out typedef unsigned char bool in mud.h
Did you make changes or not? What new features? I compiled under Ubuntu without making any changes at all. I made a test character and did a "goto" to him. No crash. I transferred him to me. No crash. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| MattJ820
(32 posts) Bio
|
Date
| Reply #9 on Thu 09 Apr 2015 07:38 PM (UTC) |
Message
| I backed out the changes I hadmade and the replicated the issue with a clean version. So, is the core dump because I'm compiling under OSX? | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #10 on Thu 09 Apr 2015 09:14 PM (UTC) |
Message
| I ran my test through valgrind with these results:
cd ../area
valgrind --tool=memcheck ../bin/swr 1530
After doing a "goto":
==25819== Conditional jump or move depends on uninitialised value(s)
==25819== at 0x4E52A3: strip_color (functions.c:353)
==25819== by 0x4E63B4: is_name2 (handler.c:529)
==25819== by 0x4E6549: nifty_is_name (handler.c:566)
==25819== by 0x4EAC4F: get_char_world (handler.c:1777)
==25819== by 0x455099: find_location (act_wiz.c:750)
==25819== by 0x473D48: do_goto (build.c:864)
==25819== by 0x4F6986: interpret (interp.c:418)
==25819== by 0x49D7AF: game_loop (comm.c:602)
==25819== by 0x49C6FA: main (comm.c:263)
==25819==
==25819== Conditional jump or move depends on uninitialised value(s)
==25819== at 0x4E5268: strip_color (functions.c:355)
==25819== by 0x4E63B4: is_name2 (handler.c:529)
==25819== by 0x4E6549: nifty_is_name (handler.c:566)
==25819== by 0x4EAC4F: get_char_world (handler.c:1777)
==25819== by 0x455099: find_location (act_wiz.c:750)
==25819== by 0x473D48: do_goto (build.c:864)
==25819== by 0x4F6986: interpret (interp.c:418)
==25819== by 0x49D7AF: game_loop (comm.c:602)
==25819== by 0x49C6FA: main (comm.c:263)
Code in question:
/*
* Strips colors from a string --Keberus
*/
char *strip_color( const char *str )
{
static char newstr[MAX_STRING_LENGTH];
int i, j;
if( !str || str[0] == '\0' )
{
return "";
}
for( i = j = 0; ( str[i] != '\0' ); i++, j++ ) // <--- line 353
{
if( str[i] == '&' ) // <---- line 355
{
i = i + 2;
}
newstr[j] = str[i];
}
newstr[j] = '\0';
return newstr;
}
On the face of it, that code looks OK, however you could try a better initialization of i and j, eg.
See if that helps. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #11 on Thu 09 Apr 2015 11:09 PM (UTC) |
Message
| Now that valgrind has alerted me to the function strip_color, I think there is a bug in it (and not what I suggested earlier).
My testing using gdb reveals that it is called with the argument "&w" like this:
#0 strip_color (str=0x7fffffffbc00 "&w") at functions.c:348
So, considering the "for" loop, we have this input:
The variable "i" starts at zero, and we immediately detect the '&' character, so it adds two to "i". Then the for loop adds 1 to "i", so now i is equal to 3. However that puts "i" outside the string as it is only 2 bytes. In other words, "i" now points past the null-terminator. It could then conceivably increment massively, overwriting memory.
I suggest you change strip_color function to be:
/*
* Strips colors from a string --Keberus
*/
char *strip_color( const char *str )
{
static char newstr[MAX_STRING_LENGTH];
int i, j;
if( !str || str[0] == '\0' )
{
return "";
}
for( i = j = 0; str[i]; )
{
if( str[i] == '&' )
i += 2; // skip ampersand and color code
else
newstr[j++] = str[i++]; // copy character
}
newstr[j] = '\0';
return newstr;
}
In fact even that could fail if it was fed with "&" on its own. This would be better:
/*
* Strips colors from a string --Keberus
*/
char *strip_color( const char *str )
{
static char newstr[MAX_STRING_LENGTH];
int i, j;
if( !str || str[0] == '\0' )
{
return "";
}
for( i = j = 0; str[i]; )
{
if( str[i] == '&' )
{
i++; // skip ampersand
if (str [i])
i++; // skip color code
}
else
newstr[j++] = str[i++]; // copy character
}
newstr[j] = '\0';
return newstr;
}
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| MattJ820
(32 posts) Bio
|
Date
| Reply #12 on Sat 11 Apr 2015 01:10 AM (UTC) Amended on Sat 11 Apr 2015 01:45 AM (UTC) by MattJ820
|
Message
| I copied in the last code quote and over wrote the strip color function in functions.c but I still got a core dump using goto. I'm going to google lldb to find out why I can't BT to find what was going on when the dump happened. I wish it would work.
Thanks for helping Nick.
Could it be I need to initialize these other variables? I'll try that.
==25819== Conditional jump or move depends on uninitialised value(s)
==25819== at 0x4E52A3: strip_color (functions.c:353)
==25819== by 0x4E63B4: is_name2 (handler.c:529)
==25819== by 0x4E6549: nifty_is_name (handler.c:566)
==25819== by 0x4EAC4F: get_char_world (handler.c:1777)
==25819== by 0x455099: find_location (act_wiz.c:750)
==25819== by 0x473D48: do_goto (build.c:864)
==25819== by 0x4F6986: interpret (interp.c:418)
==25819== by 0x49D7AF: game_loop (comm.c:602)
==25819== by 0x49C6FA: main (comm.c:263)
==25819==
==25819== Conditional jump or move depends on uninitialised value(s)
==25819== at 0x4E5268: strip_color (functions.c:355)
==25819== by 0x4E63B4: is_name2 (handler.c:529)
==25819== by 0x4E6549: nifty_is_name (handler.c:566)
==25819== by 0x4EAC4F: get_char_world (handler.c:1777)
==25819== by 0x455099: find_location (act_wiz.c:750)
==25819== by 0x473D48: do_goto (build.c:864)
==25819== by 0x4F6986: interpret (interp.c:418)
==25819== by 0x49D7AF: game_loop (comm.c:602)
==25819== by 0x49C6FA: main (comm.c:263) | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #13 on Sat 11 Apr 2015 02:57 AM (UTC) |
Message
| I think it was complaining about using data off the end of the string, which my change should have fixed. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #14 on Sat 11 Apr 2015 03:15 AM (UTC) |
Message
| You don't need to use lldb, I just tested on my Mac using gdb.
After it crashed, I got a backtrace:
(gdb) bt
#0 0x00007fff931e182a in __kill ()
#1 0x00007fff960ccb6c in __abort ()
#2 0x00007fff9609e89f in __chk_fail ()
#3 0x00007fff9609e6d9 in __sprintf_chk ()
#4 0x00000001000194f8 in show_char_to_char_0 (victim=0x100941000, ch=0x100943a00) at act_info.c:520
#5 0x000000010001adab in show_char_to_char (list=0x100941000, ch=0x100943a00) at act_info.c:816
#6 0x000000010001bad1 in do_look (ch=0x100943a00, argument=0x1002400d4 "") at act_info.c:1008
#7 0x0000000100047ee3 in transfer_char (ch=0x100941000, victim=0x100943a00, location=0x1004bcfc0) at act_wiz.c:813
#8 0x00000001000481f6 in do_transfer (ch=0x100941000, argument=0x7fff5fbff625 "") at act_wiz.c:864
#9 0x0000000100116d56 in interpret (ch=0x100941000, argument=0x7fff5fbff621 "nick") at interp.c:418
#10 0x00000001000a57dd in game_loop () at comm.c:602
#11 0x00000001000a436c in main (argc=2, argv=0x7fff5fbffb08) at comm.c:263
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | 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.
49,947 views.
This is page 1, subject is 2 pages long: 1 2
It is now over 60 days since the last post. This thread is closed.
Refresh page
top