3 ms·
I don't disbelieve this fact; I'd just like to see a sample program that demonstrates it.
by lalaithion 4y ago
I don't disbelieve this fact; I'd just like to see a sample program that demonstrates it.
- saagarjha 4y ago$ swiftc - import Dispatch var array = [Int]() DispatchQueue.global().async { while true { array.append(Int.random(in: .min...(.max))) } } DispatchQueue.global().async { while true { let range = 0..<array.count guard !range.isEmpty else { continue } array.remove(at: Int.random(in: range)) } } dispatchMain() $ ./main Segmentation fault: 11 $ ./main main(71894,0x16f103000) malloc: double free for ptr 0x13e808200 main(71894,0x16f103000) malloc: *** set a breakpoint in malloc_error_break to debug Abort trap: 6 $
- lalaithion 4y agoThanks!