Skip to content

The _Unwind_Backtrace code for arm based systems is non-functional. #21153

@llvmbot

Description

@llvmbot
Bugzilla Link 20779
Resolution FIXED
Resolved on Aug 29, 2014 12:10
Version unspecified
OS other
Attachments Example of failing test.
Reporter LLVM Bugzilla Contributor
CC @mclow

Extended Description

src/Unwind/UnwindLevel1-gcc-ext.c implements the _Unwind_Backtrace function. Arm has it's own unwind format that is special, and on this platform, the IP is never modified. Calling this function results in an infinite loop calling the trace function without ever terminating.

Attached is a simple example that will run infinitely.

I implemented a hack to allow this to work. Adding this to the end of _Unwind_Backtrace

#if LIBCXXABI_ARM_EHABI
// Get the information for this frame.
unw_proc_info_t frameInfo;
if (unw_get_proc_info(&cursor, &frameInfo) != UNW_ESUCCESS) {
return _URC_END_OF_STACK;
}

uint32_t* unwindInfo = (uint32_t *) frameInfo.unwind_info;
uint32_t format = ((*unwindInfo & 0x0f000000) >> 24);
size_t len, startOffset;
switch (format) {
  case 0:  // Short descriptor, 16-bit entries
    len = 4;
    startOffset = 1;
    break;
  case 1:  // Long descriptor, 16-bit entries
  case 3:  // Long descriptor, 32-bit entries
    len = 4 + 4 * ((*unwindInfo & 0x00ff0000) >> 16);
    startOffset = 2;
    break;
  default:
    startOffset = 0;
    break;
}
// Update the IP address.
result = _Unwind_VRS_Interpret((struct _Unwind_Context *)(&cursor),
    unwindInfo, startOffset, len);
if (result != _URC_CONTINUE_UNWIND) {
  return _URC_END_OF_STACK;
}

#endif // LIBCXXABI_ARM_EHABI

This is just a kludge to allow this code to work to mostly work. It also has a problem since the backtrace will stop at the first catch it finds even with this code.

This can be tested on an Android aosp tree if necessary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillalibc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions