> On Sep 12, 2016, at 6:42 AM, Gerriet M. Denkmann <gerr...@mdenkmann.de> wrote:
> 
> So: is the code ok and the compiler broken in Debug mode?
> Or is the code fundamentally wrong and that it works in Release is just a 
> fluke?

99% of the time it’s the latter. Which means you should try to debug the code. 
Did you set the breakpoint on malloc_error? What line of code is triggering it? 
Did you examine the values of variables? Did you run with the Address Sanitizer?

I don’t see a bug in your code itself, but I’m not sure about the thread-safety 
of Swift arrays. NSMutableArray isn’t thread-safe, and I think Swift follows 
the same general thread-safety conventions. On the other hand, it doesn’t look 
like the array gets resized in the threads since you allocate it with a given 
capacity, so the assignments shouldn’t be doing anything fancy like memory 
allocation.

(But on the other other hand, if Swift is smart enough [like C++] to specialize 
[Bool] as a true bit-array, then assigning to an array element does require 
thread-safety, since it will involve reading a byte from RAM, setting one bit, 
and writing it back. That’s not an atomic operation, so overlapping assignments 
can interfere with each other. It wouldn’t cause a crash, though, obviously.)

—Jens
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to