-
Notifications
You must be signed in to change notification settings - Fork 130
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(breadcrumbs): guard read access to breadcrumbs count #743
Conversation
I've removed internal access to the |
…ugsnag/bugsnag-cocoa into tom/fix-breadcrumb-count-thread-safety
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's scope to remove quite a bit of dead code here so have commented inline.
This touches more on the overall class design, but it's worth noting that using dispatch_barrier_sync
for a method that can be called from the main thread is not great. This is because it will block until IO completes.
Fortunately I think it should be possible to replace this with dispatch_barrier_async
because the only remaining method after implementing these suggestions would be cachedBreadcrumbs
. This is always called before breadcrumb collection happens, so could be extracted out to BugsnagClient/BSGOutOfMemoryWatchdog
. This is potentially a bit out of the scope of this changeset so it'd be acceptable to address this when the breadcrumb disk serialization is revisited in general.
b26473f
to
355cccc
Compare
355cccc
to
d0dba98
Compare
I haven't addressed this as there are wider issues trying to run this asynchronously. I'll raise this separately for a future change as this should be a good efficiency gain. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM pending resolution of two minor comments
This PR also fixes #737 |
I'm using commit 9044a26 and still getting crashes
Link here in case you have access to all bugsnag data |
Thanks @raylillywhite - I'm investigating now. |
@raylillywhite - I haven't been able to reproduce this, but it does seem that we're somehow holding on to a freed reference, even though the mutable copy should have preserved the reference. Are you able to readily reproduce this in a non-live environment? I have pushed a change (808b8bc) that reinstates the barrier guard for |
I can't reproduce it on demand, but we saw it quite a few times (we log a lot of breadcrumbs). And we're not shipping for a few weeks so I'll use that commit in our next test build today and see if it still happens. |
Goal
Fixes #616
Design
Refactored access to breadcrumb list to avoid the need for the
readWriteQueue
guard in most cases.Changeset
capacity
,count
, andobjectAtIndexedSubscript
as no longer neededreadWriteQueue
guard and used a copy of the list instead; also made signature nonnull to return empty array if there are no elements.breadcrumbs
field from configuration to client and added fields to configuration formaxBreadcrumbs
andenabledBreadcrumbTypes
. These are then used in theBugsnagBreadcrumbs
constructor. This prevents any need for resizing the array of breadcrumbs outside the class.Tests