Firstly, global and static variables are shared.
Secondly, memory from malloc that you can reach via a pointer in a global variable, (or via a pointer that...) is shared.
Thirdly, memory in one thread's stack that you can reach via a pointer in a global variable, (or via a pointer that...) is shared.
Really, all of it is shared, all the time, but not all of it is reachable. Thread A can access thread B's stack, but it won't have a pointer to do so through unless thread B does something like assign the address of something in its stack to a global (don't do that) or you're doing something where you examine the details of the threads and work your way into their stacks (if you're doing that you're way more knowledgeable enough about the mechanisms of the pthreads implementation than I am*, so I won't tell you not to do that, but as a rule it wouldn't be something to do lightly).
Mostly you only have to worry about global and static, and can consider anything dealing only in locals to be thread-safe, but that gets blown away once you can reach the latter from the former.
*Actually, I know little on that, and am mostly basing this on knowledge of threading in other languages. Really, it's a general threading thing rather than a pthreads specific one, with the exception that some other languages won't even let you fall into the trap of referencing stack memory from global.