To the best of my knowledge, when a process writes to a file it starts a system call. Among the required information, it expects a pointer to a buffer in the user space, filled with the data to write.
Consider a scenario where there is a process that spawns two threads. One thread executes a system call to write 10MB. The other thread performs invalid memory access that triggers a segmentation fault, while the Operating System is serving the IO request. What happens to the write request in this scenario? In particular, I have the guarantee that either the write operation does not happen or it is completed before the deallocation of the process memory? Do the answers change if the io request is just a 64-bit integer?