10 Apr, 2010, Zula wrote in the 1st comment:
Votes: 0
Hey, just patched in olc and I am getting an error in group add when creating new char.

void group_add( CHAR_DATA *ch, const char *name, bool deduct)
{
int sn,gn;

if (IS_NPC(ch)) /* NPCs do not have skills */
return;

sn = skill_lookup(name);

if (sn != -1)
{
/**/ if (ch->pcdata->learned[sn] == 0) /* i.e. not known */
{
ch->pcdata->learned[sn] = 1;
if (deduct)
ch->pcdata->points += skill_table[sn].rating[ch->class];
}
return;
}

/* now check groups */

gn = group_lookup(name);

if (gn != -1)
{
if (ch->pcdata->group_known[gn] == FALSE)
{
ch->pcdata->group_known[gn] = TRUE;
if (deduct)
ch->pcdata->points += group_table[gn].rating[ch->class];
}
gn_add(ch,gn); /* make sure all skills in the group are known */
}
}


It error is when it checks to see if it's learned, it finds the sn properly but cannot access ch->pcdata->learned. It can access ch->pcdata, but when I try to print ch->pcdata->learned, it says cannot access memory
10 Apr, 2010, Runter wrote in the 2nd comment:
Votes: 0
Just cause you can access ch->pcdata and just because it's not set to 0 does not mean it's valid memory it's pointing to.

This is likely a case of what the old timers called a 'rogue pointer'. But I guess since we're using the same language we're free to use the term too. ;)

There's a variety of ways to get a rogue pointer. A common way is freeing the memory and then using it later. Use a memory profiling tool like valgrind. It'll save you a lot of footwork. But honestly, these types of errors are always a lot of fun to track down. :)
10 Apr, 2010, Zula wrote in the 3rd comment:
Votes: 0
From nanny before the call for group_add, ch->pcdata->learned has a value of "{0 <repeats 150 times>}", but then when I step and it goes to group_add, it is no longer accessible
10 Apr, 2010, Zula wrote in the 4th comment:
Votes: 0
Strange, well, I erased some empty space and then hit enter, saved, recompiled and working fine….?
0.0/4