posix_fallocate is not signal-safe #168
Comments
Seems like similar problem may occur in case of other system calls (i.e. |
Yeah, I looked briefly at the syscalls we use and these can be interrupted: close, flock, dup, read. |
By the fact there, in NVML, are much many syscalls which are sensitive to signals. |
I looked at this, and I see os_posix_fallocate used in only three places. In all three instances, the error code seems to be propagated to the user in |
The problem is that restarting pmemobj_create does not help. Every time we do it posix_fallocate starts from the very beginning, which means that it might never finish if application raises signals periodically (like SIGALRM). |
Yes, the same is true for whatever syscall that application does. If the application itself calls fallocate on some file, it will need to deal with EINTR. |
In short: you write a library, you don't control the whole application, you didn't raise a signal, you don't know why there was a signal. |
@marcinslusarz , You can play with block/unblock to prevent it. |
We should not block signals, because that may interfere with the way application handles signals.
|
Marcin, your words really disappoint me :-( PS: in your way you should take a look at posix_fallocate() sources and forget about posix_fallocate() at all. Then you can combine syscall(NR_posix_fallocate, fd, 0, size) with something like you have written above. |
Fixed in PMDK 1.6 |
A call to
posix_fallocate
can be interrupted by a signal and then the whole operation is cancelled and errno is set to EINTR. If an application using NVML has a lot of signals flying around, the file allocation might be impossible. This issue should be addressed in one way or another.The text was updated successfully, but these errors were encountered: