Dungeon Crawl Stone Soup Tracker - DCSS
|
Viewing Issue Advanced Details |
|
ID:
|
Category:
|
Severity:
|
Reproducibility:
|
Date Submitted:
|
Last Update:
|
5084 |
Bug Report |
minor |
always |
2011-12-18 03:08 |
2014-09-11 17:46 |
|
Reporter:
|
stsp |
Local or Remote:
|
Local |
|
Assigned To:
|
doy |
Operating System:
|
Linux |
|
Priority:
|
normal |
Console or Tiles:
|
Tiles |
|
Status:
|
resolved |
Product Branch:
|
0.9 ancient branch |
|
Product Version:
|
0.9.1 |
Resolution:
|
done |
|
Projection:
|
none |
|
|
|
ETA:
|
none |
Fixed in Branch:
|
0.16 ancient branch |
|
|
Summary:
|
0005084: divide-by-zero in _get_exp_progress |
Description:
|
_get_exp_progress() divides by zero if the following is done:
Enter a game (e.g. via tutorial) and quit it (ctrl-q, "yes").
Now go into the 'Instructions' section from the main menu and
try to browse characters notes using ':'.
The notes list was empty in my case, I didn't have any notes stored.
Press Escape to leave the screen, and the divide by zero happens.
Fix for 0.9.1 attached. |
Steps To Reproduce:
|
|
Additional Information:
|
|
System Description:
|
|
Relationships | |
Attached Files:
|
divide-by-zero-0.9.1.diff [^] (453 bytes) 2011-12-18 03:08 [Show Content] [Hide Content]--- source/output.cc.orig Sun Dec 18 01:13:46 2011
+++ source/output.cc Sun Dec 18 01:30:38 2011
@@ -702,6 +702,8 @@ static std::string _get_exp_progress()
return "";
const int current = exp_needed(you.experience_level);
+ if (current == 0)
+ return "";
const int next = exp_needed(you.experience_level + 1);
return make_stringf("%2d%%",
(you.experience - current) * 100 / (next - current));
divide-by-zero.diff [^] (675 bytes) 2011-12-18 03:10 [Show Content] [Hide Content]commit a961af0f2f0a7a266ff276723a1147b93933de10
Author: Stefan Sperling <stsp@stsp.name>
Date: Sun Dec 18 01:29:03 2011 +0100
Avoid divide-by zero.
Signed-off-by: Stefan Sperling <stsp@stsp.name>
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index 37dd666..7ae78bd 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -2788,6 +2788,8 @@ int get_exp_progress()
return 0;
const int current = exp_needed(you.experience_level);
+ if (current == 0)
+ return 0;
const int next = exp_needed(you.experience_level + 1);
return ((you.experience - current) * 100 / (next - current));
}
|
|
Issue History |
Date Modified |
Username |
Field |
Change |
2011-12-18 03:08 |
stsp |
New Issue |
|
2011-12-18 03:08 |
stsp |
File Added: divide-by-zero-0.9.1.diff |
|
2011-12-18 03:10 |
stsp |
File Added: divide-by-zero.diff |
|
2011-12-18 03:11 |
stsp |
Note Added: 0016312 |
|
2011-12-18 03:15 |
stsp |
Note Added: 0016313 |
|
2011-12-18 03:26 |
stsp |
Note Added: 0016314 |
|
2011-12-18 16:58 |
Wensleydale |
Note Added: 0016317 |
|
2011-12-18 18:58 |
stsp |
Note Added: 0016319 |
|
2011-12-27 21:45 |
komondorok |
Note Added: 0016404 |
|
2013-03-31 07:16 |
mumra |
Issue Monitored: mumra |
|
2014-09-11 17:46 |
doy |
Note Added: 0027207 |
|
2014-09-11 17:46 |
doy |
Status |
new => resolved |
2014-09-11 17:46 |
doy |
Fixed in Branch |
=> 0.16 development branch |
2014-09-11 17:46 |
doy |
Resolution |
open => done |
2014-09-11 17:46 |
doy |
Assigned To |
=> doy |
Notes |
|
(0016312)
|
stsp
|
2011-12-18 03:11
|
|
Attachment 'divide-by-zero.diff' is a fix for the current code in git. The code has been moved to a different file so a separate patch is needed. |
|
|
(0016313)
|
stsp
|
2011-12-18 03:15
|
|
Note also that a different problem happens with this fix in place.
I am not sure how to fix this one.
Here's what I'm seeing when I try the reproduction recipe described above with my patch in place:
ERROR: range check error (-46 / 17)
Program received signal SIGABRT, Aborted.
[Switching to process 18312, thread 0x202a2b800]
0(gdb) bt
#0 0x000000020dea50da in kill () from /usr/lib/libc.so.61.0
#1 0x000000020df0b7a1 in abort () at /usr/src/lib/libc/stdlib/abort.c:68
0000002 0x00000000004b9baf in _BreakStrToDebugger (mesg=Could not find the frame bas
e for "_BreakStrToDebugger".
) at dbg-asrt.cc:728
0000003 0x00000000004b9cec in die_noline (format=Could not find the frame base for "
die_noline(char const*, ...)".
) at dbg-asrt.cc:792
0000004 0x00000000009b4491 in FixedVector<FixedVector<unsigned int, 17>, 17>::operat
or[] (this=0x130e5a8, index=18446744073709551570) at fixedvector.h:70
0000005 0x00000000009b4515 in FixedArray<unsigned int, 17, 17>::operator()<coord_def
> (this=0x130e5a8, i=@0x7f7ffffec320) at fixedarray.h:65
0000006 0x00000000009b025c in player_view_update_at (gc=@0x7f7ffffec440)
at view.cc:900
0000007 0x00000000009b0312 in player_view_update () at view.cc:913
0000008 0x00000000009b05b6 in viewwindow (show_updates=true) at view.cc:1040
0000009 0x000000000096df64 in redraw_screen () at stuff.cc:328
0000010 0x0000000000478e2c in display_notes () at chardump.cc:1320
0000011 0x00000000004ab4ed in _keyhelp_keyfilter (ch=58) at command.cc:1901
0000012 0x0000000000729a06 in formatted_scroller::process_key (
this=0x7f7ffffec950, keyin=58) at menu.cc:1684
0000013 0x000000000073005e in Menu::do_menu (this=0x7f7ffffec950) at menu.cc:339
0000014 0x00000000007301a3 in Menu::show (this=0x7f7ffffec950,
reuse_selections=false) at menu.cc:325
0000015 0x00000000004a6ec6 in _show_keyhelp_menu (lines=@0x7f7ffffecc40,
with_manual=true, easy_exit=false, hotkey=0,
highlight_string=@0x7f7ffffecc60) at command.cc:2094
0000016 0x00000000004a7001 in list_commands (hotkey=0, do_redraw_screen=false,
highlight_string=@0x7f7ffffecda0) at command.cc:2706
0000017 0x0000000000944040 in _show_startup_menu (ng_choice=0x7f7ffffed090,
defaults=@0x7f7ffffed050) at startup.cc:836
0000018 0x0000000000944bce in startup_step () at startup.cc:925
0000019 0x00000000006d2c58 in _launch_game () at main.cc:350
0000020 0x00000000006d2ff4 in _launch_game_loop () at main.cc:328
#21 0x00000000006d325b in main (argc=1, argv=0x7f7ffffed240) at main.cc:288
(gdb) frame 5
0000005 0x00000000009b4515 in FixedArray<unsigned int, 17, 17>::operator()<coord_def
> (this=0x130e5a8, i=@0x7f7ffffec320) at fixedarray.h:65
65 return mData[i.x][i.y];
(gdb) p i
$11 = (const coord_def &) @0x7f7ffffec320: {x = -46, y = -19}
(gdb) up
0000006 0x00000000009b025c in player_view_update_at (gc=@0x7f7ffffec440)
at view.cc:900
900 env.tile_bk_fg(gc) = env.tile_fg(ep);
(gdb) p gc
$12 = (const coord_def &) @0x7f7ffffec440: {x = 0, y = 0}
x000000020dea50da in kill () from /usr/lib/libc.so.61.0 |
|
|
(0016314)
|
stsp
|
2011-12-18 03:26
|
|
Actually it is crucial to enter and quit the tutorial for this bug to happen. After quitting from a normal game the problem does not trigger. |
|
|
(0016317)
|
Wensleydale
|
2011-12-18 16:58
|
|
I wasn't able to reproduce during my local testing, neither in master nor at the 0.9 tag. After entering tutorial mode, quitting, restarting the game (because quitting closes the game window; does this happen to you, stsp?), selecting the instructions menu, and pressing `:` to browse character notes, I was immediately punted back out to the main menu. In fact, it seems as though in my case it is impossible to browse the character notes from the main menu even if you currently have a save where your character has made notes.
Still, someone who knows the code better might want to take a look at this patch and see if it's something we should be using anyway. |
|
|
(0016319)
|
stsp
|
2011-12-18 18:58
|
|
No, I don't need to restart the exectuble.
I start a tutorial, say, lesson 1.
I press space to scroll through the introductory message.
When I hit Ctrl-q in the tutorial, it asks me if i want to quit. I say "yes".
Then I'm back in the tutorial selection screen.
There, I hit escape to go back to the main screen.
Now i pick Instructions and then hit the colon.
It shows a screen with the headers for the notes, but no notes.
There I hit Escape and it hits the divide by zero. |
|
|
(0016404)
|
komondorok
|
2011-12-27 21:45
|
|
When I set restart_after_game=true I can reproduce this in 0.9.1. I don't think the patch will solve the issue because the negative vector subscript is not the root problem, just a symptom - it tried to draw the player view when no game is ongoing. |
|
|
(0027207)
|
doy
|
2014-09-11 17:46
|
|
This was fixed quite a while ago in 0.10-a0-1193-g970ddb3. |
|