[tlbuild] dvi test?

Bruno Voisin bvoisin at icloud.com
Tue Feb 1 17:05:05 CET 2022


Karl wrote:

>      3208/0x31ed:  ftruncate(0x6, 0x0, 0x0)		 = 0 0
>      3208/0x31ed:  lseek(0x6, 0xFFFFFFFFFFFFF7C7, 0x1)		 = -1 Err#22
> 
> fseek (aka lseek) should presumably not be getting called with that
> strangely huge value (-something?) right after ftruncate has truncated
> it to empty.
> 
> ftruncate is only used directly in one place in xdvi: dvi-init.c
> line 1193:
> 	if (ftruncate(tmp_fd, 0) < 0) {
> 	  <failure code>
> 	}
> 	fseek(target_fp, 0L, SEEK_SET);
> 	fseek(source_fp, 0L, SEEK_SET);
> 	
> I think it would be a good idea to check the return values from those
> fseeks.

Looking whether ftruncate exhibits peculiar behavior on macOS I found this

https://stackoverflow.com/questions/25502229/ftruncate-not-working-on-posix-shared-memory-in-mac-os-x
https://github.com/osvenskan/posix_ipc/issues/5

Namely: "Apple's implementation of ftruncate only works once and when called on a new memory block. Second and later calls on the same block (whether be created or just opened for writing) always fail with EINVAL (even when shrinking the block)"

If I understood well, this means on macOS you can only apply ftruncate to tmp_fd immediately after it's been created; if it's been read already for some other purpose, ftruncate will fail. But this is for data written to memory if I understood correctly, whereas xdvi uses it for a file, right?

I've no idea whether that's related, just thought it worth reporting.

Bruno




More information about the tlbuild mailing list.