1 .\" $Id: v7bugs.doc,v 1.5 1994/06/24 10:02:36 ceriel Exp $
33 This document describes the UNIX version 7 errors fixed at the
34 Vrije Universiteit, Amsterdam.
35 Several of these are discovered at the VU.
36 Others are quoted from a list of bugs distributed by BellLabs.
38 For each error the differences between the original and modified
39 source files are given,
40 as well as a test program.
42 C optimizer bug for unsigned comparison
44 The following C program caused an IOT trap, while it should not
45 (compile with 'cc -O prog.c'):
57 BellLabs suggests to make the following patch in c21.c:
59 /* modified /usr/src/cmd/c/c21.c */
62 190 /* next 2 lines replaced as indicated by
63 191 * Bell Labs bug distribution ( v7optbug )
64 192 p->back->back->forw = p->forw;
65 193 p->forw->back = p->back->back;
66 194 End of lines changed */
67 195 if (p->forw->op==CBR
68 196 || p->forw->op==SXT
69 197 || p->forw->op==CFCC) {
70 198 p->back->forw = p->forw;
71 199 p->forw->back = p->back;
73 201 p->back->back->forw = p->forw;
74 202 p->forw->back = p->back->back;
76 204 /* End of new lines */
78 206 p = p->back->back;
82 Use the previous program to test before and after the modification.
84 The loader fails for large data or text portions
86 The loader 'ld' produces a "local symbol botch" error
87 for the following C program.
97 printf("loader is fine\\n");
100 We have made the following fix:
102 /* original /usr/src/cmd/ld.c */
115 /* modified /usr/src/cmd/ld.c */
118 114 * The original Version 7 loader had problems loading large
119 115 * text or data portions.
120 116 * Why not include <a.out.h> ???
121 117 * then they would be declared unsigned
125 121 unsigned tsize; /* not int !!! */
126 122 unsigned dsize; /* not int !!! */
127 123 unsigned bsize; /* not int !!! */
128 124 unsigned ssize; /* not int !!! */
129 125 unsigned entry; /* not int !!! */
130 126 unsigned pad; /* not int !!! */
131 127 unsigned relflg; /* not int !!! */
135 Floating point registers
137 When a program is swapped to disk if it needs more memory,
138 then the floating point registers were not saved, so that
139 it may have different registers when it is restarted.
140 A small assembly program demonstrates this for the status register.
141 If the error is not fixed, then the program generates an IOT error.
142 A "memory fault" is generated if all is fine.
151 Some digging into the kernel is required to fix it.
152 The following patch will do:
154 /* original /usr/sys/sys/slp.c */
156 563 a2 = malloc(coremap, newsize);
159 566 p->p_flag |= SSWAP;
164 /* modified /usr/sys/sys/slp.c */
166 590 a2 = malloc(coremap, newsize);
170 594 * copy floating point register and status,
171 595 * but only if you must switch processes
173 597 if(u.u_fpsaved == 0) {
179 603 p->p_flag |= SSWAP;
185 Floating point registers.
187 A similar problem arises when a process forks.
188 The child will have random floating point registers as is
189 demonstrated by the following assembly language program.
190 The child process will die by an IOT trap and the father prints
191 the message "child failed".
218 mess: <child failed\\n>
220 The same file slp.c should be patched as follows:
222 /* original /usr/sys/sys/slp.c */
225 500 * When the resume is executed for the new process,
226 501 * here's where it will resume.
228 503 if (save(u.u_ssav)) {
232 507 a2 = malloc(coremap, n);
234 509 * If there is not enough core for the
235 510 * new process, swap out the current process to generate the
239 /* modified /usr/sys/sys/slp.c */
242 520 * When the resume is executed for the new process,
243 521 * here's where it will resume.
245 523 if (save(u.u_ssav)) {
250 528 /* copy the floating point registers and status to child */
251 529 if(u.u_fpsaved == 0) {
256 534 a2 = malloc(coremap, n);
258 536 * If there is not enough core for the
259 537 * new process, swap out the current process to generate the
264 /usr/src/libc/v6/stat.c
266 Some system calls are changed from version 6 to version 7.
267 A library of system call entries, that make a version 6 UNIX look like
268 a version 7 system, is provided to run some
269 useful version 7 utilities, like 'tar', on UNIX-6.
270 The entry for 'stat' contained two bugs:
271 the 24-bit file size was incorrectly converted to 32 bits
272 (sign extension of bit 15)
273 and the uid/gid fields suffered from sign extension.
275 Transferring files from version 6 to version 7 using 'tar'
276 will fail for all files for which
278 ( (size & 0100000) != 0 )
280 These two errors are fixed if stat.c is modified as follows:
282 /* original /usr/src/libc/v6/stat.c */
288 49 buf->st_nlink = osbuf.os_nlinks;
289 50 buf->st_uid = osbuf.os_uid;
290 51 buf->st_gid = osbuf.os_gid;
293 /* modified /usr/src/libc/v6/stat.c */
296 12 unsigned os_size1;
299 49 buf->st_nlink = osbuf.os_nlinks;
300 50 buf->st_uid = osbuf.os_uid & 0377;
301 51 buf->st_gid = osbuf.os_gid & 0377;