[SDL2] SDL_Init freezing with SDL_INIT_TIMER

Greetings SDL community!

I started porting my game engine from SDL to SDL2 yesterday and I ran into
a strange issue.
When calling SDL_Init with SDL_INIT_TIMER flag, the function never returns.
It just stays there in some kind of infinite loop.
The same behavior happens when i’m trying to initialize SDL2_mixer,
although SDL2_image and SDL2_ttf are correctly
initialized and work ok.

My code basically calls SDL_Init with SDL_INIT_TIMER, SDL_INIT_VIDEO and
SDL_INIT_AUDIO flags. And then it initializes
SDL2_ttf, SDL2_image and SDL2_mixer. When calling SDL_Init without
SDL_INIT_TIMER and with SDL2_mixer commented,
there’s no freezing.

I’m using Ubuntu 12.04 LTS on a x64 machine. I’ve compiled SDL2 directly
from hg as well as SDL2_image, SDL2_ttf and
SDL2_mixer.

I don’t know if it’s ok to just paste the trace, but here it is:

#0 __lll_lock_wait () at
…/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:132
#1 0x00007ffff70c7065 in _L_lock_858 () from
/lib/x86_64-linux-gnu/libpthread.so.0
#2 0x00007ffff70c6eba in __pthread_mutex_lock (mutex=0x6054b0) at
pthread_mutex_lock.c:61
#3 0x00007ffff6e88c4c in SDL_mutexP (mutex=0x6054b0) at
/home/puyol/prog/SDL2/src/thread/pthread/SDL_sysmutex.c:103
#4 0x00007ffff6e89011 in SDL_DestroySemaphore (sem=0x605490) at
/home/puyol/prog/SDL2/src/thread/generic/SDL_syssem.c:126
#5 0x00007ffff6e2b5dd in SDL_CreateThread (fn=,
name=, data=)
at /home/puyol/prog/SDL2/src/thread/SDL_thread.c:286
#6 0x00007ffff6e2bb30 in SDL_TimerInit () at
/home/puyol/prog/SDL2/src/timer/SDL_timer.c:230
#7 0x00007ffff6ddfc75 in SDL_InitSubSystem (flags=49) at
/home/puyol/prog/SDL2/src/SDL.c:106
#8 0x00007ffff6ddfd3a in SDL_Init (flags=49) at
/home/puyol/prog/SDL2/src/SDL.c:216
#9 0x00007ffff7bc7899 in Polymorphic::Engine::Initialize () at
src/engine.cpp:78
#10 0x00007ffff7bc8093 in Polymorphic::Engine::Run (gi=0x7fffffffe100) at
src/engine.cpp:134
#11 0x00000000004014d7 in main (argc=1, argv=0x7fffffffe218) at
src/main.cpp:10

If there’s any information I forgot to provide, just tell me. Any help will
be appreciated.

Thanks for you time,

Erick

o_o

I suppose it must be some recent change because I’m on Ubuntu 12.04
LTS x64 too and I don’t have any issues. I’m using the latest snapshot
from February 28th, if that matters, so if it’s a new bug it must be
from after that.

Which reminds me, if I recall correctly on Ubuntu SDL will default to
using gettimeofday instead of clock_gettime, probably because the
latter requires linking with librt (-lrt). I have absolutely no idea
why configure doesn’t even consider it. May not be related to this,
but I always found it curious (using gettimeofday can result in lots
of issues because you aren’t guaranteed it won’t be affected by
external factors).

2013/3/6, Erick Sousa :> Greetings SDL community!

I started porting my game engine from SDL to SDL2 yesterday and I ran into
a strange issue.
When calling SDL_Init with SDL_INIT_TIMER flag, the function never returns.
It just stays there in some kind of infinite loop.
The same behavior happens when i’m trying to initialize SDL2_mixer,
although SDL2_image and SDL2_ttf are correctly
initialized and work ok.

My code basically calls SDL_Init with SDL_INIT_TIMER, SDL_INIT_VIDEO and
SDL_INIT_AUDIO flags. And then it initializes
SDL2_ttf, SDL2_image and SDL2_mixer. When calling SDL_Init without
SDL_INIT_TIMER and with SDL2_mixer commented,
there’s no freezing.

I’m using Ubuntu 12.04 LTS on a x64 machine. I’ve compiled SDL2 directly
from hg as well as SDL2_image, SDL2_ttf and
SDL2_mixer.

I don’t know if it’s ok to just paste the trace, but here it is:

#0 __lll_lock_wait () at
…/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:132
#1 0x00007ffff70c7065 in _L_lock_858 () from
/lib/x86_64-linux-gnu/libpthread.so.0
#2 0x00007ffff70c6eba in __pthread_mutex_lock (mutex=0x6054b0) at
pthread_mutex_lock.c:61
#3 0x00007ffff6e88c4c in SDL_mutexP (mutex=0x6054b0) at
/home/puyol/prog/SDL2/src/thread/pthread/SDL_sysmutex.c:103
#4 0x00007ffff6e89011 in SDL_DestroySemaphore (sem=0x605490) at
/home/puyol/prog/SDL2/src/thread/generic/SDL_syssem.c:126
#5 0x00007ffff6e2b5dd in SDL_CreateThread (fn=,
name=, data=)
at /home/puyol/prog/SDL2/src/thread/SDL_thread.c:286
#6 0x00007ffff6e2bb30 in SDL_TimerInit () at
/home/puyol/prog/SDL2/src/timer/SDL_timer.c:230
#7 0x00007ffff6ddfc75 in SDL_InitSubSystem (flags=49) at
/home/puyol/prog/SDL2/src/SDL.c:106
#8 0x00007ffff6ddfd3a in SDL_Init (flags=49) at
/home/puyol/prog/SDL2/src/SDL.c:216
#9 0x00007ffff7bc7899 in Polymorphic::Engine::Initialize () at
src/engine.cpp:78
#10 0x00007ffff7bc8093 in Polymorphic::Engine::Run (gi=0x7fffffffe100) at
src/engine.cpp:134
#11 0x00000000004014d7 in main (argc=1, argv=0x7fffffffe218) at
src/main.cpp:10

If there’s any information I forgot to provide, just tell me. Any help will
be appreciated.

Thanks for you time,

Erick

This is caused by a bug in the CMake script which leads to the
non-detection of pthreads semaphore support. The patch hasn’t been
applied to hg yet, so grab it from
http://bugzilla.libsdl.org/show_bug.cgi?id=1709 and you should be
fine.On 7 March 2013 03:48, Sik the hedgehog <sik.the.hedgehog at gmail.com> wrote:

o_o

I suppose it must be some recent change because I’m on Ubuntu 12.04
LTS x64 too and I don’t have any issues. I’m using the latest snapshot
from February 28th, if that matters, so if it’s a new bug it must be
from after that.

Which reminds me, if I recall correctly on Ubuntu SDL will default to
using gettimeofday instead of clock_gettime, probably because the
latter requires linking with librt (-lrt). I have absolutely no idea
why configure doesn’t even consider it. May not be related to this,
but I always found it curious (using gettimeofday can result in lots
of issues because you aren’t guaranteed it won’t be affected by
external factors).

2013/3/6, Erick Sousa :

Greetings SDL community!

I started porting my game engine from SDL to SDL2 yesterday and I ran into
a strange issue.
When calling SDL_Init with SDL_INIT_TIMER flag, the function never returns.
It just stays there in some kind of infinite loop.
The same behavior happens when i’m trying to initialize SDL2_mixer,
although SDL2_image and SDL2_ttf are correctly
initialized and work ok.

My code basically calls SDL_Init with SDL_INIT_TIMER, SDL_INIT_VIDEO and
SDL_INIT_AUDIO flags. And then it initializes
SDL2_ttf, SDL2_image and SDL2_mixer. When calling SDL_Init without
SDL_INIT_TIMER and with SDL2_mixer commented,
there’s no freezing.

I’m using Ubuntu 12.04 LTS on a x64 machine. I’ve compiled SDL2 directly
from hg as well as SDL2_image, SDL2_ttf and
SDL2_mixer.

I don’t know if it’s ok to just paste the trace, but here it is:

#0 __lll_lock_wait () at
…/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:132
#1 0x00007ffff70c7065 in _L_lock_858 () from
/lib/x86_64-linux-gnu/libpthread.so.0
#2 0x00007ffff70c6eba in __pthread_mutex_lock (mutex=0x6054b0) at
pthread_mutex_lock.c:61
#3 0x00007ffff6e88c4c in SDL_mutexP (mutex=0x6054b0) at
/home/puyol/prog/SDL2/src/thread/pthread/SDL_sysmutex.c:103
#4 0x00007ffff6e89011 in SDL_DestroySemaphore (sem=0x605490) at
/home/puyol/prog/SDL2/src/thread/generic/SDL_syssem.c:126
#5 0x00007ffff6e2b5dd in SDL_CreateThread (fn=,
name=, data=)
at /home/puyol/prog/SDL2/src/thread/SDL_thread.c:286
#6 0x00007ffff6e2bb30 in SDL_TimerInit () at
/home/puyol/prog/SDL2/src/timer/SDL_timer.c:230
#7 0x00007ffff6ddfc75 in SDL_InitSubSystem (flags=49) at
/home/puyol/prog/SDL2/src/SDL.c:106
#8 0x00007ffff6ddfd3a in SDL_Init (flags=49) at
/home/puyol/prog/SDL2/src/SDL.c:216
#9 0x00007ffff7bc7899 in Polymorphic::Engine::Initialize () at
src/engine.cpp:78
#10 0x00007ffff7bc8093 in Polymorphic::Engine::Run (gi=0x7fffffffe100) at
src/engine.cpp:134
#11 0x00000000004014d7 in main (argc=1, argv=0x7fffffffe218) at
src/main.cpp:10

If there’s any information I forgot to provide, just tell me. Any help will
be appreciated.

Thanks for you time,

Erick


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I applied the mentioned patch and recompiled SDL2. Now everything works
like a charm!

Thank you all for your help!

2013/3/6 Scott Percival > This is caused by a bug in the CMake script which leads to the

non-detection of pthreads semaphore support. The patch hasn’t been
applied to hg yet, so grab it from
http://bugzilla.libsdl.org/show_bug.cgi?id=1709 and you should be
fine.

On 7 March 2013 03:48, Sik the hedgehog <sik.the.hedgehog at gmail.com> wrote:

o_o

I suppose it must be some recent change because I’m on Ubuntu 12.04
LTS x64 too and I don’t have any issues. I’m using the latest snapshot
from February 28th, if that matters, so if it’s a new bug it must be
from after that.

Which reminds me, if I recall correctly on Ubuntu SDL will default to
using gettimeofday instead of clock_gettime, probably because the
latter requires linking with librt (-lrt). I have absolutely no idea
why configure doesn’t even consider it. May not be related to this,
but I always found it curious (using gettimeofday can result in lots
of issues because you aren’t guaranteed it won’t be affected by
external factors).

2013/3/6, Erick Sousa <@Erick_Sousa>:

Greetings SDL community!

I started porting my game engine from SDL to SDL2 yesterday and I ran
into

a strange issue.
When calling SDL_Init with SDL_INIT_TIMER flag, the function never
returns.

It just stays there in some kind of infinite loop.
The same behavior happens when i’m trying to initialize SDL2_mixer,
although SDL2_image and SDL2_ttf are correctly
initialized and work ok.

My code basically calls SDL_Init with SDL_INIT_TIMER, SDL_INIT_VIDEO and
SDL_INIT_AUDIO flags. And then it initializes
SDL2_ttf, SDL2_image and SDL2_mixer. When calling SDL_Init without
SDL_INIT_TIMER and with SDL2_mixer commented,
there’s no freezing.

I’m using Ubuntu 12.04 LTS on a x64 machine. I’ve compiled SDL2 directly
from hg as well as SDL2_image, SDL2_ttf and
SDL2_mixer.

I don’t know if it’s ok to just paste the trace, but here it is:

#0 __lll_lock_wait () at
…/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:132
#1 0x00007ffff70c7065 in _L_lock_858 () from
/lib/x86_64-linux-gnu/libpthread.so.0
#2 0x00007ffff70c6eba in __pthread_mutex_lock (mutex=0x6054b0) at
pthread_mutex_lock.c:61
#3 0x00007ffff6e88c4c in SDL_mutexP (mutex=0x6054b0) at
/home/puyol/prog/SDL2/src/thread/pthread/SDL_sysmutex.c:103
#4 0x00007ffff6e89011 in SDL_DestroySemaphore (sem=0x605490) at
/home/puyol/prog/SDL2/src/thread/generic/SDL_syssem.c:126
#5 0x00007ffff6e2b5dd in SDL_CreateThread (fn=,
name=, data=)
at /home/puyol/prog/SDL2/src/thread/SDL_thread.c:286
#6 0x00007ffff6e2bb30 in SDL_TimerInit () at
/home/puyol/prog/SDL2/src/timer/SDL_timer.c:230
#7 0x00007ffff6ddfc75 in SDL_InitSubSystem (flags=49) at
/home/puyol/prog/SDL2/src/SDL.c:106
#8 0x00007ffff6ddfd3a in SDL_Init (flags=49) at
/home/puyol/prog/SDL2/src/SDL.c:216
#9 0x00007ffff7bc7899 in Polymorphic::Engine::Initialize () at
src/engine.cpp:78
#10 0x00007ffff7bc8093 in Polymorphic::Engine::Run (gi=0x7fffffffe100)
at

src/engine.cpp:134
#11 0x00000000004014d7 in main (argc=1, argv=0x7fffffffe218) at
src/main.cpp:10

If there’s any information I forgot to provide, just tell me. Any help
will

be appreciated.

Thanks for you time,

Erick


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I haven’t applied the patch because I want to figure out what’s wrong with
the threading emulation code, but I haven’t had time to look at it.

Does anyone else want to take a look at it?On Wed, Mar 6, 2013 at 4:27 PM, Scott Percival wrote:

This is caused by a bug in the CMake script which leads to the
non-detection of pthreads semaphore support. The patch hasn’t been
applied to hg yet, so grab it from
http://bugzilla.libsdl.org/show_bug.cgi?id=1709 and you should be
fine.

On 7 March 2013 03:48, Sik the hedgehog <sik.the.hedgehog at gmail.com> wrote:

o_o

I suppose it must be some recent change because I’m on Ubuntu 12.04
LTS x64 too and I don’t have any issues. I’m using the latest snapshot
from February 28th, if that matters, so if it’s a new bug it must be
from after that.

Which reminds me, if I recall correctly on Ubuntu SDL will default to
using gettimeofday instead of clock_gettime, probably because the
latter requires linking with librt (-lrt). I have absolutely no idea
why configure doesn’t even consider it. May not be related to this,
but I always found it curious (using gettimeofday can result in lots
of issues because you aren’t guaranteed it won’t be affected by
external factors).

2013/3/6, Erick Sousa :

Greetings SDL community!

I started porting my game engine from SDL to SDL2 yesterday and I ran
into

a strange issue.
When calling SDL_Init with SDL_INIT_TIMER flag, the function never
returns.

It just stays there in some kind of infinite loop.
The same behavior happens when i’m trying to initialize SDL2_mixer,
although SDL2_image and SDL2_ttf are correctly
initialized and work ok.

My code basically calls SDL_Init with SDL_INIT_TIMER, SDL_INIT_VIDEO and
SDL_INIT_AUDIO flags. And then it initializes
SDL2_ttf, SDL2_image and SDL2_mixer. When calling SDL_Init without
SDL_INIT_TIMER and with SDL2_mixer commented,
there’s no freezing.

I’m using Ubuntu 12.04 LTS on a x64 machine. I’ve compiled SDL2 directly
from hg as well as SDL2_image, SDL2_ttf and
SDL2_mixer.

I don’t know if it’s ok to just paste the trace, but here it is:

#0 __lll_lock_wait () at
…/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:132
#1 0x00007ffff70c7065 in _L_lock_858 () from
/lib/x86_64-linux-gnu/libpthread.so.0
#2 0x00007ffff70c6eba in __pthread_mutex_lock (mutex=0x6054b0) at
pthread_mutex_lock.c:61
#3 0x00007ffff6e88c4c in SDL_mutexP (mutex=0x6054b0) at
/home/puyol/prog/SDL2/src/thread/pthread/SDL_sysmutex.c:103
#4 0x00007ffff6e89011 in SDL_DestroySemaphore (sem=0x605490) at
/home/puyol/prog/SDL2/src/thread/generic/SDL_syssem.c:126
#5 0x00007ffff6e2b5dd in SDL_CreateThread (fn=,
name=, data=)
at /home/puyol/prog/SDL2/src/thread/SDL_thread.c:286
#6 0x00007ffff6e2bb30 in SDL_TimerInit () at
/home/puyol/prog/SDL2/src/timer/SDL_timer.c:230
#7 0x00007ffff6ddfc75 in SDL_InitSubSystem (flags=49) at
/home/puyol/prog/SDL2/src/SDL.c:106
#8 0x00007ffff6ddfd3a in SDL_Init (flags=49) at
/home/puyol/prog/SDL2/src/SDL.c:216
#9 0x00007ffff7bc7899 in Polymorphic::Engine::Initialize () at
src/engine.cpp:78
#10 0x00007ffff7bc8093 in Polymorphic::Engine::Run (gi=0x7fffffffe100)
at

src/engine.cpp:134
#11 0x00000000004014d7 in main (argc=1, argv=0x7fffffffe218) at
src/main.cpp:10

If there’s any information I forgot to provide, just tell me. Any help
will

be appreciated.

Thanks for you time,

Erick


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org