A bug is a failure of a program to operate in the intended way. How does changing the correct behaviour of a correct program into an incorrect one protect anyone from bugs? Wouldn't it be more natural to say that the bug is with the thread implementation, which does not work like it claims to do?
IEEE Std 1003.1 wrote:Thread
A single flow of control within a process. Each thread has its own thread ID, scheduling priority and policy, errno value, thread-specific key/value bindings, and the required system resources to support a flow of control. Anything whose address may be determined by a thread, including but not limited to static variables, storage obtained via malloc(), directly addressable storage obtained through implementation-defined functions, and automatic variables, are accessible to all threads in the same process.
Accessing a stack variable belonging to another thread is a perfectly legal and normal behaviour. If it works, it is most certainly not a fluke, it means that the implementor bothered to read the specification that defined what he claims to have implemented. One is of course free to make a thread implementation where thread stacks are only accessible from the same thread, but then it wouldn't be a POSIX thread implementation.
One should try not to design a system around the assumption that the programmer does not know what he is doing. If someone does not know how to program, chances are that he will be doing something he knows how to do instead, such as stopping suspicious drivers, flipping hamburgers, flying an airplane, or selling real estate. Someone who passed a stack variable pointer to another thread probably meant to do just that, so one should let him expect that to work like the standard says it should.
Reference:
http://pubs.opengroup.org/onlinepubs/00 ... tag_03_393
Edit: Looking back at the first page, I see that the mention of POSIX threads didn't come from the OP. However, even so, most people would expect stack variables to be a shared resource, since that's how threads work on virtually every other system.