02 Oct, 2012, arholly wrote in the 1st comment:
Votes: 0
Hi:
I seg faulted during some OLC editing, but not during others and I cannot figure it out.
Quote
Program received signal SIGSEGV, Segmentation fault.
0x08128417 in string_append (ch=0x8388590, pString=0x834acb4) at string.c:72
72 if ( *(*pString + strlen( *pString ) - 1) != '\r' )
(gdb) bt
#0 0x08128417 in string_append (ch=0x8388590, pString=0x834acb4) at string.c:72
#1 0x080fd885 in redit_udesc (ch=0x8388590, argument=0x8385dce "") at olc_act.c:2085
#2 0x080ee559 in redit (ch=0x8388590, argument=0x8385dce "") at olc.c:1049
#3 0x080ecf79 in run_olc_editor (d=0x83859b0) at olc.c:55
#4 0x080982d7 in game_loop_unix (control=8) at comm.c:1036
#5 0x08097c8c in main (argc=2, argv=0xbfffd824) at comm.c:656
(gdb) list
67 {
68 *pString = NULL;
69 }
70 send_to_char( *pString, ch );
71
72 if ( *(*pString + strlen( *pString ) - 1) != '\r' )
73 send_to_char( "\n\r", ch );
74
75 ch->desc->pString = pString;
76
(gdb) info locals
No locals.
(gdb) frame 1
#1 0x080fd885 in redit_udesc (ch=0x8388590, argument=0x8385dce "") at olc_act.c:2085
2085 string_append( ch, &pRoom->udescription );
(gdb) list
2080
2081 EDIT_ROOM(ch, pRoom);
2082
2083 if ( IS_NULLSTR(argument) )
2084 {
2085 string_append( ch, &pRoom->udescription );
2086 return TRUE;
2087 }
2088
2089 send_to_char( "Syntax: udesc\n\r", ch );
(gdb) info locals
pRoom = 0x834ac50


This is the whole of string_append
void string_append( CHAR_DATA *ch, char **pString )
{
send_to_char( "-=======- Entering APPEND Mode -========-\n\r", ch );
send_to_char( " Type .h on a new line for help\n\r", ch );
send_to_char( " Terminate with a ~ or @ on a blank line.\n\r", ch );
send_to_char( "-=======================================-\n\r", ch );

if ( *pString == NULL )
{
*pString = NULL;
}
send_to_char( *pString, ch );

if ( *(*pString + strlen( *pString ) - 1) != '\r' )
send_to_char( "\n\r", ch );

ch->desc->pString = pString;

return;
}
02 Oct, 2012, Davion wrote in the 2nd comment:
Votes: 0
arholly said:
void string_append( CHAR_DATA *ch, char **pString )
{…
if ( *pString == NULL )
{
*pString = NULL;
}

}


You seem to have moved away from stock here. In stock, it sets *pString to a empty string rather than NULL. See if returnin it to stock fixes your problem.

if ( *pString == NULL )
{
*pString = str_dup("")
}
02 Oct, 2012, arholly wrote in the 3rd comment:
Votes: 0
Well, that works I think. However, now I've got an entirely new problem. It looks like it is truncating each word after 4 characters.
Quote
-=======- Entering APPEND Mode -========-
Type .h on a new line for help
Terminate with a ~ or @ on a blank line.
-=======================================-
Almost engulfed by small, bean-filled animals, the desk appears to be
very child-friendly. A silver bowl filled with various types of candy is
decorated with a clash of flowers and dinosaurs. Across the front, a gold
plate covered with seemingly thick glass presents the name 'Alissa Reone'.
>
.h
Sedit help (commands on blank line):
.r 'old' 'new' - replace a substring
(requires '', "")
.n 'location' - insert a return after substring.
(requires '', "")
.h - get help (this info)
.s - show string so far
.l - show string so far with line numbers
.f - (word wrap) string
.w - (word wrap without reducing blank lines) string
.c - clear string so far
@ - end string
>
.w
Lines wrapped.
>
.s
String so far:
Almo eng by sma bea ani the des app to be
very chi A sil bow fil wit var typ of can
is deco wit a cla of flo and din Ac the fro a
gold plat cov wit see thi gla pre the nam 'Al
Reon
>
02 Oct, 2012, arholly wrote in the 4th comment:
Votes: 0
Ok, I traced it down to this function. The other functions for formatting seem to work fine.
char *desc_pretty( char *string, int start, int lines, bool no_free )
{
char buf[MSL]={'\0'};
char wordbuf[MAX_INPUT_LENGTH]={'\0'};
char *p, *bp, *wp;
int i = 0,inword = 0;
/* find starting line to pretty-ify */
for( i = 1, p = string, bp = buf; *p != 0 && i < start; p++)
{
*bp++ = *p;
if( *p == '\r' )
i++;
}
*bp = 0;
/* now build pretty lines from raw ones */
pretty_proc( bp, NULL ); /* init pretty processor */
for( i = inword = 0, wp = wordbuf; i < lines && *p != 0; p++ )
{
if( *p == ' ' )
{
if( inword )
{
inword = 0;
*wp = 0;
pretty_proc( NULL, wordbuf );
wp = wordbuf;
}
*wp++ = ' ';
}
else if( *p == '\r' )
{
i++; /* inc line count */
if( inword )
{
inword = 0;
*wp = 0;
pretty_proc( NULL, wordbuf );
wp = wordbuf;
if( p[1] == '\n' || p[1] == ' ' || p[1] == 0)
pretty_proc( NULL, "\n\r" );
else
pretty_proc( NULL, " " );
}
else
{
pretty_proc( NULL, "\n\r" );
wp = wordbuf;
}
}
else if( *p == '\n' )
continue;
else {
inword = 1;
*wp++ = *p;
}
}
/* and append any leftover lines directly */
strncat( buf, p, sizeof(buf) );
/* and swap in the new editted description */
if(no_free)
{
snprintf(string, sizeof(string), "%s", buf);
return string;
}
PURGE_DATA( string );
return str_dup( buf );
}
03 Oct, 2012, arholly wrote in the 5th comment:
Votes: 0
Ok, I'm having another seg fault issue. It seems that when a description is Null, it seems to crash.

Quote
Program received signal SIGSEGV, Segmentation fault.
0x00b0cd20 in strcpy () from /lib/libc.so.6
(gdb) bt
#0 0x00b0cd20 in strcpy () from /lib/libc.so.6
#1 0x081292ce in string_add (ch=0x838a2e8, argument=0x8387c89 "This is a test.") at string.c:244
#2 0x08098236 in game_loop_unix (control=8) at comm.c:1030
#3 0x08097c23 in main (argc=2, argv=0xbfffd824) at comm.c:655
(gdb) list
582
583 purgeExtractedWorldData();
584 log_string("Project Twilight has completed its cleanup procedure and may now shutdown.");
585 return;
586 }
587
588 int main( int argc, char **argv )
589 {
590 struct timeval now_time;
591 bool fCopyOver = FALSE;
(gdb) frame 1
#1 0x081292ce in string_add (ch=0x838a2e8, argument=0x8387c89 "This is a test.") at string.c:244
244 strcpy( buf, *ch->desc->pString );
(gdb) list
239 ch->desc->pString = NULL;
240 return;
241 }
242
243 // strncpy( buf, *ch->desc->pString, sizeof(buf) );
244 strcpy( buf, *ch->desc->pString );
245
246 /*
247 * Truncate strings to MAX_STRING_LENGTH.
248 * ————————————–
(gdb) info locals
buf = '\000' <repeats 4095 times>
__FUNCTION__ = "string_add"
(gdb) print *ch->desc->pString
$1 = 0x0
04 Oct, 2012, Rarva.Riendf wrote in the 6th comment:
Votes: 0
Quote
strcpy( buf, *ch->desc->pString );

well *NULL will not work.
0.0/6