[tlbuild] dvi test?
John Hawkinson
jhawk at alum.mit.edu
Mon Jan 31 04:20:31 CET 2022
I am very confused and am unable to reproduce some of Dick and Bruno's tests from several hours ago.
Replies to multiple messages from Dick and Bruno inline below.
Richard Koch <koch at uoregon.edu> wrote on Sun, 30 Jan 2022
at 12:56:11 EST in <06411E7A-7F3F-4DF3-9E14-1E80EA3F7CF0 at uoregon.edu>:
> I decided to see if I could pare down John's example. I reached the following. The sample below produces a crash. But if the bottom comment is moved in by one so the last word is "e" rather than "el", then there is no crash. I couldn't get rid of the draft copy or the \sc a.
...
> Lorem ipsum dolor sit amet, consectetur adipisicing el%it
I named this file jhawk-dick-test-el.tex. And then uncommented the "it" at the end and named that jhawk-dick-test-elit.tex.
Compiling both of those, neither crash my MacOS Monterey TL2021 xdvi, unlike my original test (t2a.dvi).
I understand this result differs from Bruno's results and Dick's results, so I am very confused.
I have attached both the .tex and the .dvi files here, so hopefiully someone can see why I am getting different results.
HOWEVER:
Bruno Voisin <bvoisin at icloud.com> wrote on Sun, 30 Jan 2022
at 14:23:32 EST in <4F691E0E-9D07-4867-8DCE-2CC1F08FDA2A at icloud.com>:
> Here's this output (attached). test-dick.dvi is Dick's test file with % after "el", leading xdvi to crash upon reload on recent macOS, and test-dick-alt.dvi is the same file with % after "e", yielding no crash.
I feel like this should be the same as my jhawk-dick-test-el.dvi, and yet it is not. For one thing, mine are (both!) 2176 dvi files:
jhawk at lrr xdvi-tmp % ls -ld jhawk*{tex,dvi}
-rw-r--r-- 1 jhawk staff 2176 Jan 30 21:58 jhawk-test-dick-el.dvi
-rw-r--r-- 1 jhawk staff 975 Jan 30 21:49 jhawk-test-dick-el.tex
-rw-r--r-- 1 jhawk staff 2176 Jan 30 21:58 jhawk-test-dick-elit.dvi
-rw-r--r-- 1 jhawk staff 974 Jan 30 21:49 jhawk-test-dick-elit.tex
And one of Bruno's is 2180:
jhawk at lrr Downloads % ls -ld test-dick*
-rw-r--r--@ 1 jhawk staff 2176 Jan 30 21:55 test-dick-alt.dvi
-rw-r--r--@ 1 jhawk staff 2180 Jan 30 21:53 test-dick.dvi
xdvi abort()s after shift-R for me on Bruno's test-dick.dvi, and does so in the familiar fashion:
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
* frame #0: 0x00000001ae8d19b8 libsystem_kernel.dylib`__pthread_kill + 8
frame #1: 0x00000001ae904eb0 libsystem_pthread.dylib`pthread_kill + 288
frame #2: 0x00000001ae842314 libsystem_c.dylib`abort + 164
frame #3: 0x000000010004d18c xdvi-bin`do_abort at util.c:300:5
frame #4: 0x0000000100004414 xdvi-bin`dvi_fmt_error(message="set_no_char: attempt to set character of unknown font") at dvi-draw.c:488:5
frame #5: 0x00000001000091e4 xdvi-bin`set_no_char(ch=0) at dvi-draw.c:1804:5
frame #6: 0x00000001000067f0 xdvi-bin`draw_part(fp=0x0000000207f6ed40, minframe=0x0000000100176f18, current_dimconv=8.3022000830220009) at dvi-draw.c:1861:15
frame #7: 0x0000000100007b70 xdvi-bin`draw_page at dvi-draw.c:2267:2
frame #8: 0x0000000100022a1c xdvi-bin`redraw(windowrec=0x0000000100171f78) at events.c:6038:5
frame #9: 0x0000000100023140 xdvi-bin`redraw_page at events.c:6191:5
frame #10: 0x00000001000236d0 xdvi-bin`do_pages at events.c:6277:7
frame #11: 0x00000001000567b4 xdvi-bin`run_dvi_file(filename="/Users/jhawk/Downloads/test-dick.dvi", data=0x00000001001762e0) at xdvi.c:3622:5
frame #12: 0x000000010000198c xdvi-bin`main(argc=2, argv=0x000000016fdff648) at main.c:1311:6
frame #13: 0x00000001002010f4 dyld`start + 520
What did Bruno (and Dick?) do differently to compile (latex) this?
Richard Koch <koch at uoregon.edu> wrote on Sun, 30 Jan 2022
at 20:54:28 EST in <6A7A8B82-045B-4AE5-AFFB-4F8BDD6D9CB7 at uoregon.edu>:
> These discoveries suggest that we look at the code in dvi-init.c. Starting at line 1232, we find
> a routine "file_exists_p" which produces the first trace entry, and then opens the dvi file, and then
> performs some tests. After this routine returns, the routine "process_preamble" is called, and
> it reads the incorrect value.
>
> Let us look at the "file_exists_p" code. It writes the first two trace items. Then there is a comment
> labeled /* shouldn't happen */ and it does a few tests. If they fail, it closes the file and returns FALSE.
> Otherwise it returns TRUE.
>
> So I modified the code so it never performs those tests that shouldn't happen. I did that
> by simply adding "return True;" after line 1243.
Err.
So, I set a breakpoint at at the first line after the /* shouldn't happen */ and stepped over each test and never entered the if block, it always returned true. Sevearl times before hitting R and several times after. lldb session attached as lldb-shouldnt-happen.log.
So am I seeing soething different from Dick?
To be sure, I applied this patch:
diff --git a/texk/xdvik/dvi-init.c b/texk/xdvik/dvi-init.c
index 6126a08..1fa8354 100644
--- a/texk/xdvik/dvi-init.c
+++ b/texk/xdvik/dvi-init.c
@@ -1240,7 +1240,8 @@ file_exists_p(const char *path, dviErrFlagT *errflag)
}
TRACE_FILES((stderr, "m_dvi_fp for |%s| = %p", path, (void *)m_dvi_fp));
/* fprintf(stderr, "after internal_open_dvi2: xfopen\n"); */
-
+
+ return True;
/* shouldn't happen */
if (fstat(fileno(m_dvi_fp), &fstatbuf) != 0 || S_ISDIR(fstatbuf.st_mode)) { /* if it's a directory */
*errflag = FILE_IS_DIRECTORY;
Then when I run xdvi on t2a.dvi, it immediately crashes, prior to hitting 'R'. I guess that matches up with Dick's #3:
> 3) HOWEVER: if I changed "e" to "el", then the document IMMEDIATELY CRASHES without even waiting
> to type R as soon as xdvi loads it.
>
>
> Conclusion: One of those /* shouldn't happen */ events is happening
> with our test file. I don't know why it doesn't crash the file when it is first loaded.
> Someone smarter will have to take over.
But I think the conclusion is incorrect -- rather, than one of the tests failing, it is that they have side effects.
Although that doesn't make a lot of sense either.
Reverting Dick's patch and setting breakpoints on the first lines inside each if's true block, the breakpoints are never hit; the crash occurs after hitting shift-R:
jhawk at lrr xdvik % TEXMFROOT=/usr/local/texlive/2021 TEXMFCNF=$TEXMFROOT/texmf-dist/web2c lldb ./xdvi-bin t2a.dvi
(lldb) target create "./xdvi-bin"
Current executable set to '/Users/jhawk/src/xdvik-22.87.05/Work/texk/xdvik/xdvi-bin' (arm64).
(lldb) settings set -- target.run-args "t2a.dvi"
(lldb) b dvi-init.c:1246
Breakpoint 1: where = xdvi-bin`file_exists_p + 392 at dvi-init.c:1246:3, address = 0x0000000100013640
(lldb) b dvi-init.c:1260
Breakpoint 2: where = xdvi-bin`file_exists_p + 448 at dvi-init.c:1260:3, address = 0x0000000100013678
(lldb) r
Process 28020 launched: '/Users/jhawk/src/xdvik-22.87.05/Work/texk/xdvik/xdvi-bin' (arm64)
xdvi-bin: set_no_char: attempt to set character of unknown font, offset 42
xdvi-bin 22.87.05 (Xaw toolkit): ../../../texk/xdvik/dvi-draw.c:488: Shouldn't happen: I'll abort now, to help you debugging this.
Process 28020 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
frame #0: 0x00000001ae8d19b8 libsystem_kernel.dylib`__pthread_kill + 8
libsystem_kernel.dylib`__pthread_kill:
-> 0x1ae8d19b8 <+8>: b.lo 0x1ae8d19d8 ; <+40>
0x1ae8d19bc <+12>: pacibsp
0x1ae8d19c0 <+16>: stp x29, x30, [sp, #-0x10]!
0x1ae8d19c4 <+20>: mov x29, sp
Target 0: (xdvi-bin) stopped.
> I don't know how to rebuild just xdvi-xaw, so I rebuilt the entire 2022 tree.
Yikes! This is pretty easy. From the xdvik tree, which I got from downloading https://master.dl.sourceforge.net/project/xdvi/xdvik/22.87.05/xdvik-22.87.05.tar.gz?viasf=1 and untarring it (but you could take it from the TexLive source tree if you have it handy), just run
./Build --debug
in the toplevel and it will build xdvik and a few necessary libraries. Then cd to Work/texk/xdvi. After making any source edits, you can just hit "make" in that directory to rebuild only the affected files and relink.
To run that xdvi, you can either copy xdvi-bin to the TexLive run tree or you can set these environment variables to run it out of the build tree (thanks, Karl, for explaining that to me):
TEXMFROOT=/usr/local/texlive/2021 TEXMFCNF=/usr/local/texlive/2021/texmf-dist/web2c ./xdvi-bin t2a.dvi
Or, to run it under lldb:
TEXMFROOT=/usr/local/texlive/2021 TEXMFCNF=/usr/local/texlive/2021/texmf-dist/web2c lldb ./xdvi-bin t2a.dvi
--
jhawk at alum.mit.edu
John Hawkinson
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jhawk-test-dick-el.tex
Type: application/x-tex
Size: 975 bytes
Desc: not available
URL: <https://tug.org/pipermail/tlbuild/attachments/20220130/61f2ab2b/attachment-0002.tex>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jhawk-test-dick-el.dvi
Type: application/x-dvi
Size: 2176 bytes
Desc: not available
URL: <https://tug.org/pipermail/tlbuild/attachments/20220130/61f2ab2b/attachment-0002.dvi>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jhawk-test-dick-elit.tex
Type: application/x-tex
Size: 974 bytes
Desc: not available
URL: <https://tug.org/pipermail/tlbuild/attachments/20220130/61f2ab2b/attachment-0003.tex>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jhawk-test-dick-elit.dvi
Type: application/x-dvi
Size: 2176 bytes
Desc: not available
URL: <https://tug.org/pipermail/tlbuild/attachments/20220130/61f2ab2b/attachment-0003.dvi>
-------------- next part --------------
jhawk at lrr xdvik % TEXMFROOT=/usr/local/texlive/2021 TEXMFCNF=$TEXMFROOT/texmf-dist/web2c lldb ./xdvi-bin t2a.dvi
(lldb) target create "./xdvi-bin"
Current executable set to '/Users/jhawk/src/xdvik-22.87.05/Work/texk/xdvik/xdvi-bin' (arm64).
(lldb) settings set -- target.run-args "t2a.dvi"
(lldb) b dvi-init.c:1245
Breakpoint 1: where = xdvi-bin`file_exists_p + 348 at dvi-init.c:1245:22, address = 0x0000000100013614
(lldb) r
Process 27752 launched: '/Users/jhawk/src/xdvik-22.87.05/Work/texk/xdvik/xdvi-bin' (arm64)
Process 27752 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x0000000100013614 xdvi-bin`file_exists_p(path="t2a.dvi", errflag=0x000000016fdff2cc) at dvi-init.c:1245:22
1242 /* fprintf(stderr, "after internal_open_dvi2: xfopen\n"); */
1243
1244 /* shouldn't happen */
-> 1245 if (fstat(fileno(m_dvi_fp), &fstatbuf) != 0 || S_ISDIR(fstatbuf.st_mode)) { /* if it's a directory */
1246 *errflag = FILE_IS_DIRECTORY;
1247 fclose(m_dvi_fp);
1248 m_dvi_fp = NULL;
Target 0: (xdvi-bin) stopped.
(lldb) n
Process 27752 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x0000000100013670 xdvi-bin`file_exists_p(path="t2a.dvi", errflag=0x000000016fdff2cc) at dvi-init.c:1259:18
1256 In this case, it would be better to look at the preamble before
1257 entering the drawing loop.
1258 */
-> 1259 if (fstatbuf.st_size == 0) {
1260 *errflag = FILE_HAS_ZERO_SIZE;
1261 fclose(m_dvi_fp);
1262 m_dvi_fp = NULL;
Target 0: (xdvi-bin) stopped.
(lldb)
Process 27752 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x00000001000136a8 xdvi-bin`file_exists_p(path="t2a.dvi", errflag=0x000000016fdff2cc) at dvi-init.c:1265:5
1262 m_dvi_fp = NULL;
1263 return False;
1264 }
-> 1265 return True;
1266 }
1267
1268 /*
Target 0: (xdvi-bin) stopped.
(lldb) c
Process 27752 resuming
Process 27752 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x0000000100013614 xdvi-bin`file_exists_p(path="/Users/jhawk/src/xdvik-22.87.05/Work/texk/xdvik/t2a.dvi", errflag=0x000000016fdff33c) at dvi-init.c:1245:22
1242 /* fprintf(stderr, "after internal_open_dvi2: xfopen\n"); */
1243
1244 /* shouldn't happen */
-> 1245 if (fstat(fileno(m_dvi_fp), &fstatbuf) != 0 || S_ISDIR(fstatbuf.st_mode)) { /* if it's a directory */
1246 *errflag = FILE_IS_DIRECTORY;
1247 fclose(m_dvi_fp);
1248 m_dvi_fp = NULL;
Target 0: (xdvi-bin) stopped.
(lldb) n
Process 27752 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x0000000100013614 xdvi-bin`file_exists_p(path="/Users/jhawk/src/xdvik-22.87.05/Work/texk/xdvik/t2a.dvi", errflag=0x000000016fdff33c) at dvi-init.c:1245:22
1242 /* fprintf(stderr, "after internal_open_dvi2: xfopen\n"); */
1243
1244 /* shouldn't happen */
-> 1245 if (fstat(fileno(m_dvi_fp), &fstatbuf) != 0 || S_ISDIR(fstatbuf.st_mode)) { /* if it's a directory */
1246 *errflag = FILE_IS_DIRECTORY;
1247 fclose(m_dvi_fp);
1248 m_dvi_fp = NULL;
Target 0: (xdvi-bin) stopped.
(lldb) n
Process 27752 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x0000000100013670 xdvi-bin`file_exists_p(path="/Users/jhawk/src/xdvik-22.87.05/Work/texk/xdvik/t2a.dvi", errflag=0x000000016fdff33c) at dvi-init.c:1259:18
1256 In this case, it would be better to look at the preamble before
1257 entering the drawing loop.
1258 */
-> 1259 if (fstatbuf.st_size == 0) {
1260 *errflag = FILE_HAS_ZERO_SIZE;
1261 fclose(m_dvi_fp);
1262 m_dvi_fp = NULL;
Target 0: (xdvi-bin) stopped.
(lldb) c
Process 27752 resuming
Process 27752 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x0000000100013614 xdvi-bin`file_exists_p(path="/Users/jhawk/src/xdvik-22.87.05/Work/texk/xdvik/t2a.dvi", errflag=0x000000016fdff1dc) at dvi-init.c:1245:22
1242 /* fprintf(stderr, "after internal_open_dvi2: xfopen\n"); */
1243
1244 /* shouldn't happen */
-> 1245 if (fstat(fileno(m_dvi_fp), &fstatbuf) != 0 || S_ISDIR(fstatbuf.st_mode)) { /* if it's a directory */
1246 *errflag = FILE_IS_DIRECTORY;
1247 fclose(m_dvi_fp);
1248 m_dvi_fp = NULL;
Target 0: (xdvi-bin) stopped.
(lldb) n
Process 27752 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x0000000100013614 xdvi-bin`file_exists_p(path="/Users/jhawk/src/xdvik-22.87.05/Work/texk/xdvik/t2a.dvi", errflag=0x000000016fdff1dc) at dvi-init.c:1245:22
1242 /* fprintf(stderr, "after internal_open_dvi2: xfopen\n"); */
1243
1244 /* shouldn't happen */
-> 1245 if (fstat(fileno(m_dvi_fp), &fstatbuf) != 0 || S_ISDIR(fstatbuf.st_mode)) { /* if it's a directory */
1246 *errflag = FILE_IS_DIRECTORY;
1247 fclose(m_dvi_fp);
1248 m_dvi_fp = NULL;
Target 0: (xdvi-bin) stopped.
(lldb) n
Process 27752 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x0000000100013670 xdvi-bin`file_exists_p(path="/Users/jhawk/src/xdvik-22.87.05/Work/texk/xdvik/t2a.dvi", errflag=0x000000016fdff1dc) at dvi-init.c:1259:18
1256 In this case, it would be better to look at the preamble before
1257 entering the drawing loop.
1258 */
-> 1259 if (fstatbuf.st_size == 0) {
1260 *errflag = FILE_HAS_ZERO_SIZE;
1261 fclose(m_dvi_fp);
1262 m_dvi_fp = NULL;
Target 0: (xdvi-bin) stopped.
(lldb) n
Process 27752 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x00000001000136a8 xdvi-bin`file_exists_p(path="/Users/jhawk/src/xdvik-22.87.05/Work/texk/xdvik/t2a.dvi", errflag=0x000000016fdff1dc) at dvi-init.c:1265:5
1262 m_dvi_fp = NULL;
1263 return False;
1264 }
-> 1265 return True;
1266 }
1267
1268 /*
Target 0: (xdvi-bin) stopped.
(lldb) c
Process 27752 resuming
xdvi-bin: set_no_char: attempt to set character of unknown font, offset 42
xdvi-bin 22.87.05 (Xaw toolkit): ../../../texk/xdvik/dvi-draw.c:488: Shouldn't happen: I'll abort now, to help you debugging this.
Process 27752 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
frame #0: 0x00000001ae8d19b8 libsystem_kernel.dylib`__pthread_kill + 8
libsystem_kernel.dylib`__pthread_kill:
-> 0x1ae8d19b8 <+8>: b.lo 0x1ae8d19d8 ; <+40>
0x1ae8d19bc <+12>: pacibsp
0x1ae8d19c0 <+16>: stp x29, x30, [sp, #-0x10]!
0x1ae8d19c4 <+20>: mov x29, sp
More information about the tlbuild
mailing list.