libsdl 1.2 SDL_SemWaitTimeout incorrect behavior

Bug #1409922 reported by Darrell Walisser
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
libsdl1.2 (Ubuntu)
New
Undecided
Unassigned

Bug Description

release: 14.04.1 LTS
version: 1.2.15-8ubuntu1.1 0

The function SDL_SemWaitTimeout returns an error result (-1) if the semaphore wait times out, when it should return SDL_MUTEX_TIMEDOUT per documentation.

Ref: http://www.libsdl.org/release/SDL-1.2.15/docs/html/sdlsemwaittimeout.html

The fix is to check for ETIMEDOUT value of errno:

diff -ru libsdl1.2-1.2.15/src/thread/pthread/SDL_syssem.c libsdl1.2-fixed/src/thread/pthread/SDL_syssem.c
--- libsdl1.2-1.2.15/src/thread/pthread/SDL_syssem.c 2012-01-19 01:30:06.000000000 -0500
+++ libsdl1.2-fixed/src/thread/pthread/SDL_syssem.c 2015-01-12 16:13:54.768791640 -0500
@@ -144,8 +144,12 @@
                retval = sem_timedwait(&sem->sem, &ts_timeout);
        while (retval == -1 && errno == EINTR);

- if (retval == -1)
- SDL_SetError(strerror(errno));
+ if (retval == -1) {
+ if (errno == ETIMEDOUT)
+ retval = SDL_MUTEX_TIMEDOUT;
+ else
+ SDL_SetError(strerror(errno));
+ }
 #else
        end = SDL_GetTicks() + timeout;
        while ((retval = SDL_SemTryWait(sem)) == SDL_MUTEX_TIMEDOUT) {

Revision history for this message
Darrell Walisser (darrell-walisser) wrote :

Should be noted, this bug fix is already in the head of SDL 1.2:

http://hg.libsdl.org/SDL/file/bda7de312fbd/src/thread/pthread/SDL_syssem.c

Revision history for this message
Darrell Walisser (darrell-walisser) wrote :

Last note, I promise. The bug was fixed a loong time ago. Would it help if SDL developers released a new stable version (1.2.16), and I can go bug them about it.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.