This is an archive of the discontinued LLVM Phabricator instance.

Reset _unwindInfoMissing when info is found eventually
AbandonedPublic

Authored by dim on Apr 8 2022, 3:51 PM.

Details

Reviewers
compnerd
jrtc27
ldionne
MaskRay
mstorsjo
nikic
Group Reviewers
Restricted Project
Summary

As reported in https://github.com/llvm/llvm-project/issues/54799, when
using the C APIs unw_init_local(), unw_set_reg(), unw_get_reg()
and unw_step(), sometimes libunwind can erroneously conclude there is
no unwind info available.

This is because the initial call to co->setInfoBasedOnIPRegister() in
unw_init_local() can set _unwindInfoMissing to true, as at that
point there may not yet be unwind info available.

Subsequent calls to unw_set_reg(), with the register parameter set to
UNW_REG_IP, might still be able to find unwind info based on the new
IP value, but it does *not* reset _unwindInfoMissing to false in
those cases, so follow-up calls to unw_step() will erroneously return
UNW_STEP_END immediately.

To fix this, add explicit resets of _unwindInfoMissing to false, in
the various places where setInfoBasedOnIPRegister() actually does find
unwind info.

Diff Detail

Event Timeline

dim created this revision.Apr 8 2022, 3:51 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptApr 8 2022, 3:51 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript
dim requested review of this revision.Apr 8 2022, 3:51 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 8 2022, 3:51 PM
dim added a subscriber: emaste.Apr 8 2022, 4:01 PM
JVD added a subscriber: JVD.Apr 10 2022, 10:12 AM
nikic resigned from this revision.Apr 11 2022, 3:18 AM

See https://github.com/llvm/llvm-project/issues/54799#issuecomment-1094405136 , the test is incorrect and the original report doesn't indicate a bug to me.

MaskRay requested changes to this revision.May 14 2022, 5:17 PM
This revision now requires changes to proceed.May 14 2022, 5:17 PM
dim abandoned this revision.May 15 2022, 12:47 AM