Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Avoid using dladdr with libunwindstack #658

Closed
wants to merge 1 commit into from

Conversation

fractalwrench
Copy link
Contributor

@fractalwrench fractalwrench commented Apr 4, 2024

Goal

Avoids using dladdr by using functions available in libunwindstack directly. This avoids the need for extra symbolication code that doesn't necessarily account for edge cases introduced by Android.

The SO load address is different by a few thousand bytes when calculated by libunwindstack. I believe this is because libunwindstack accounts for how Android reads elf files whereas dladdr does not.

Testing

I tested 3 representative crashes on an ARM emulator & compared stacktraces (see attached).

The symbolication for libart.so appears to be more complete for libunwindstack (it correctly gets mterp_op_invoke_static, whereas dladdr doesn't). However, all the embrace frames seem to incorrectly point at nullPointerDereference. I'd assume the different SO load address means our backend symbolication chooses this function.

Copy link

codecov bot commented Apr 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.97%. Comparing base (a6d0807) to head (6b9bf04).

Additional details and impacted files

Impacted file tree graph

@@                   Coverage Diff                   @@
##           termination-handler     #658      +/-   ##
=======================================================
- Coverage                80.06%   79.97%   -0.09%     
=======================================================
  Files                      416      416              
  Lines                    10934    10934              
  Branches                  1673     1673              
=======================================================
- Hits                      8754     8745       -9     
- Misses                    1506     1515       +9     
  Partials                   674      674              

see 5 files with indirect coverage changes

@@ -44,6 +44,9 @@ static inline void emb_copy_frame_data(unwindstack::AndroidUnwinderData &android
data->offset = map_info->offset();
data->flags = map_info->flags();
emb_strncpy(data->full_name, map_info->GetFullName().c_str(), EMB_FRAME_STR_SIZE);

// calculate line number
data->line_num = data->pc - data->start;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't line_num meant to refer to the symbolicated line number? this looks like it's computing the module address offset

RETURN_ON_JSON_FAILURE(json_object_set_number(frame_object, kModuleAddrKey, frame->module_addr));
RETURN_ON_JSON_FAILURE(json_object_set_number(frame_object, kLineNumKey, frame->line_num));

RETURN_ON_JSON_FAILURE(json_object_set_number(frame_object, kFrameAddrKey, frame->pc));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not sure i follow these changes. some of the names in emb_sframe seem a bit confusing and some of the fields seem like they might be redundant. probably worth a chat to go over that to see if we can clean up some stuff there

Base automatically changed from termination-handler to master April 15, 2024 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants