Angband.oook.cz
Angband.oook.cz
AboutDownloadVariantsLadderForumCompetitionSpoilersComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Development

Reply
 
Thread Tools Display Modes
Old February 12, 2012, 02:17   #1
PowerWyrm
Knight
 
PowerWyrm's Avatar
 
Join Date: Apr 2008
Posts: 781
PowerWyrm is on a distinguished road
[3.4-dev] Obscure bug with queues

I didn't check all the calls to "struct queue" in the code, but the ones in generate.c and obj-util.c assume that the queue can handle "size" pointers when created with a size of "size".

When looking at the code in z-queue.c, pushing "size" items in a queue of size "size" will not work:

Code:
void q_push(struct queue *q, uintptr_t item) {
    q->data[q->tail] = item;
    q->tail = (q->tail + 1) % q->size;
    if (q->tail == q->head) abort();
}
For the last item, abort() will be called (which is quite ugly in itself -- it won't save the character state before quitting for example).

Fix: either allow one more item in the queue, or add +1 to queue size when calling q_new().
__________________
PWMAngband variant maintainer - check http://www.mangband.org/forum/viewforum.php?f=9 to learn more about this new variant!
PowerWyrm is offline   Reply With Quote
Old February 12, 2012, 03:12   #2
d_m
Angband Devteam member
 
d_m's Avatar
 
Join Date: Aug 2008
Location: Philadelphia, PA, USA
Age: 34
Posts: 1,501
d_m is on a distinguished road
Quote:
Originally Posted by PowerWyrm View Post
For the last item, abort() will be called (which is quite ugly in itself -- it won't save the character state before quitting for example).

Fix: either allow one more item in the queue, or add +1 to queue size when calling q_new().
Ooh, good catch!

Yeah, it probably should call something else instead. I will fix this and also try to do something a bit more friendly.
__________________
linux->xterm->screen->pmacs
d_m is offline   Reply With Quote
Old February 12, 2012, 05:08   #3
d_m
Angband Devteam member
 
d_m's Avatar
 
Join Date: Aug 2008
Location: Philadelphia, PA, USA
Age: 34
Posts: 1,501
d_m is on a distinguished road
OK, this is fixed in angband/master and v4/v4-master.

I chose to use (size + 1) in q_new so that if the user wants a queue of size 40 it allocates 41 buckets.

Thanks again for catching this!
__________________
linux->xterm->screen->pmacs
d_m is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Untraceable bug in dev versions - help! Magnate Development 5 September 20, 2011 22:04
A question to the dev team regarding new ID-by-use (possible bug) PowerWyrm Vanilla 3 August 27, 2010 18:30
Dev Bug rdermyer Vanilla 13 December 24, 2008 03:49
Fear Bug In Dev Version LordArcher Vanilla 2 November 30, 2008 21:04
[Dev] major Fear bug. Irashtar Vanilla 1 August 31, 2008 04:03


All times are GMT +1. The time now is 19:09.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.