[tlbuild] dvi test?

John Hawkinson jhawk at alum.mit.edu
Wed Feb 2 03:03:45 CET 2022


Bruno Haible <bruno at clisp.org> wrote on Tue,  1 Feb 2022
at 20:53:32 EST in <11271134.lvqk35OSZv at omega>:

> > -> 1188		if (fseek(target_fp, 0L, SEEK_SET)) {
> 
> Per the lseek() documentation [2], the argument that fseek() passes
> to lseek() would lead to a negative file descriptor position.

Sorry, how? It seems to me that fseek()'s implementation calls lseek() with the same whence=SEEK_SET when fseek() is called with seek_set(), at least per the below code. Or maybe I missed something in it. Where does it convert to SEEK_CUR with a negative offset?

> > On the other hand, it seems to point to https://github.com/apple-oss-distributions/Libc/blob/rel/Libc-1439/stdio/FreeBSD/fseek.c which looks not to have updated since 2014 (before this issue was introduced) and does not implement fseek() in terms of lseek().
> 
> fseek() does call lseek(), but on BSD systems this does not happen
> directly, but through _ftello or _sseek.

Err, you're quite right. Still, I don't think code is up-to-date. Here's the stack when lseek() call though:

(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 5.1
  * frame #0: 0x00000001c0563248 libsystem_kernel.dylib`__lseek
    frame #1: 0x00000001c04786c4 libsystem_c.dylib`_sseek + 72
    frame #2: 0x00000001c04722bc libsystem_c.dylib`__sflush + 108
    frame #3: 0x00000001c0494d64 libsystem_c.dylib`_fseeko + 716
    frame #4: 0x00000001c04781ec libsystem_c.dylib`fseek + 96
    frame #5: 0x00000001000138ac xdvi-bin`make_backup_fp(source_fp=0x0000000219c06c10, target_fp=0x0000000219c06d40) at dvi-init.c:1195:6
    frame #6: 0x00000001000131f0 xdvi-bin`internal_open_dvi(path="/Users/jhawk/src/xdvik-22.87.05/Work/texk/xdvik/t2a.dvi", errflag=0x000000016fdff1ec, load_fonts='\x01') at dvi-init.c:1384:61
    frame #7: 0x0000000100015234 xdvi-bin`load_dvi_file(load_fonts='\x01', errflag=0x000000016fdff1ec) at dvi-init.c:1866:10
    frame #8: 0x00000001000232e4 xdvi-bin`do_pages at events.c:6235:11
    frame #9: 0x00000001000566e8 xdvi-bin`run_dvi_file(filename="/Users/jhawk/src/xdvik-22.87.05/Work/texk/xdvik/t2a.dvi", data=0x00000001001762e0) at xdvi.c:3622:5
    frame #10: 0x0000000100001804 xdvi-bin`main(argc=2, argv=0x000000016fdff678) at main.c:1311:6
    frame #11: 0x00000001002010f4 dyld`start + 520


--
jhawk at alum.mit.edu
John Hawkinson


More information about the tlbuild mailing list.