Addresses DateFormatter.timeZone setter crash when running Publish #100
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 thelastBuildDate
andpubDate
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 astatic let
property. This meant that it could be attempting to get and/or set thetimeZone
on the sameDateFormatter
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.