Question about a core dump (D20, not TBA)

Login to reply  Page: « < 1 of 1 > »
18 Apr 2010 - 03:142482
Question about a core dump (D20, not TBA)
First off, I love TBA, it's a nice blank slate to begin from with several necessities already added. I am currently also tinkering with the D20 code built off CWG Rasputin code.
D20 Link: http://cid-1573e9686728b039.skydrive.live.com/self.aspx/.Public/d20MUD.zip

Ok upon choosing your class, it core dumps.
running GDB I find.


 Program received signal SIGSEGV, Segmentation fault.
0x08176c17 in display_levelup_changes (ch=0x9872b28, apply_changes=1) at interpreter.c:4062
4062                    if (ch->levelup->skills[i] > 0) {
(gdb)
(gdb) run -q -p 4796
The program being debugged has been started already.
Start it from the beginning? (y or n) n
Please answer y or n.
The program being debugged has been started already.
Start it from the beginning? (y or n) Program not restarted.
(gdb) where
#0  0x08176c17 in display_levelup_changes (ch=0x9872b28, apply_changes=1) at interpreter.c:4062
#1  0x080d8673 in do_advance_level (ch=0x9872b28, whichclass=0, manual=1) at class.c:3779
#2  0x080d59a8 in advance_level (ch=0x9872b28, whichclass=0) at class.c:3175
#3  0x081780e3 in gain_level (ch=0x9872b28, whichclass=0) at limits.c:363
#4  0x0815ac51 in handle_gain (keeper=0x95d7930, guild_nr=0, ch=0x9872b28, argument=0xbfbc3125 "mage") at guild.c:918
#5  0x0815c670 in guild (ch=0x9872b28, me=0x95d7930, cmd=161, argument=0xbfbc3124 " mage") at guild.c:1419
#6  0x0816ec63 in special (ch=0x9872b28, cmd=161, arg=0xbfbc3124 " mage") at interpreter.c:1801
#7  0x0816d467 in command_interpreter (ch=0x9872b28, argument=0xbfbc3120 "gain mage") at interpreter.c:1089
#8  0x080dfa7c in game_loop (mother_desc=6) at comm.c:965
#9  0x080def24 in init_game (port=4796) at comm.c:586
#10 0x080de902 in main (argc=4, argv=0xbfbc5474) at comm.c:417
(gdb) Quit

Now it has been the better part of about 12 years since I dabbled with muds or any *nix environment but it's coming back to me slowly. Line 0 is my problem area correct?

And if so can any one see what might be wrong with this?


 void display_levelup_changes(struct char_data *ch, int apply_changes) {

	int i = 0;

	send_to_char(ch,
			"\r\n"
			"Your Level Summary:\r\n"
			"\r\n"
			"Skills:\r\n"
			"\r\n"
			);

	for (i = 0; i < SKILL_TABLE_SIZE + 1; i++) {
		if (ch->levelup->skills[i] > 0) { /* THIS SEEMS TO BE THE PROBLEM HERE -SOKOL */
			send_to_char(ch, "%s raised from %d to %d.\r\n", spell_info[i].name, GET_SKILL(ch, i), GET_SKILL(ch, i) +ch->levelup->skills[i]);
			if (apply_changes)
				GET_SKILL_BASE(ch, i) += ch->levelup->skills[i];
		}
	}

	send_to_char(ch,
			"\r\n"
			"Feats:\r\n"
			"\r\n"
			);

	for (i = 0; i < NUM_FEATS_DEFINED; i++) {
		if (ch->levelup->feats[i] > 0) {
			send_to_char(ch, "%s", feat_list[i].name);
			if (apply_changes)
				HAS_FEAT(ch, i)++;

			switch (i) {
			case FEAT_IMPROVED_CRITICAL:
			case FEAT_WEAPON_FINESSE:
			case FEAT_WEAPON_FOCUS:
			case FEAT_WEAPON_SPECIALIZATION:
			case FEAT_GREATER_WEAPON_FOCUS:
			case FEAT_GREATER_WEAPON_SPECIALIZATION:
			case FEAT_IMPROVED_WEAPON_FINESSE:
			case FEAT_EXOTIC_WEAPON_PROFICIENCY:
			case FEAT_MONKEY_GRIP:
			case FEAT_POWER_CRITICAL:
				if (apply_changes)
					SET_COMBAT_FEAT(ch, feat_to_subfeat(i), ch->levelup->feat_weapons[i]);
				send_to_char(ch, " (%s)", weapon_list[ch->levelup->feat_weapons[i]].name);
				break;
			case FEAT_SKILL_FOCUS:
			case FEAT_EPIC_SKILL_FOCUS:
				if (apply_changes)
					ch->player_specials->skill_focus[ch->levelup->feat_skills[i] - SKILL_LOW_SKILL] += 1;
				send_to_char(ch, " (%s)", spell_info[ch->levelup->feat_skills[i]].name);
				break;
			}
			send_to_char(ch, "\r\n");
		}
	}

	send_to_char(ch,
			"\r\n"
			"Ability Score Trains:\r\n"
			"\r\n"
			);

	for (i = 0; i < 6; i++) {
		if (ch->levelup->trains[i] > 0) {
			switch (i) {
			case 0:
				if (apply_changes)
					ch->real_abils.str += ch->levelup->trains[i];
				send_to_char(ch, "Strength raised from %d to %d.\r\n", ch->real_abils.str, ch->real_abils.str + ch->levelup->trains[i]);
				break;
			case 1:
				if (apply_changes)
					ch->real_abils.dex += ch->levelup->trains[i];
				send_to_char(ch, "Dexterity raised from %d to %d.\r\n", ch->real_abils.dex, ch->real_abils.dex + ch->levelup->trains[i]);
				break;
			case 2:
				if (apply_changes)
					ch->real_abils.con += ch->levelup->trains[i];
				send_to_char(ch, "Constitution raised from %d to %d.\r\n", ch->real_abils.con, ch->real_abils.con + ch->levelup->trains[i]);
				break;
			case 3:
				if (apply_changes)
					ch->real_abils.intel += ch->levelup->trains[i];
				send_to_char(ch, "Intelligence raised from %d to %d.\r\n", ch->real_abils.intel, ch->real_abils.intel + ch->levelup->trains[i]);
				break;
			case 4:
				if (apply_changes)
					ch->real_abils.wis += ch->levelup->trains[i];
				send_to_char(ch, "Wisdom raised from %d to %d.\r\n", ch->real_abils.wis, ch->real_abils.wis + ch->levelup->trains[i]);
				break;
			case 5:
				if (apply_changes)
					ch->real_abils.cha += ch->levelup->trains[i];
				send_to_char(ch, "Charisma raised from %d to %d.\r\n", ch->real_abils.cha, ch->real_abils.cha + ch->levelup->trains[i]);
				break;

			}
		}
	}
}

So it seems:

 if (ch->levelup->skills[i] > 0) { /* THIS SEEMS TO BE THE PROBLEM HERE -SOKOL */
is the problem or the last thing loaded before the crash. I apologize for asking this when it's not directly TBA related, but the mud community has gotten very small, and the places to ask question like these has as well.

Thanks,
Sokol


18 Apr 2010 - 20:332485
Question about a core dump (D20, not TBA)
Quote sokol:

...
 Program received signal SIGSEGV, Segmentation fault.
...
 if (ch->levelup->skills[i] > 0) { /* THIS SEEMS TO BE THE PROBLEM HERE -SOKOL */

This means either ch or ch->levelup is NULL or pointing to free'd memory. It would seem ch is ok, according to the backtrace, so try having a look at ch->levelup.


__________________
You know who I am.
Login to reply  Page: « < 1 of 1 > »