• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Swift crash in dispatch_apply
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Swift crash in dispatch_apply


  • Subject: Re: Swift crash in dispatch_apply
  • From: "Clark S. Cox III" <email@hidden>
  • Date: Mon, 07 Jul 2014 10:00:19 -0700

> On Jul 4, 2014, at 23:05, Gerriet M. Denkmann <email@hidden> wrote:
>
> Why does this crash?
>
> class Crash : NSObject	//	must be subclass of NSObject to get a crash
> {
> 	var globalSize = 0
> 	let queue = dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_HIGH, 0 )
>
> 	func makeCrash()
> 	{
> 		globalSize = 97		//	anything
> 		let nbrThreads : UInt = 1	//	any positive number will do; output might be garbled for > 1
> 		let localSize = globalSize
>
> 		println("makeCrash will do dispatch_apply( \(nbrThreads) )")
> 		dispatch_apply( nbrThreads, queue,
> 			{	[unowned self] (idx: size_t) in
>
> 				println( "thread[\(idx)] local \(localSize)")			//	ok
>
> 				// next line will crash ---	Mac OS X 10.9.4 	Xcode Version 6.0 (6A216f)
> 				println( "thread[\(idx)] global \(self.globalSize)")	//	will crash
> 			}
> 		)
> 	}
> }
>
> let dummy = Crash()
> dummy.makeCrash()

What is the actual crash?

> What am I doing wrong?

Why are you making self unowned? I suspect (without seeing the actual crash) that dummy has been released as there are no more strong references to it.


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Swift crash in dispatch_apply
      • From: "Gerriet M. Denkmann" <email@hidden>
References: 
 >Swift crash in dispatch_apply (From: "Gerriet M. Denkmann" <email@hidden>)

  • Prev by Date: Re: App icon is being mangled when built
  • Next by Date: Re: Why does Swift crash my CFBitVector ?
  • Previous by thread: Swift crash in dispatch_apply
  • Next by thread: Re: Swift crash in dispatch_apply
  • Index(es):
    • Date
    • Thread