Discussion:
[Libunwind-devel] Docs suggestion - things that invalidate a saved context
Craig Ringer
2018-06-20 12:18:44 UTC
Permalink
Hi folks

This probably falls into the category of "how can you not have figured that
out" and "too obvious to document" for many here, but a quick docs
suggestion:

In unw_getcontext, it'd be helpful to explain the bounds of validity for a
saved context. In particular, a saved context ceases to be valid after
returning from the function that captured the context or after a longjmp()
/ siglongjmp(). It may still work, but the stack pointer has moved back and
it's not safe to access the stack anymore. New function calls, alloca(),
etc, may clobber the residual state left on the stack.

I just spent a really embarrassing amount of time figuring out that this is
why my PostgreSQL self-backtrace handler worked fine in non-returning
direct error callbacks, but produced garbled nonsense when invoked after a
longjmp() / setjmp().
--
Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
Loading...