esfml icon indicating copy to clipboard operation
esfml copied to clipboard

Initializing OpenAL results in seg fault

Open mjbshaw opened this issue 11 years ago • 3 comments

Simply creating an sf::Music, for example (which results in the AudioDevice being created and setting up OpenAL) results in the following log messages when closing the app:

05-25 17:09:00.733: D/dalvikvm(9473): threadid=11: thread exiting, not yet detached (count=0)
05-25 17:09:00.733: D/dalvikvm(9473): threadid=11: thread exiting, not yet detached (count=1)
05-25 17:09:00.738: E/dalvikvm(9473): threadid=11: native thread exited without detaching
05-25 17:09:00.738: E/dalvikvm(9473): VM aborting
05-25 17:09:00.738: A/libc(9473): Fatal signal 11 (SIGSEGV) at 0xdeadd00d (code=1)

Not creating an sf::Music results in proper termination. I'm not sure if this is a bug in OpenAL or if we're not shutting OpenAL down properly. I'm also unsure if this is caused by OpenAL's internal threads, or if its creating problems with our own threads.

mjbshaw avatar May 25 '13 23:05 mjbshaw

It comes from my modified OpenAL Soft library I provided. Let me explain.

I'm unable to use a shared library (.so) in Android, it simply doesn't work with dependencies etc. and I already spent hours on it. That's why we currently use static libraries (.a) only.

In order for OpenAL Soft to work, it needs the Java virtual machine instance JavaVM* which is given by Android by calling a function named JNI_OnLoad() at load time. OpenAL Soft implements JNI_OnLoad() and relies on Android to call it to get the JavaVM* instance. It happens Android doesn't call this function with static library since they're not loaded at runtime which causes OpenAL Soft to crash.

To solve this problem, I modified OpenAL Soft to pick up JavaVM* located in sfml-main library (main.cpp line 54) and I guess I forgot to detach the VM somewhere. :)

intjelic avatar May 26 '13 00:05 intjelic

Anyway, I had to pre-compile a bunch of libraries and had to modify various to compile successfully (except OpenAL Soft I never modified the source, just some path to adjust, things like this). I'll provide detailed instructions and probably scripts for people who want to rebuild themselves.

intjelic avatar May 26 '13 00:05 intjelic

I'm unable to use a shared library (.so) in Android, it simply doesn't work with dependencies etc. and I already spent hours on it. That's why we currently use static libraries (.a) only.

Ideally we should get the shared versions working (mostly because of license issues with LGPL libraries, like OpenAL Soft).

That's useful information, though!

mjbshaw avatar May 27 '13 17:05 mjbshaw