Plot icon indicating copy to clipboard operation
Plot copied to clipboard

Addresses DateFormatter.timeZone setter crash when running Publish

Open insidegui opened this issue 2 years ago • 0 comments

We were experiencing random crashes on Linux when generating our website. I don't have the backtrace readily available, but it was clear that the crash was on the setter for DateFormatter.timeZone while generating a podcast feed, when generating the lastBuildDate and pubDate tags.

The crash was a bad pointer dereference and would happen randomly, which made me think it could be a concurrency-related issue. Looking into how Plot implements those tags, it uses RSS.dateFormatter, which was a static let property. This meant that it could be attempting to get and/or set the timeZone on the same DateFormatter instance from multiple threads, which would eventually lead to this crash.

The solution I came up with was to just change RSS.dateFormatter to a computed property, so that it's not possible for multiple threads to be using the same instance. I haven't been able to reproduce the crash again since making this change.

I believe this affected us because we're using a customized version of Publish which allows for multiple podcast feeds to be generated on the same site, and since Publish makes heavy use of concurrency, we were hit with this bug when multiple feeds were being generated at the same time.

insidegui avatar Dec 29 '23 13:12 insidegui