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
➜ GDB - I don't quite understand
GDB - I don't quite understand
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Nick Cash
USA (626 posts) Bio
|
Date
| Sun 14 Dec 2003 07:19 AM (UTC) |
Message
| Alright, I was using gdb on my core file and got this after a backtrace:
#0 0x420807b6 in strcpy () from /lib/i686/libc.so.6
#1 0x080589b7 in profanity_filter (
arg=0x8153200 "You're home planet is a little hard to get to right now.",
out=0x8153200 "You're home planet is a little hard to get to right now.") at act_comm.c:446
#2 0x08059b7e in do_say (ch=0x8287858,
argument=0x8153200 "You're home planet is a little hard to get to right now.")
at act_comm.c:1056
#3 0x080deba9 in spec_newbie_pilot (ch=0x8287858) at special.c:160
#4 0x080ec279 in mobile_update () at update.c:689
#5 0x080eeaf5 in update_handler () at update.c:2227
#6 0x080922ff in game_loop () at comm.c:573
#7 0x08091b2c in main (argc=7, argv=0xbffffac4) at comm.c:236
#8 0x42017589 in __libc_start_main () from /lib/i686/libc.so.6
There are only two things in there that tell me anything I'm understanding. One, it has an issue with my profanity filter, or two (or both I guess) it has a problem with spec_newbie_pilot. What would you suggest? |
~Nick Cash
http://www.nick-cash.com | Top |
|
Posted by
| Zeno
USA (2,871 posts) Bio
|
Date
| Reply #1 on Sun 14 Dec 2003 08:17 PM (UTC) |
Message
| Most likely the filter. The backtrace simply shows you what happened before the crash. |
Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #2 on Sun 14 Dec 2003 09:01 PM (UTC) |
Message
| Can you paste the code in the profanity filter? Some versions just comment that out anyway, sounds like it wasn't done properly. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Cash
USA (626 posts) Bio
|
Date
| Reply #3 on Sun 14 Dec 2003 09:22 PM (UTC) |
Message
|
/*
* Profanity Filter
*/
void profanity_filter( char * arg, char * out )
{
char *nbuf, *tbuf, *p;
bool change=TRUE;
int x, v;
nbuf = malloc(strlen(arg)+1);
tbuf = malloc(strlen(arg)+1);
strcpy(nbuf, strlower(arg));
strcpy(tbuf, arg);
while (change)
{
change = FALSE;
for (x = 0; str_cmp(ignore_table[x], "$"); x++)
{
if ( ( p = strstr(nbuf, ignore_table[x]) ) )
{
change = TRUE;
for (v = 0; v < strlen(ignore_table[x]); v++)
*(p+v) = '.';
}
}
}
change = TRUE;
while (change)
{
change = FALSE;
for (x = 0; strcmp(curse_table[x], "$"); x++)
{
if ( ( p = strstr(nbuf, curse_table[x]) ) )
{
change = TRUE;
for (v = 0; v < strlen(curse_table[x]); v++)
*(p+v) = '*';
}
}
}
/*
* Clonse *'s over to the real string
*/
for( x = 0; x < strlen( nbuf ); x++ )
{
if ( nbuf[x] == '*' ) tbuf[x] = '*';
}
strcpy( out, tbuf );
free(nbuf);
free(tbuf);
return;
}
Perhaps its that its using free instead of another function? (DISPOSE perhaps?) I'm not really sure. |
~Nick Cash
http://www.nick-cash.com | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #4 on Mon 15 Dec 2003 12:28 AM (UTC) |
Message
| Free goes with malloc, so that part is OK. There are a number of strcpy calls in that function. I would put a breakpoint on it and step through and see which line is crashing. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Cash
USA (626 posts) Bio
|
Date
| Reply #5 on Mon 15 Dec 2003 05:44 AM (UTC) |
Message
| It doesnt crash every time though. Its kind of strage, but I'm sure its a memory problem. I'll post back in a while with any news I get. |
~Nick Cash
http://www.nick-cash.com | Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #6 on Mon 15 Dec 2003 05:33 PM (UTC) |
Message
| Maybe it's called incorrectly, that is, with bad parameters.
What bothers me from your code is the last time strcpy is used, on the "out" pointer. Chances are you're not calling it correctly at some point, and from the backtrace it appears that's in do_say. |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | Top |
|
Posted by
| Zeno
USA (2,871 posts) Bio
|
Date
| Reply #7 on Tue 16 Dec 2003 01:07 AM (UTC) Amended on Tue 16 Dec 2003 01:13 AM (UTC) by Zeno
|
Message
| Maybe its encountering problems with the quote(s)..? |
Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org | Top |
|
Posted by
| Samson
USA (683 posts) Bio
|
Date
| Reply #8 on Wed 17 Dec 2003 12:27 AM (UTC) |
Message
| The meat of the problem lies in the filter itself:
Quote:
void profanity_filter( char * arg, char * out )
Notice it's being passed these arguments from elsewhere, and you have no way of knowing how large the memory space for them is. The other strcpys the function uses are also bothersome looking to me, but I'm not sure they'd be a problem. It's the one where the contents of 'tbuf' are copied back into 'out' that I suspect is why it crashes.
It's most likely overflowing the memory boundary for *out and corrupting whatever is stored beyond it. | Top |
|
Posted by
| Nick Cash
USA (626 posts) Bio
|
Date
| Reply #9 on Wed 17 Dec 2003 01:16 AM (UTC) |
Message
| How would you reccomend I fix it? |
~Nick Cash
http://www.nick-cash.com | Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #10 on Wed 17 Dec 2003 01:20 AM (UTC) |
Message
| Quoting myself:
Quote: Chances are you're not calling it correctly at some point, and from the backtrace it appears that's in do_say.
So go look at the backtrace, see the line that's calling it, and look for a bad argument. As Samson and I have pointed out that "out" argument is being allocated elsewhere, and quite possibly it's not being allocated correctly just one time. Your backtrace will show you where it was called, and that point will at least give hints as to where the error is. |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #11 on Thu 18 Dec 2003 06:28 AM (UTC) |
Message
|
Quote:
How would you reccomend I fix it?
Forget the profanity filter. There are plenty of ways of getting around them, and get your intent across. eg. a space between each letter. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Cash
USA (626 posts) Bio
|
Date
| Reply #12 on Thu 18 Dec 2003 10:06 PM (UTC) |
Message
| Heh, my thoughts exactly. I had just taken the damn thing out before I read this post. Thanks for the ideas anyways! |
~Nick Cash
http://www.nick-cash.com | Top |
|
Posted by
| Nick Cash
USA (626 posts) Bio
|
Date
| Reply #13 on Mon 29 Dec 2003 12:35 AM (UTC) Amended on Mon 29 Dec 2003 12:40 AM (UTC) by Nick Cash
|
Message
| I was actually looking over stuff in a non-updated version of my code that still contained this and thought of something. Perhaps the reason it was messing up was because it was being called using argument twice, like this:
profanity_filter( argument, argument );
Now to me that seems faulty. Just a thought, not like I'm going to put it back in my code anyways, unless things get out of hand.
It would appear you were right Kysilyan. |
~Nick Cash
http://www.nick-cash.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.
19,921 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top