When stack gets destroyed relative to TSD destructors?
Douglas C. Schmidt wrote: > Can someone please let me know if POSIX pthreads specifies > when a thread stack gets destroyed relative to the time at which the > thread-specific storage destructors get run? In particular, if a > thread-specific destructor accesses a pointer to a location on the > run-time stack, will this memory still exist or will it be gone by the > time the time the destructor runs? Thread-specific data destructors must run in the context of the thread that created the TSD value being destroyed. (This is clearly and unambiguously implied by the standard. That is, while the standard doesn’t explicitly require this, an implementation that called destructors in some other context would present a wide range of severe restrictions in behavior that are not allowed by the standard.) Thus, the stack must exist and remain valid at this point. After a thread has terminated (having completed calling all cleanup handlers and destructors), “the result of access to local (auto) var