Viewing Issue Simple Details Jump to Notes ] Wiki ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0005084 [DCSS] Bug Report minor always 2011-12-18 03:08 2014-09-11 17:46
Reporter stsp View Status public  
Assigned To doy
Priority normal Resolution done  
Status resolved   Product Branch 0.9 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.
Additional Information
Tags No tags attached.
Attached Files ? file icon divide-by-zero-0.9.1.diff [^] (453 bytes) 2011-12-18 03:08 [Show Content]
? file icon divide-by-zero.diff [^] (675 bytes) 2011-12-18 03:10 [Show Content]

- Relationships

-  Notes
stsp (reporter)
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.
stsp (reporter)
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/
#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
0000003 0x00000000004b9cec in die_noline (format=Could not find the frame base for "
die_noline(char const*, ...)".
) at
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)
0000007 0x00000000009b0312 in player_view_update () at
0000008 0x00000000009b05b6 in viewwindow (show_updates=true) at
0000009 0x000000000096df64 in redraw_screen () at
0000010 0x0000000000478e2c in display_notes () at
0000011 0x00000000004ab4ed in _keyhelp_keyfilter (ch=58) at
0000012 0x0000000000729a06 in formatted_scroller::process_key (
    this=0x7f7ffffec950, keyin=58) at
0000013 0x000000000073005e in Menu::do_menu (this=0x7f7ffffec950) at
0000014 0x00000000007301a3 in Menu::show (this=0x7f7ffffec950,
    reuse_selections=false) at
0000015 0x00000000004a6ec6 in _show_keyhelp_menu (lines=@0x7f7ffffecc40,
    with_manual=true, easy_exit=false, hotkey=0,
    highlight_string=@0x7f7ffffecc60) at
0000016 0x00000000004a7001 in list_commands (hotkey=0, do_redraw_screen=false,
    highlight_string=@0x7f7ffffecda0) at
0000017 0x0000000000944040 in _show_startup_menu (ng_choice=0x7f7ffffed090,
    defaults=@0x7f7ffffed050) at
0000018 0x0000000000944bce in startup_step () at
0000019 0x00000000006d2c58 in _launch_game () at
0000020 0x00000000006d2ff4 in _launch_game_loop () at
#21 0x00000000006d325b in main (argc=1, argv=0x7f7ffffed240) at
(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)
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/
stsp (reporter)
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.
Wensleydale (updater)
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.
stsp (reporter)
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.
komondorok (reporter)
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.
doy (developer)
2014-09-11 17:46

This was fixed quite a while ago in 0.10-a0-1193-g970ddb3.

- 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

Mantis 1.1.8[^]
Copyright © 2000 - 2009 Mantis Group
Powered by Mantis Bugtracker