Public bug reported:

Title:
bash/readline 5.2 corrupts redisplay of large multiline bracketed paste; fixed 
in bash 5.3

Description:

Ubuntu 24.04 LTS / Noble: bash/readline produces a badly corrupted
on-screen redisplay when a sufficiently large multiline block is pasted
into an interactive shell using bracketed paste.

The pasted input itself appears to remain correct. The problem is the
interactive readline redisplay: text fragments are shifted, overwritten,
or displayed at unexpected positions, making it difficult to verify the
command before pressing Enter.

This is especially problematic for administrative SSH sessions where
large multiline shell commands are pasted and visually reviewed before
execution.


TESTED ENVIRONMENT
==================

Ubuntu release:
  Ubuntu 24.04 LTS (Noble)

Ubuntu bash package:
  bash 5.2.21-2ubuntu4

Bash:
  GNU bash, version 5.2.21(1)-release (x86_64-pc-linux-gnu)

TERM:
  xterm-256color

Terminal dimensions during testing:
  141 columns x 41 rows

Connection:
  interactive SSH/PTTY session


REPRODUCTION
============

1. Start a completely unconfigured bash 5.2 shell:

   INPUTRC=/dev/null /bin/bash --noprofile --norc

2. Paste the attached file
   readline-multiline-paste-reproducer.txt
   into the interactive readline prompt. Do not execute it.

3. Observe the displayed input.


ACTUAL RESULT
=============

The readline display becomes corrupted.

Parts of previously pasted lines may appear shifted or overwritten.
The visual representation no longer reliably corresponds to the logical
layout of the pasted multiline input.

Changing the prompt to a minimal PS1 does not solve the problem.

The problem also reproduces with:

  INPUTRC=/dev/null
  /bin/bash --noprofile --norc

so it does not appear to depend on ~/.bashrc, ~/.inputrc, prompt colour
sequences, or user readline configuration.

Setting:

  bind 'set enable-active-region off'

does not fix the issue.

Enabling horizontal scrolling:

  bind 'set horizontal-scroll-mode on'

changes the display behaviour but does not solve the underlying problem.
Newlines may then be visibly represented as ^J while navigating the
pasted buffer.


EXPECTED RESULT
===============

A multiline bracketed paste should remain visually stable and accurately
redisplayed, including when the logical input occupies more physical
screen lines than the terminal height.

The user should be able to inspect the entire pasted command reliably
before executing it.


DATA INTEGRITY
==============

During testing, the pasted bytes themselves were checked separately.

Pasting into a file using:

  cat > /tmp/paste-test.txt

and comparing the resulting contents showed that the pasted data itself
was intact.

The observed problem therefore appears to be a readline redisplay issue,
rather than clipboard, SSH, or input corruption.


VERSION COMPARISON
==================

The problem was tested on the SAME HOST through the SAME SSH connection,
PTY and terminal.

Results:

  Ubuntu Noble bash 5.2.21:
    REPRODUCES

  GNU bash 5.2.37, built from the upstream bash 5.2 source with all
  official bash52-001 through bash52-037 patches:
    REPRODUCES

  GNU bash 5.3.15, built separately on the same Ubuntu 24.04 host:
    DOES NOT REPRODUCE

  Bash 5.3 inside an Ubuntu 26.04 container, reached through the same
  SSH session and terminal:
    DOES NOT REPRODUCE

This is important because updating from bash 5.2.21 to the final upstream
5.2 patchlevel (5.2.37) does not fix the problem.

The behavioural change appears only with the bash 5.3 / readline 8.3
generation.


POSSIBLE UPSTREAM RELATION
==========================

The GNU Readline 8.3 change log contains redisplay-related changes that
look relevant to this behaviour, including support for input lines that
consume more than the physical number of screen lines, plus other
redisplay fixes.

Given that:

  bash/readline 5.2.21 -> affected
  bash/readline 5.2.37 -> affected
  bash/readline 5.3.x  -> not affected

this may be related to the readline 8.3 redisplay changes rather than to
one of the later bash 5.2 patch releases.

I have not identified a single upstream commit that can safely be claimed
as the exact fix, so this should be treated as a suspected upstream
relationship rather than a confirmed commit-level diagnosis.


IMPACT
======

This does not appear to corrupt the actual pasted bytes.

However, it is more than a cosmetic inconvenience for interactive
administration: the shell can display a pasted command differently enough
that an administrator cannot reliably review the command shown on screen
before executing it.

For commands involving package management, firewall configuration,
service configuration, etc., reliable pre-execution display is an
important safety property.


REQUEST
=======

Please investigate whether the Readline 8.3 redisplay changes relevant to
input exceeding the physical terminal height can be safely backported to
Noble's bash 5.2 package.

Replacing Noble's bash 5.2 with bash 5.3 is not being requested.

A targeted backport would be preferable if the relevant upstream changes
can be isolated with acceptable regression risk.

ProblemType: Bug
DistroRelease: Ubuntu 24.04
Package: bash 5.2.21-2ubuntu4
ProcVersionSignature: Ubuntu 6.8.0-137.137-generic 6.8.12
Uname: Linux 6.8.0-137-generic x86_64
ApportVersion: 2.28.3-0ubuntu0.1
Architecture: amd64
CasperMD5CheckResult: unknown
CloudArchitecture: x86_64
CloudBuildName: server
CloudID: ui
CloudName: ui
CloudPlatform: ui
CloudRegion: Germany (South)
CloudSerial: 20250626
CloudSubPlatform: metadata (http://169.254.169.254/latest/)
Date: Sun Aug 23 08:51:11 2026
SourcePackage: bash
UpgradeStatus: No upgrade log present (probably fresh install)

** Affects: bash (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: amd64 apport-bug cloud-image noble

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2164834

Title:
  bash/readline 5.2 corrupts redisplay of large multiline bracketed
  paste; fixed in bash 5.3

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/bash/+bug/2164834/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to