annotate TODO @ 3069:caefe2344f65

Date: Thu, 27 Dec 2007 07:38:25 +0000 From: John Bartholomew Subject: [SDL] SDL Semaphore implementation broken on Windows? Hi, Over the past couple of days, I've been battling with SDL, SDL_Mixer and SMPEG to try to find an audio hang bug. I believe I've found the problem, which I think is a race condition inside SDL's semaphore implementation (at least the Windows implementation). The semaphore code uses Windows' built in semaphore functions, but it also maintains a separate count value. This count value is updated with bare increment and decrement operations in SemPost and SemWaitTimeout - no locking primitives to protect them. In tracking down the apparent audio bug, I found that at some point a semaphore's count value was being decremented to -1, which is clearly not a valid value for it to take. I'm still not certain exactly what sequence of operations is occuring for this to happen, but I believe that overall it's a race condition between a thread calling SemPost (which increments the count) and the thread on the other end calling SemWait (which decrements it). I will try to make a test case to verify this, but I'm not sure if I'll be able to (threading errors being difficult to reproduce even in the best circumstances). However, assuming this is the cause of my problems, there is a very simple fix: Windows provides InterlockedIncrement() and InterlockedDecrement() functions to perform increments and decrements which are guaranteed to be atomic. So the fix is in thread/win32/SDL_syssem.c: replace occurrences of --sem->count with InterlockedDecrement(&sem->count); and replace occurrences of ++sem->count with InterlockedIncrement(&sem->count); This is using SDL v1.2.12, built with VC++ 2008 Express, running on a Core 2 duo processor.
author Sam Lantinga <slouken@libsdl.org>
date Tue, 17 Feb 2009 05:39:18 +0000
parents a728b8b779d1
children 4ccdf20bad6f
rev   line source
2777
6f260584df22 Adding SDL 1.3 release checklist, so we start getting a list of must-have features and bug fixes for a 1.3 release
Sam Lantinga <slouken@libsdl.org>
parents: 2330
diff changeset
1
6f260584df22 Adding SDL 1.3 release checklist, so we start getting a list of must-have features and bug fixes for a 1.3 release
Sam Lantinga <slouken@libsdl.org>
parents: 2330
diff changeset
2 1.3 release checklist:
2864
fe8ea2b39aea Updated TODO list
Sam Lantinga <slouken@libsdl.org>
parents: 2861
diff changeset
3 * Add higher precision timers for profiling
2777
6f260584df22 Adding SDL 1.3 release checklist, so we start getting a list of must-have features and bug fixes for a 1.3 release
Sam Lantinga <slouken@libsdl.org>
parents: 2330
diff changeset
4 * Implement YUV texture support
2861
25745ac3d785 Updated TODO list
Sam Lantinga <slouken@libsdl.org>
parents: 2777
diff changeset
5 - in progress, software support is done, Ryan is working on OpenGL shaders
2777
6f260584df22 Adding SDL 1.3 release checklist, so we start getting a list of must-have features and bug fixes for a 1.3 release
Sam Lantinga <slouken@libsdl.org>
parents: 2330
diff changeset
6 * Implement desktop video mode change notification?
2921
3c45e98e0547 Don't forget OpenGL 3.0 support
Sam Lantinga <slouken@libsdl.org>
parents: 2911
diff changeset
7 * Add OpenGL 3.0 context support
2977
a0f4ffd9c2ae Icons with translucency are implemented
Sam Lantinga <slouken@libsdl.org>
parents: 2966
diff changeset
8 * Finish multiple display support
a0f4ffd9c2ae Icons with translucency are implemented
Sam Lantinga <slouken@libsdl.org>
parents: 2966
diff changeset
9 * Open windows on display that is selected when creating a window
2978
4c9130d66e2c Added a few things to the TODO list.
Sam Lantinga <slouken@libsdl.org>
parents: 2977
diff changeset
10 * Create testing plan - becoming more and more important...
4c9130d66e2c Added a few things to the TODO list.
Sam Lantinga <slouken@libsdl.org>
parents: 2977
diff changeset
11 - unit tests for each feature and combination with expected output
4c9130d66e2c Added a few things to the TODO list.
Sam Lantinga <slouken@libsdl.org>
parents: 2977
diff changeset
12 and actual output comparison.
4c9130d66e2c Added a few things to the TODO list.
Sam Lantinga <slouken@libsdl.org>
parents: 2977
diff changeset
13 * Public license for SDL_compat.c, tests, and SDL_main*
2861
25745ac3d785 Updated TODO list
Sam Lantinga <slouken@libsdl.org>
parents: 2777
diff changeset
14 * Verify mouse grab support
25745ac3d785 Updated TODO list
Sam Lantinga <slouken@libsdl.org>
parents: 2777
diff changeset
15 * Properly handle mouse grab with Vista DPI scaling
25745ac3d785 Updated TODO list
Sam Lantinga <slouken@libsdl.org>
parents: 2777
diff changeset
16 * Make sure the mouse is where it's supposed to be when un-grabbed
3062
e2bb8ab7b43f We need to figure out whether we should handle events on foreign windows
Sam Lantinga <slouken@libsdl.org>
parents: 3051
diff changeset
17 * Plan how to handle events on foreign windows
2861
25745ac3d785 Updated TODO list
Sam Lantinga <slouken@libsdl.org>
parents: 2777
diff changeset
18 * Add keyboard enumeration / name query API
2957
2c30a17edf11 Ryan doesn't like hung programs to lock up his system. Silly, huh?
Sam Lantinga <slouken@libsdl.org>
parents: 2945
diff changeset
19 * Implement NET_WM_PING and NET_WM_PID/WM_CLIENT_MACHINE (?)
2c30a17edf11 Ryan doesn't like hung programs to lock up his system. Silly, huh?
Sam Lantinga <slouken@libsdl.org>
parents: 2945
diff changeset
20 - http://standards.freedesktop.org/wm-spec/wm-spec-1.3.html#KILLINGWINDOWS
2965
5066298aa82a Maybe add a timeout for SDL_WaitEvent()
Sam Lantinga <slouken@libsdl.org>
parents: 2960
diff changeset
21 * Add a timeout parameter for SDL_WaitEvent() (?)
2995
b3f23a4b4547 Added more info for precise waiting in SDL_WaitEvent()
Sam Lantinga <slouken@libsdl.org>
parents: 2991
diff changeset
22 - http://lists.libsdl.org/pipermail/sdl-libsdl.org/2008-May/thread.html#65067
2988
e7dd24f2f890 Added keyrepeat to the TODO list
Sam Lantinga <slouken@libsdl.org>
parents: 2981
diff changeset
23 * Implement key repeat at the driver level
2991
f4d14219c2aa Implemented svn revision support
Sam Lantinga <slouken@libsdl.org>
parents: 2988
diff changeset
24 * Add name -> keysym and name -> scancode lookup functions
3051
Sam Lantinga <slouken@libsdl.org>
parents: 3006
diff changeset
25 * Fix building haptic system on win32
3064
044ccc2c7485 Suggestion from the mailing list
Sam Lantinga <slouken@libsdl.org>
parents: 3062
diff changeset
26 * Add always on top window styles
3065
a728b8b779d1 Added reminder for shaped windows
Sam Lantinga <slouken@libsdl.org>
parents: 3064
diff changeset
27 * Add video modes that have an alpha channel?
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
28
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
29 Wish list for the 1.3 development branch:
1534
f02e673ffc5f *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 1441
diff changeset
30 http://bugzilla.libsdl.org/
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
31
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1621
diff changeset
32 * Add a way to register custom events
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
33 * DirectInput joystick support needs to be implemented
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
34 * Explicit vertical retrace wait (maybe separate from SDL_Flip?)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
35 * Shaped windows, windows without borders
2861
25745ac3d785 Updated TODO list
Sam Lantinga <slouken@libsdl.org>
parents: 2777
diff changeset
36 * Multiple display support
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
37 * Add a timestamp to events
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
38 * Add audio input API
2330
3458c74b5fab So we don't forget to do this...
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
39 * Add modifier state to key and button events
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
40
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
41 In the jump from 1.2 to 1.3, we should change the SDL_Rect members to
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
42 int and evaluate all the rest of the datatypes. This is the only place
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
43 we should do it though, since the 1.2 series should not break binary
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
44 compatibility in this way.
150
df1d68818edb *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 2
diff changeset
45
df1d68818edb *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 2
diff changeset
46 Requests:
df1d68818edb *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 2
diff changeset
47 * PCM and CDROM volume control (deprecated, but possible)