bug-bash
[Top][All Lists]
Advanced

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

Incomplete cleanup in Bash with malformed heredoc in pipeline


From: Alvaro Falagan
Subject: Incomplete cleanup in Bash with malformed heredoc in pipeline
Date: Wed, 18 Jun 2025 23:37:07 +0200

Hi,

I would like to report an issue I’ve found in Bash (5.0.17) regarding the
use of pipelines involving built-in commands and here-documents.

### Summary

When a built-in (e.g., `echo`, `export`, `cd`, etc.) is used in a pipeline,
and the next command starts with a malformed or incomplete `<<EOF` heredoc,
Bash does not clean up all its internal memory and leaves at least one file
descriptor (`/dev/pts/0`, fd 255) open at exit.

This issue is not limited to `echo`; it happens with any built-in command,
as long as a heredoc follows it improperly in a pipeline.

### Example

```bash
echo hola | <<EOF
some text
EOF

Valgrind was run with:
    valgrind --leak-check=full --track-origins=yes --track-fds=yes bash

Environment:
- Bash version: GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu)
- OS: Ubuntu 22.04 under WSL 1 (Windows Subsystem for Linux)
- Full Valgrind output is attached.

Attachment: valgrind_output.txt
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]