CotEditor icon indicating copy to clipboard operation
CotEditor copied to clipboard

Application stops responding when open files are changed externally at a slow rate

Open gingerbeardman opened this issue 4 years ago • 0 comments

Description

Application stops responding when open files are changed externally.

More specifically, when they are written by an external app at a slow rate.

To Reproduce

  1. Open a large file
  2. Whilst the file is open rewrite it at a slow rate
  3. app stops responding

Using attached files

  1. extract files crash-bundle.zip
  2. in terminal run ./crash.sh

This does

  1. opens two documents
  2. rewrite slowly both files one at a time
  3. app stops responding

Source code

crash.sh to open files and then write to those open files

linesPerSecond=500
echo "opening files"
cot macuser.txt nikkei.txt
echo "rewriting macuser.txt"
./catLPS.pl $linesPerSecond original.macuser.txt > macuser.txt
echo "rewriting nikkei.txt"
./catLPS.pl $linesPerSecond original.nikkei.txt > nikkei.txt

catLPS.pl to write a file at specific lines per second

#!/usr/bin/perl -w

use strict;
use Time::HiRes qw|time|;

my $start=time;
my $lps=300;

$lps=shift @ARGV if @ARGV && $ARGV[0]=~/^(\d+)$/;
my $sleepPerLine=1/$lps;

print &&
    select undef,undef,undef,($start + $sleepPerLine*$. - Time::HiRes::time)
    while <>

Expected behavior

  • app should not stop responding

CotEditor version

4.0.8 (471)

macOS version

11.6 (20G165)

Additional context

  • Sample of CotEditor.txt
  • In real life I encounter this by rewriting a large directory listing whilst it is open
  • Note that if you change linesPerSecond to something higher, say 2000, the app will not crash

gingerbeardman avatar Nov 04 '21 00:11 gingerbeardman