Microsoft KB Archive/69510

Improper Error Handling When Writing to Locked Records PSS ID Number: Q69510 Article last modified on 04-08-1993

5.00

OS/2

Summary:

Using FORTRAN 5.00 under OS/2, error label branching does not occur when trying to WRITE to records that have been locked by another process using the LOCKING function. If “ERR=” is removed from the WRITE statement, the following error does NOT occur:

F6421: file read-only or locked against writing

The locked records are not overwritten in either case. Attempting to READ from a locked record produces the proper error message and will branch to a line number if ERR=(line number) is specified.

Microsoft has confirmed this to be a problem in FORTRAN version 5.00. This problem was corrected in Microsoft FORTRAN version 5.10.

More Information:

The programs below demonstrate the failure in error label branching while attempting to write to locked records. The first program, program one, locks records 7 through 10 of the direct access file, SECURE.DAT. The second program, program two, attempts to write to the records that were locked by program one.

First Program
program one integer*2 j character*10 name(10) data name/10*'AAAAAAAAAA'/

open (1,file='secure.dat',access='direct', +form='formatted',recl=20) do j=1,10 write (1,'(a)',rec=j) name(j),j if (j.gt.6) locking(1,lockmode='LOCK',rec=j) enddo write(*,*) 'file written' c Read line pauses program so new OS/2 process can run program two

read(*,*) close(1) end

Second Program
program two integer*2 j character*10 name(10) data name/10*'zzzzzzzzzz'/

open (1,file='secure.dat',access='direct', +form='formatted',recl=20) do 20 j=7,10 write (1,'(a)',rec=j,err=20) name(j),j write (*,*) 'no write error occurred ',j 20 continue close(1) end

After both programs have executed, the file SECURE.DAT contains the following data:

AAAAAAAAAA AAAAAAAAAA AAAAAAAAAA AAAAAAAAAA AAAAAAAAAA AAAAAAAAAA AAAAAAAAAA AAAAAAAAAA AAAAAAAAAA AAAAAAAAAA

Although the locked records remain unaltered, the output from program two appears as follows:

no write error occurred 7 no write error occurred 8 no write error occurred 9 no write error occurred 10

=
================================================================

Copyright Microsoft Corporation 1993.