Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!rutgers!husc6!ut-sally!utah-cs!b-davis From: b-davis@utah-cs.UUCP Newsgroups: comp.sys.ibm.pc Subject: Major bug in all(?) versions of MS-DOS. Message-ID: <4274@utah-cs.UUCP> Date: Fri, 6-Feb-87 17:48:53 EST Article-I.D.: utah-cs.4274 Posted: Fri Feb 6 17:48:53 1987 Date-Received: Sun, 8-Feb-87 00:40:09 EST Organization: University of Utah VCIS Group Lines: 95 Keywords: bug ; Here is a probable bug (or feature) in MS-DOS. Does anyone know a ; work around (without closing the first file)? Would Gordon Letwin at ; Microsoft care to comment? This bug appears on PC-DOS 2.0, PC-DOS 3.0, ; and MS-DOS 3.1. (Unix has no problems with this algorigthm.) ; The test goes like this: ; Create a file with name 'xxx'. Call this file FD1. ; Write 80 bytes to FD1. ; Open the file named 'xxx' a second time. Call this file FD2. ; Note that NO errors have happened yet. ; Try to read 80 bytes from FD2. No bytes are read. ; Note that NO error is reported. ; If in symdeb push to a new shell. See that the file 'xxx' has ; been created but has a size of 0. ; Exit the program. See that the file 'xxx' is now 80 bytes long. ; If FD1 is closed at POINT A (see source) then FD2 will perform the read. ; If FD1 is closed at POINT B (see source) then the read of FD2 still fails ; even though the disk has been updated before the read happens. xtest segment para public 'prog' assume cs:xtest,ds:xtest org 100h start: jmp main ; int fd1, fd2; ; char buffer[80]; ; int a, b; fd1 dw 0 fd2 dw 0 buffer db 80 dup (0) a dw 0 b dw 0 xxx db "xxx", 0 main: ; modify memory so symdeb can push a shell mov bx, 4096 mov ah, 4ah int 21h ; create a file ; fd1 = open("xxx", O_TRUNC | O_CREAT | O_RDWR | O_BINARY, 0600); mov dx, offset xxx mov cx, 0 mov ah, 3ch int 21h mov fd1, ax ; write out 80 bytes ; a = write(fd1, buffer, sizeof(buffer)); mov bx, fd1 mov dx, offset buffer mov cx, size buffer mov ah, 40h int 21h mov a, ax ; POINT A ; If these three lines are included then all works well. ; mov bx, fd1 ; mov ah, 3eh ; int 21h ; open the file a second time ; fd2 = open("xxx", O_RDWR | O_BINARY, 0); mov dx, offset xxx mov al, 2 mov ah, 3dh int 21h mov fd2, ax ; POINT B ; If these three lines are included then the read still fails. ; mov bx, fd1 ; mov ah, 3eh ; int 21h ; read the data from the second file ; b = read(fd2, buffer, sizeof(buffer)); mov bx, fd2 mov dx, offset buffer mov cx, size buffer mov ah, 3fh int 21h mov b, ax ; Here a = 80 and b = 0. Shouldn't b = 80 also? ; return to system mov al, 0 mov ah, 4ch int 21h ret xtest ends end start ;--------------------------- End of Test ----------------------- -- Brad Davis {ihnp4, decvax, seismo}!utah-cs!b-davis b-davis@utah-cs.ARPA One drunk driver can ruin your whole day.