more repairs to stack trace and caching

Fixes problems with d15fda9d6b, but also fixes a problem that
could show up in non-libunwind mode and cause lost frames.