Is NSDateFormatter thread-safe?
Is NSDateFormatter thread-safe?
- Subject: Is NSDateFormatter thread-safe?
- From: Jens Alfke <email@hidden>
- Date: Mon, 31 Oct 2011 17:27:10 -0700
I have some code that uses a shared NSDateFormatter instance to convert dates to/from ISO-8601 format. This code is now being invoked on multiple threads, and I’m getting intermittent malloc warnings about double frees, and one actual crash.
My assumption was that an NSDateFormatter should be thread-safe as long as I treat it as read-only (not changing any attributes) but this makes me think I’m wrong. Anyone know for sure?
Here’s the usual backtrace I see in a malloc warning or crash:
#0 0x018f83b4 in icu::OlsonTimeZone::operator= ()
#1 0x018f9f2d in icu::OlsonTimeZone::clone ()
#2 0x018bb400 in icu::DateFormat::parse ()
#3 0x01964d05 in udat_parse ()
#4 0x01623161 in CFDateFormatterGetAbsoluteTimeFromString ()
#5 0x01622f8e in CFDateFormatterCreateDateFromString ()
#6 0x006bf7e9 in getObjectValue ()
#7 0x006bf701 in -[NSDateFormatter getObjectValue:forString:errorDescription:] ()
#8 0x006bfa3f in -[NSDateFormatter dateFromString:] ()
…
—Jens
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden