Chapter 2: Segmentation Fault after first .task modifier

When going through the process of building out the Storage app, right as we get into our work with the .task {} modifier on ListView, I place in the code to call availableFiles. After doing this, I get a crash on account of a Segmentation Fault. This occurs only when I try to do this step, and when I open the final version of the project, the same behavior occurs. The compiler wants me to add some conformances to the Sendable protocol, but I don’t really trust the yellow warning suggestions…

Anyways, jokes aside, I’m wondering why this unusual occurrence happens. This seems very similar to the project in Chapter 1 in a lot of ways, so why this would occur beats me.

Hi sorry you’re hitting issues with this.

First of all, could you let me know which version of Xcode are you using (the current latest is 13.2.1 and I don’t see this issue with it) and if you have a toolchain from which one is it. If I could reproduce we’ll figure it out quickly.

The compiler isn’t completely off though — the model is a class, and therefore when we call methods on it we could be mutating it, which isn’t great to do from an asynchronous context (like in the task closure). However, in its current version the compiler should not be checking for this as the correct checks for this are still wip — if yuo have a nightly toolchain it might be that these are already on though … let me know some more details