Bug 1413676

Summary: Bash leaks heredoc fd to child processes
Product: [Fedora] Fedora Reporter: Edgar Hoch <edgar.hoch>
Component: bashAssignee: Siteshwar Vashisht <svashisht>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: unspecified    
Version: 25CC: admiller, agk, anprice, bmarzins, bmr, heinzm, jonathan, kdudka, lvm-team, msnitzer, prajnoha, prockai, svashisht, zkabelac
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: bash-4.4.12-4.fc26 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-04-27 20:55:12 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Do not leak heredoc fd to child processes none

Description Edgar Hoch 2017-01-16 16:25:22 UTC
Description of problem:

When I call pvs, vgs or lvs from scripts in a bash command substitution, then I get an error of the following form for each invocation of these commands:

File descriptor 3 (/tmp/sh-thd-871826097) leaked on pvs invocation. Parent PID 1769: /bin/bash

For example, I call these commands in a command substitution to include the result in the body of an e-mail. See Steps to Reproduce.


Version-Release number of selected component (if applicable):
lvm2-2.02.167-3.fc25.x86_64

How reproducible:
Always

Steps to Reproduce:
1. Create a shell script "mailtestscript" with following content:

#!/bin/bash

    Mail -s "mail test with pvs vgs lvs" myname <<EOF

LVM physical volumes:
`pvs`

LVM volume groups:
`vgs`

LVM logical volumes:
`lvs`

EOF


2. Substitute "myname" by a valid e-mail address of your own (to receive the e-mail which the script will send).

3. Make the script executable:
   chmod u+x mailtestscript

4. Run the script:
   ./mailtestscript

Actual results:

Output of the script are messages like this:

File descriptor 3 (/tmp/sh-thd-871866956) leaked on pvs invocation. Parent PID 6142: /bin/bash
File descriptor 3 (/tmp/sh-thd-871866956) leaked on vgs invocation. Parent PID 6142: /bin/bash
File descriptor 3 (/tmp/sh-thd-871866956) leaked on lvs invocation. Parent PID 6142: /bin/bash

It sends an e-mail (as expected).


Expected results:

The script should print nothing to standard out and standard error.
It should send only an e-mail.

Additional info:

This happens at least since a longer time, at least since Fedora 24, maybe even on previous version. I have not reported is until now because the commands have been working as expected, besides of these error message.

Comment 1 Zdenek Kabelac 2017-01-16 16:40:18 UTC
I'd say it's rather a misuse of lvm2 commands.
You should prepare resulting text output ahead of Mail command.
Otherwise you have no idea what has 'failed' during creation.

But if there is a bug  - it's bug in bash which should not be exposing FD for its  <<EOF magic to executed command.

Comment 2 Siteshwar Vashisht 2017-01-17 13:30:58 UTC
Created attachment 1241774 [details]
Do not leak heredoc fd to child processes

Comment 3 Siteshwar Vashisht 2017-01-17 13:37:32 UTC
I posted my patch upstream http://lists.gnu.org/archive/html/bug-bash/2017-01/msg00026.html

Comment 4 Fedora Update System 2017-04-26 13:02:22 UTC
bash-4.4.12-4.fc26 has been submitted as an update to Fedora 26. https://bodhi.fedoraproject.org/updates/FEDORA-2017-075ed3aef8

Comment 5 Fedora Update System 2017-04-26 21:53:19 UTC
bash-4.4.12-4.fc26 has been pushed to the Fedora 26 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2017-075ed3aef8

Comment 6 Fedora Update System 2017-04-27 20:55:12 UTC
bash-4.4.12-4.fc26 has been pushed to the Fedora 26 stable repository. If problems still persist, please make note of it in this bug report.