From 2b8903cd7a88e972792bd070a7f6bf85f33de780 Mon Sep 17 00:00:00 2001 From: "nethack.allison" Date: Sat, 1 Jul 2006 18:44:18 +0000 Subject: [PATCH] wrote: > NetHack feedback form submitted by > on Friday, June 30, 2006 at 17:31:12 > --------------------------------------------------------------------------- > > mailversion:1.35 > > nhversion:3.4.3 > > nhfrom:Our 3.4.3 source release, unmodified > comments: > telnet nethack.alt.org with the terminal set to 21 rows. > Choose to pick a char, not accept pot luck, and game segfaults. > (same happens from linux console) I was able to reproduce something similar in win32 by setting the console to 21 rows. As he stated, don't let the game pick you character for you to reproduce the problem. As soon as I chose Archeologist the problem occurred: Where: In hack.c, weight_cap() if (Levitation || Is_airlevel(&u.uz) /* */ #ifdef STEED || (u.usteed && strongmonst(u.usteed->data)) #endif ) Variables: carrcap 200 u.usteed 0x00000000 &u.uz 0x005e54aa youmonst.data 0x00000000 Examination of the preprocessor output of that section of code reveals that "Levitation" becomes: (u.uprops[47].intrinsic || u.uprops[47].extrinsic || ((youmonst.data)->mlet == 5)) so it is the is_floater(youmonst.data) causing the crash. Call stack: weight_cap() line 2300 + 24 bytes inv_weight() line 2342 + 5 bytes calc_capacity(int 0) line 2354 + 5 bytes near_capacity() line 2365 + 7 bytes bot() line 607 + 5 bytes docorner(int 47, int 19) line 2378 erase_menu_or_text(int 5, WinDesc * 0x00a22550, char 0) line 994 + 25 bytes tty_dismiss_nhwindow(int 5) line 1664 + 15 bytes tty_select_menu(int 5, int 1, mi * * 0x0006fc40) line 2248 + 9 bytes tty_player_selection() line 442 + 16 bytes pcmain(int 3, char * * 0x00a20eb0) line 457 main(int 3, char * * 0x00a20eb0) line 91 + 13 bytes This adds a check for a valid youmonst.data in bot(). --- doc/fixes34.4 | 2 ++ src/botl.c | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/doc/fixes34.4 b/doc/fixes34.4 index eac81d007..e3c785195 100644 --- a/doc/fixes34.4 +++ b/doc/fixes34.4 @@ -238,6 +238,8 @@ use alternate phrasing when life drain attack affects non-living creature bypass "wait! there's a creature hidden there" when attacking a hidden monster sensed by ongoing monster detection remove makedefs.c dependency that time_t and long are the same size +terminal window set to 21 lines can cause a crash during player selection + menus; have bot() check for valid youmonst.data Platform- and/or Interface-Specific Fixes diff --git a/src/botl.c b/src/botl.c index 0283858c9..01e23477e 100644 --- a/src/botl.c +++ b/src/botl.c @@ -308,8 +308,10 @@ bot2() void bot() { - bot1(); - bot2(); + if (youmonst.data) { + bot1(); + bot2(); + } context.botl = context.botlx = 0; } @@ -604,11 +606,13 @@ bot() static int idx = 0, idx_p, idxmax; boolean updated = FALSE; unsigned anytype; - int i, pc, chg, cap = near_capacity(); + int i, pc, chg, cap; struct istat_s *curr, *prev; boolean valset[MAXBLSTATS]; if (!blinit) panic("bot before init."); + if (!youmonst.data) return; + cap = near_capacity(); idx_p = idx; idx = 1 - idx; /* 0 -> 1, 1 -> 0 */ -- 2.40.0