fix a few stack walking and signal handling bugs

See individual commit messages for details.