title: Shared native libraries on android and libc thread safety
body: <p>I am new to Android development (and not an expert on C/C++ either), but find myself working on a native shared library written in C that is supposed to be used (among other platforms) by an Android app.</p>
  
  <p>Now, I started thinking about thread safety, and determined that my lib is currently not thread safe (uses static/global variables). No problem, I will simply use it from just one thread.</p>
  
  <p>Here is where my actual question starts. From some posts on the internet (e.g. <a href="https://bugs.launchpad.net/firefox/+bug/856072" rel="nofollow">on Launchpad</a>, it seems that some parts of the bionic libc (in particular, stdio) are not thread safe either, at least in some Android releases (we still target pre-3.0). Now the question is, will other native libraries used in this app/process share the same libc instance, causing thread safety issues, or does every shared library get its own libc instance?</p>
  
  <p>In case libc is shared between all shared libs, where can I find information on which parts of it are thread safe and which aren't? Do I have to use all my native libs from the same thread to be on the safe side?</p>
  
  <p>Edit: Updating with my current understanding: The bionic libc is <em>supposed</em> to be thread safe entirely, and the issue shown above is an isolated bug that will not happen in most situations (like many MT bugs). The question stands, but my best guess is that the entire process shares the same libc instance. I'll try to test this later.</p>