New Issue: I/O module: bug with specifying a different end position for a channel than 'max(int(64))'

20450, "lydia-duncan", "I/O module: bug with specifying a different end position for a channel than 'max(int(64))'", "2022-08-16T15:15:52Z"

Summary of Problem

I discovered that if a file already has contents and you create a writing channel (at least using openwriter, though I don't see why file.writer would behave any differently since openwriter calls it), specifying an ending location other than max(int(64)) (the end of the file) will cause all the characters after the end location to be dropped, truncating the file after your additions.

This seems incorrect - I would expect the contents of the file outside of the specified region to be untouched, enabling concurrent modifications to distinct parts of the file.

Steps to Reproduce

Source Code:

use IO;

var filename = "openwriterLimited.txt";
var writeCh = openwriter(filename);
writeCh.writeln("She said she was looking for me");
writeCh.close();

var writeChEnd = openwriter(filename, end=3);
writeChEnd.write("You");
writeChEnd.close();

Compile command:
chpl foo.chpl

Execution command:
./foo

Associated Future Test(s):
TBA

Configuration Information

  • Output of chpl --version: chpl version 1.28.0 pre-release
  • Output of $CHPL_HOME/util/printchplenv --anonymize:
    CHPL_TARGET_PLATFORM: darwin
    CHPL_TARGET_COMPILER: clang
    CHPL_TARGET_ARCH: x86_64
    CHPL_TARGET_CPU: native
    CHPL_LOCALE_MODEL: flat
    CHPL_COMM: none
    CHPL_TASKS: qthreads
    CHPL_LAUNCHER: none
    CHPL_TIMERS: generic
    CHPL_UNWIND: none
    CHPL_MEM: jemalloc
    CHPL_ATOMICS: cstdlib
    CHPL_GMP: bundled
    CHPL_HWLOC: bundled
    CHPL_RE2: bundled
    CHPL_LLVM: none *
    CHPL_AUX_FILESYS: none
  • Back-end compiler and version, e.g. gcc --version or clang --version:
    Apple clang version 11.0.3 (clang-1103.0.32.62)
    Target: x86_64-apple-darwin20.6.0
    Thread model: posix
    InstalledDir: /Library/Developer/CommandLineTools/usr/bin