[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: changed file while editing



On Thu, Dec 16, 2021 at 06:04:05PM +0000, mick crane wrote:
> Is it at all possible that running Perl executable file somehow shares the
> same memory as same file opened in vi and they get jumbled?

No.  Each process has its own private memory space.

Even if you WROTE to the file (via perl or any other program), the
editing buffer you've already got opened in vi would not change, until
you explicitly tell vi to re-read the file from disk.

So when you add the notion of perl somehow ACCIDENTALLY writing to a
random file, it's just doubly nonsense.

Your problem description so far has been very hard to understand.  It's
not clear to me WHAT you are seeing, or why you've reached the conclusions
that you've reached.

I would start by trying to identify the LAYER where the error is
occurring.  This could be the X (or Wayland?) display system.  Or the
terminal emulator which uses the display system.  Or the editor which
uses the terminal emulator.  (Hint: it's probably not the editor.)

The first thing I'd do, when I see the problem happen again, would be
to ask the editor to redraw the contents of the terminal.  In vi, this
is done by pressing Ctrl-L while in command mode.  You should see a
very brief flash as the terminal's contents are wiped, and then recreated.

Editors have this command because they run on terminals, and terminals
were traditionally connected via RS-232 serial lines, either hard-wired
inside a building, or with a modem involved.  When a modem is involved,
there is a phenomenon called "line noise" which frequently causes extra
characters to be printed on the terminal wherever the cursor happens to
be.  You can ignore these for a while, but if they start to accumulate,
or if you're especially bothered by them, you just request a screen redraw.

If redrawing the screen within the editor fixes the problem, then the
problem was most likely extra characters that had been written onto the
terminal.  At that point, you can try to discover what wrote them, but
it might not be easy to do so.  Anything with appropriate privileges can
open one of your terminals and write to it.  This would include any program
you're running, but also things like the kernel broadcasting an emergency
message to every terminal.  (I doubt the latter is the case for you, as
you seem to be saying this is a frequent occurrence, and that you don't
recognize the unexpected content.  Maybe.  It's hard to understand what
you're saying.)

If redrawing the screen doesn't do anything, then I'd try to figure out
the nature of the unexpected content.  Is it whole characters?  Like,
could you -- in theory -- run commands from a different terminal which
would move the cursor and write characters on the mangled terminal, and
get the results that you see?

Or is it misplaced pixels, rather than whole characters?  Do you see pieces
of window manager borders, parts of characters, and stuff like that?

If you're seeing pixel-level stuff, that points toward an issue at the X
or Wayland level, possibly bogus drivers or firmware.  Or even bad hardware.

If it's misplaced whole characters, which are not fixed by redrawing the
screen within the editor, then that sounds like a bug in your terminal
emulator.

Another simple test to perform would be to MOVE the window around.  Does
this change the unexpected content, or does it move around with the window?

Be specific and detailed about what you do.  Be clear in how you describe
things.  Otherwise, we can't help you.


Reply to: