Re: Is NSDateFormatter thread-safe?
Re: Is NSDateFormatter thread-safe?
- Subject: Re: Is NSDateFormatter thread-safe?
- From: Roland King <email@hidden>
- Date: Tue, 01 Nov 2011 08:40:16 +0800
It's not. Documented in the Thread Programming Guide.
On 1 Nov, 2011, at 8:27, Jens Alfke <email@hidden> wrote:
> 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
_______________________________________________
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