• 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
Swift crash in dispatch_apply
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Swift crash in dispatch_apply


  • Subject: Swift crash in dispatch_apply
  • From: "Gerriet M. Denkmann" <email@hidden>
  • Date: Sat, 05 Jul 2014 13:05:21 +0700

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 am I doing wrong?

Gerriet.


 _______________________________________________
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: "Clark S. Cox III" <email@hidden>
  • Prev by Date: Re: Framework linking error
  • Next by Date: Re: Framework linking error
  • Previous by thread: Questions about Xcode Continuous Integration
  • Next by thread: Re: Swift crash in dispatch_apply
  • Index(es):
    • Date
    • Thread