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

fix: Refactor MPUploadBuilder to attempt to eliminate rare crash in withLocation: method #262

Merged
merged 1 commit into from
Mar 14, 2024

Conversation

einsteinx2
Copy link
Contributor

Summary

closes #256

After some investigation, it looks like the crash is happening due to memory corruption, specifically of the messageDictionary object in the MPMessageBuilder class, but only when the withLocation: method is called. It seems that the pointer referenced invalid memory... It's unclear whether the root cause it in the SDK code or external code clobbering that memory, but in an attempt to resolve the issue I've refactored the MPMessageBuilder class in the following ways:

  • Make the messageDictionary object a (strong) property instead of an instance variable in case there's some kind of compiler issue preventing it from being properly strongly retained
  • Simplify class by removing the new class methods and just using init methods instead
  • Fixed incorrect marking of init methods as nonnull to nullable since they can return nil and in some cases explicitly do
  • Simplified other methods to no longer return self as it was not used much and hypothetically (though unlikely to impossible) the overwriting of the original reference could cause the memory to be released in between calling the methods and writing back over the reference. I don't think this is likely an actual issue but since we can't reproduce this problem I tried to change everything that could even remotely possibly cause a memory issue.

Testing Plan

  • Was this tested locally? If not, explain why.
  • We have extensive tests against MPMessageBuilder and they are all still passing
  • Manually E2E tested to confirm messages were properly built and uploaded to the live stream

Reference Issue (For mParticle employees only. Ignore if you are an outside contributor)

Copy link
Contributor

@BrandonStalnaker BrandonStalnaker left a comment

Choose a reason for hiding this comment

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

LGTM

@einsteinx2 einsteinx2 merged commit 60cd0c8 into development Mar 14, 2024
11 checks passed
@einsteinx2 einsteinx2 deleted the fix/6174-crash-messagebuilder-withlocation branch March 14, 2024 17:58
mparticle-automation added a commit that referenced this pull request Mar 19, 2024
# [8.21.0](v8.20.0...v8.21.0) (2024-03-19)

### Bug Fixes

* Correct threading around user notification log ([#261](#261)) ([456160b](456160b))
* Refactor MPUploadBuilder to attempt to eliminate rare crash in withLocation: method ([#262](#262)) ([60cd0c8](60cd0c8))

### Features

* Improve mParticle reset methods ([#263](#263)) ([cde71a2](cde71a2))
@mparticle-automation
Copy link
Contributor

🎉 This PR is included in version 8.21.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants