lightstep / lightstep-tracer-objc

The Lightstep distributed tracing library for Objective-C and Swift
https://lightstep.com
MIT License
11 stars 9 forks source link

Autoreleasepool in `persistSamplesToUserDefaults` #46

Closed ryanrhee closed 6 years ago

ryanrhee commented 6 years ago

@supermarin has a theory that the autoreleasepool might be being released underneath us while the samples are being persisted, which makes the NSData (from NSKeyedArchiver) get freed by the time we save to NSUserDefaults.

Adding an explicit autorelease pool on top may fix this.

supermarin commented 6 years ago

@bhs context: we're observing a small crash rate and after looking deeply into it with @ryanrhee we can't find an obvious crash point. We tried testing with 100000 operations over many threads and queues, and weren't able to repro the crash.

In almost every case the stack trace goes into NSUserDefaults intenals, and hits a zombie. One possible case is that the current autoreleasepool gets drained under us while this is executing.

We should take this code out if we don't observe a crash rate reduction in the next releases.

ryanrhee commented 6 years ago

@bcronin FYI neither myself nor @supermarin can merge this PR.

keith commented 6 years ago

@bcronin do you mind pushing a minor release with this change?

bcronin commented 6 years ago

@keith , 3.2.11 has been pushed. Let me know if there are any issues.

keith commented 6 years ago

Thanks!