upgrading to olc2

Posted by Typhon on Tue 20 Jul 2004 08:47 PM — 4 posts, 17,896 views.

USA #0
ok.. fair warning this is gonna be a long post :p
im running a copy of quickmud, right now im tryin to do this at home so im also running cygwin. normally the mud runs on a redhat server. now then for the post.

quickmud has olc 1.7 i believe installed.. im trying to upgrade to olc2 and its been a little difficult. i had to rip out some of the code we put in just to get to be able to manually install the patch. funny thing is i got the patch to install correctly the first time, had to clean up a few minor things, but it was a fairly clean install. the new olc code uses a -FIRST_BOOT option when you first install it so that the mud can convert all the races/classes/skills etc to tables. the conversion only happens in the tablesave.c file. it loads all the tables to memory then writes them to file. well after the instal it writes the skills no problem, however it gets to the races and the mud segfaults. this is what i get when i compile:
Quote:

tablesave.c: In function `grabar_tabla_comandos':
tablesave.c:571: warning: assignment discards qualifiers from pointer target type
tablesave.c:576: warning: assignment discards qualifiers from pointer target type
tablesave.c: In function `grabar_razas':
tablesave.c:809: warning: assignment discards qualifiers from pointer target type
tablesave.c:814: warning: assignment discards qualifiers from pointer target type
tablesave.c:820: warning: passing arg 4 of `save_struct' discards qualifiers from pointer target type
tablesave.c: In function `grabar_skills':
tablesave.c:877: warning: passing arg 4 of `save_struct' discards qualifiers from pointer target type

granted its only warnings, so the mud compiles. using gdb this is what i get:
Quote:

Starting program: /home/typ/th2/th/src/rom.exe
Tue Jul 20 16:03:45 2004 :: Loading configuration settings from ../area/qmconfig
.rc.
Tue Jul 20 16:03:45 2004 :: Set IP address to 0.0.0.0
Tue Jul 20 16:03:45 2004 :: Loaded 0 mobprogs.
Tue Jul 20 16:03:45 2004 :: Loaded 2 mobprogs.
Tue Jul 20 16:03:45 2004 :: Loaded 2 mobprogs.
Tue Jul 20 16:03:45 2004 :: Loaded 5 mobprogs.
Tue Jul 20 16:03:45 2004 :: Loaded 11 mobprogs.
Tue Jul 20 16:03:45 2004 :: Loaded 11 mobprogs.
Tue Jul 20 16:03:45 2004 :: Loaded 11 mobprogs.
Tue Jul 20 16:03:45 2004 :: Loaded 11 mobprogs.
Tue Jul 20 16:03:45 2004 :: Loaded 11 mobprogs.
Tue Jul 20 16:03:45 2004 :: [*****] BUG: Fix_exits: 240:3 -> 250:1 -> 245.
Tue Jul 20 16:03:45 2004 :: Check Levels:
Tue Jul 20 16:03:45 2004 :: Object: (VNUM 505)(Level 0) {DA Mauser Pistol{x
Tue Jul 20 16:03:45 2004 :: Mob: (VNUM 503)(Level 50) {DThe Mob Boss BigAl{x

Program received signal SIGSEGV, Segmentation fault.
0x004b0a46 in save_struct (fp=0xa042064, tipobase=0x4d9b80, tabla=0x4b02b0, puntero=0x446390) at tablesave.c:472
472 fprintf( fp, "%s %s~\n", temp->campo, !IS_NULLSTR(*pcadena) ? *pcadena : "" );
(gdb) bt
#0 0x004b0a46 in save_struct (fp=0xa042064, tipobase=0x4d9b80, tabla=0x4b02b0, puntero=0x446390) at tablesave.c:472
#1 0x004b0f96 in grabar_razas () at tablesave.c:820
#2 0x0044c163 in boot_db () at db.c:455
#3 0x004404ac in main (argc=1, argv=0xa041f10) at comm.c:443


this is the code im having a problem with.. its has alot to do with pointers and double pointers
but this is what i have.
Quote:

case CAMPO_STRING:
pcadena = (char **) ((int) temp->puntero_campo - (int) tipobase + (int) puntero);
472-> fprintf( fp, "%s %s~\n", temp->campo, !IS_NULLSTR(*pcadena) ? *pcadena : "" );
break;
and
case CAMPO_BOOL:
pbool = (bool *) ((int) temp->puntero_campo - (int) tipobase + (int) puntero);
518-> fprintf( fp, "%s %s\n", temp->campo,
(*pbool == TRUE) ? "true" : "false" );
break;

in the first case all i changed was !IS_NULLSTR(*pcadena) to !IS_NULLSTR(&pcadena) and the mud compiled and ran again, but to no avail. the mud segfaulted at the case CAMPO_BOOL: this is what gdb had to say about that..
Quote:

Program received signal SIGSEGV, Segmentation fault.
0x610ba4c1 in strlen () from /usr/bin/cygwin1.dll
(gdb) bt
#0 0x610ba4c1 in strlen () from /usr/bin/cygwin1.dll
#1 0x610c1294 in vfprintf () from /usr/bin/cygwin1.dll
#2 0x610bfb44 in vfprintf () from /usr/bin/cygwin1.dll
#3 0x610b326f in fprintf () from /usr/bin/cygwin1.dll
#4 0x004b0b75 in save_struct (fp=0xa042064, tipobase=0x4d9b80,
tabla=0x4b02b0, puntero=0x446390) at tablesave.c:518
#5 0x004b0f86 in grabar_razas () at tablesave.c:820
#6 0x0044c163 in boot_db () at db.c:455
#7 0x004404ac in main (argc=1, argv=0xa041f10) at comm.c:443


after that im lost.. thanks for takin a look
-typhon/blade
Amended on Tue 20 Jul 2004 08:49 PM by Typhon
Australia Forum Administrator #1
Quote:

in the first case all i changed was !IS_NULLSTR(*pcadena) to !IS_NULLSTR(&pcadena) and the mud compiled and ran again, but to no avail


I wouldn't do that, you are totally changing the meaning. The * dereferences the pointer, however the & takes the address of it, which is the opposite.

In gdb, I would check out temp, eg. p temp, and also pcadena, eg. p pcadena
USA #2
ok i changed it back to what it was originally and i get...
Quote:

0x004b0a86 in save_struct (fp=0xa042064, tipobase=0x4d9b80, tabla=0x4b02f0, puntero=0x446390) at tablesave.c:473
473 fprintf( fp, "%s %s~\n", temp->campo, !IS_NULLSTR(*pcadena) ? *pcadena : "" );
(gdb) print temp->campo
$1 = 0x4b02b2 "who_name"
(gdb) print pcadena
$2 = (char **) 0x446394
(gdb) print *pcadena
$3 = 0x67616d00 <Address 0x67616d00 out of bounds>
(gdb) print **pcadena
Cannot access memory at address 0x67616d00

but this is still what i get in the race file that is stored...
Quote:

#RAZA
name hylan~
pc true
act 0
aff COTZ
off EFQR
imm 0
res HJNS
vuln BM
form H
parts PUV
remort false
points 5
class_mult 100 100 100 100 @
who_name {YHylan{x ~
skills ~ ~ ~ ~ ~ @~
stats 13 15 15 13 14 @
max_stats 17 22 21 19 20 @
size medium~
#END

#RAZA
nam

:(
thanks again
-typhon/blade-
Australia Forum Administrator #3
Dunno. Looks like pcadena has a bad address in it. You'll have to work out why.