Opened 7 years ago
Last modified 12 days ago
#197 new task
tape_mult_ does not return error_table_$short_record when fewer chars remain than caller requested
| Reported by: | Gary Dixon | Owned by: | Eric Swenson |
|---|---|---|---|
| Priority: | minor | Milestone: | |
| Component: | General | Version: | |
| Keywords: | Cc: |
Description
The iox_$get_chars subroutine document (MPM Subroutines, AG93) specifies:
The desired number of bytes, N, is specified in the call. Some I/O modules may actually read fewer than N bytes into the buffer, even though N bytes are available from the file or device. In this case the code error table_$short_record is returned. When this code is returned, the caller may again call the iox_$get_chars entry point to get more bytes. The contents of the buffer beyond the last byte read are undefined.
The meaning of this specification is unclear. If taken literally, it says that error_table_$short_record should be used only if n_read (the number of bytes returned) is less than n (the number of bytes the caller asked to be read) AND there are more bytes to be read in subsequent calls. However, some people have interpreted this to mean error_table_$short_record should be returned whenever 0 < n_read < n, even when no more bytes remain to be read.
It is unclear which of these ambiguous interpretations of the iox_$get_chars specification is correct.
This ticket records the fact that the tape_mult_ I/O module does not return error_table_$short_record when
0 < n_read < n for the last set of data read from the tape.
Instead, it returns error_table_$end_of_info with 0 < n_read < n.
If tape_mult_'s implementation is deemed to be defective, it would have to be changed to return error_table_$short_record when last set of characters read was less than n (number of characters expected by the caller) when reading at end-of-tape.
NOTES:
It may be difficult to find all programs using tape_mult_ and evaluate whether they would work correctly if such change was made. Not all tape_mult_ programs are installed in the Multics Libraries. Some may be owned by users.
Furthermore, peruse_crossreference is of little help when searching for programs using I/O modules, since the I/O module name is generally a character string in an attach description; not a direct declaration and use of a particular subroutine entrypoint. print -match tape_mult_ might have to be used to search the Multics Library source directories for such programs.
Given the ambiguity of the iox_$get_chars specification, I am marking this ticket as a "task" type. It is not yet considered either a defect or an enhancement request.
See the description of iox_$get_chars and the tape_mult_ I/O module in the MPM Subroutines manual, AG93 for more details. See ticket #195 and MCR10071 (https://s3.amazonaws.com/eswenson-multics/public/mcrs/MCR10071.pdf) for more details about how this issue was discovered.
Change History (3)
comment:1 by , 12 days ago
comment:2 by , 12 days ago
- Callers rely on the current behavior. A caller that loops while the code is
short_recordand stops onend_of_infohandles the final partial buffer correctly today. Iftape_mult_returnedshort_recordthere instead, such a caller would call again and only then getend_of_info(withn_read = 0). Most callers would still work, but any that treatshort_recordas "more data follows", or that count records, could change behavior. - The callers can't all be found. As the ticket says,
tape_mult_is named in attach descriptions, not declared, so its users cannot be found by cross-reference. Some may be in users' directories. - Other modules behave the same way. Other I/O modules (for example
vfile_reading the last part of a file) also return a partial count withend_of_info. Changing one module would make them inconsistent.
comment:3 by , 12 days ago
We could add to the iox_$get_chars description (iox_.info and AG93) something like:
If fewer than N bytes remain before the end of the file or device, the remaining bytes are returned with n_read set ccordingly; the code may then be either 0 or error_table_end_of_info, depending on the I/O module.
error_table_short_record means that fewer than N bytes were returned although more data follows.
Callers should therefore always use n_read, whatever the code.
Files: documentation only (iox_.info), if the clarification is accepted.

The
iox_$get_charsdescription says thatshort_recordmeans the module read fewer than N bytes "even though N bytes are available", and that the caller may call again to get more. Read that way,short_recordis for a short read when more data follows, andend_of_infowith a nonzero count is the right report for the final partial read.tape_mult_'s behavior fits the literal text.