[SDL] Segmentation fault, Switching to Thread
brian.ripoff at gmail.com
Tue Sep 20 01:15:05 PDT 2011
Why are you creating hundreds of short lived threads? Have you tried
commenting them out, and doing the work synchronously in the main()
thread? If this removes the problem, it is unlikely to be a SDL bug. I
doubt it is anyway, it sounds like a classic threading error.
Perhaps you have a race condition at work, where something is being
deallocated usually after, but occasionally before, your threads
complete. Are you passing complex state to these threads? Consider
commenting out the code that deallocates this state (or temporarily
heap-allocating it if it is currently automatically allocated). You
might be correct that the race condition is that your threads start
too soon (or perhaps in different orderings), before some critical
action is performed.
It might be interesting to try print the SDL thread identifiers and
times somewhere, as you start/stop them. I don't know if SDL maintains
a mapping between OS thread identifiers and its own set, see if any
correspond to the thread identifier that GDB says it is switching to.
But ultimately, I really can't imagine why you would need so many
threads, particularly short lived threads that run at start up. Sounds
like a great way to start slowly to me!
On 20 September 2011 05:12, Unga <unga888 at yahoo.com> wrote:
> And I have a block of code at the initialization, to do some checking, which assign a small work for each SDL thread (created by SDL_CreateThread()). These SDL threads are short lived, creates in probably hundreds in very quick succession without any delay in between.
> Probably I can introduce a delay in creating those short lived SDL threads.
More information about the SDL