Description
This bug report was migrated from our old Bugzilla tracker.
Reported in version: 1.2.13
Reported for operating system, platform: All, All
Comments on the original bug report:
On 2008-03-21 13:29:22 +0000, Henrik Kouri wrote:
SDL_SemWaitTimeout in src/thread/generic/SDL_syssem.c line 179 (SVN trunk):
--sem->count;
should be
if (retval == 0) {
--sem->count;
}Without this, sem->count will underflow on timeout effectively breaking the semaphore. It appears that the implementation has been wrong since the initial revision. Below is a sample C++ app to demonstrate the problem (should output plain zeros when correct):
#include <SDL.h>
#includeint main(int argc, char* argv[])
{
SDL_Init(0);
SDL_sem* sem = SDL_CreateSemaphore(0);
std::cout << SDL_SemValue(sem) << std::endl;SDL_SemTryWait(sem);
std::cout << SDL_SemValue(sem) << std::endl;SDL_SemTryWait(sem);
std::cout << SDL_SemValue(sem) << std::endl;// Breaks here! Integer underflows!
SDL_SemWaitTimeout(sem, 10);
std::cout << SDL_SemValue(sem) << std::endl;SDL_SemTryWait(sem);
std::cout << SDL_SemValue(sem) << std::endl;SDL_SemTryWait(sem);
std::cout << SDL_SemValue(sem) << std::endl;SDL_DestroySemaphore(sem);
sem = NULL;
SDL_Quit();
return 0;
}
On 2009-09-13 16:33:20 +0000, Ryan C. Gordon wrote:
Tagging this bug with "target-1.2.14" so we can try to resolve it for SDL 1.2.14.
Please note that we may choose to resolve it as WONTFIX. This tag is largely so we have a comprehensive wishlist of bugs to examine for 1.2.14 (and so we can close bugs that we'll never fix, rather than have them live forever in Bugzilla).
--ryan.
On 2009-09-21 00:35:21 +0000, Sam Lantinga wrote:
Fixed in subversion, thanks!