ftruncate failed at the second time
The used implementation seems to conform to an older specification where returning an error is an allowed behavior for ftruncate(fd, length)
when length
exceeds the previous length:
If the file previously was smaller than this size, ftruncate() shall either increase the size of the file or fail.