Potential concurrency issue in DateTimeParsers.swift
ClementCardonnel opened this issue · 1 comments
ClementCardonnel commented
Hi!
I've recently encountered a crash in DateTimeParsers.swift.
My crash occurred on line 81:
Self.calendarCache[0] = calendar
Which references this static variable:
private static var calendarCache = [Int : Calendar]()
I was parsing multiple GPX files inside Swift.Task
s. I believe this crash is concurrency driven where multiple threads attempted to access the same static variable.
Could thread safety be improved by using for example an Actor
? Or should I consider CoreGPX not thread safe and try to always parse my GPX files sequentially?
Thanks in advance
vincentneo commented
Could thread safety be improved by using for example an Actor?
Maybe it would, but it's probably safest to treat CoreGPX in its current form as not thread safe.