Crash in deinit when using Task

This is not supposed to be safe: you have escaped a self reference in deinit, and this is never ok.

Your proposed alternative works, as does:

    deinit {
        Task { [offset] in
           await manager.rmBlock(offset: offset)
        }
    }

This should almost certainly be accompanied by a diagnostic, and Swift is entirely capable of performing that diagnosis (self captured by an @escaping closure). So I recommend filing a bug report asking for it.

9 Likes