We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 958 - Timer Underflow
Summary: Timer Underflow
Status: RESOLVED INVALID
Alias: None
Product: SDL
Classification: Unclassified
Component: timer (show other bugs)
Version: HG 1.2
Hardware: All All
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-22 06:53 UTC by dino puller
Modified: 2010-02-24 01:15 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dino puller 2010-02-22 06:53:55 UTC
If you try to set a delay < 10ms a variable may got to underflow into 
void SDL_ThreadedTimerCheck(void)

I suggest to change:
		ms = t->interval - SDL_TIMESLICE;   
		next = t->next;
		if ( (int)(now - t->last_alarm) > (int)ms ) {

with:
		if ( (int)(now - t->last_alarm + SDL_TIMESLICE) > (int)ms ) {


bye,
   Dino
Comment 1 dino puller 2010-02-24 01:15:19 UTC
(In reply to comment #0)
> If you try to set a delay < 10ms a variable may got to underflow into 
> void SDL_ThreadedTimerCheck(void)
> 
> I suggest to change:
>         ms = t->interval - SDL_TIMESLICE;   
>         next = t->next;
>         if ( (int)(now - t->last_alarm) > (int)ms ) {
> 
> with:
>         if ( (int)(now - t->last_alarm + SDL_TIMESLICE) > (int)ms ) {
> 
> 
> bye,
>    Dino


The suggested line was:
     if ( (int)(now - t->last_alarm + SDL_TIMESLICE) >  t->interval ) {

Anyway  t->interval is always rounded to be at least SDL_TIMESLICE, so no underflow will happen.