Bad leaks file fd to child processes

2022-11-26 Thread ??????
Hello, 
 
I find that the file descriptor leaks when I execute the command pvs in bash 
5.2, The abnormal scenario is similar to the bug which reported by 
http://lists.gnu.org/archive/html/bug-bash/2017-01/msg00026.html 
 
When I execute pvs in the terminal opened through xshell??it??s ok 
 
PV VG  Fmt  Attr PSizePFree 
/dev/sda2  euleros lvm2 a--  <126.00g0 
 
But when I execute pvs in the terminal opened through vscode??use Remote-SHH to 
connect linux??, the File descriptor was leaked 
 
File descriptor 19 (/dev/ptmx) leaked on pvs invocation. Parent PID 3789: 
/usr/bin/bash 
File descriptor 20 (/dev/ptmx) leaked on pvs invocation. Parent PID 3789: 
/usr/bin/bash 
File descriptor 21 (/dev/ptmx) leaked on pvs invocation. Parent PID 3789: 
/usr/bin/bash 
File descriptor 99 
(/root/.vscode-server/bin/899d46d82c4c95423fb7e10e68eba52050e30ba3/vscode-remote-lock.root.899d46d82c4c95423fb7e10e68eba52050e30ba3)
 leaked on pvs invocation. Parent PID 3789: /usr/bin/bash 
  PV VG  Fmt  Attr PSizePFree 
  /dev/sda2  euleros lvm2 a--  <126.00g0 
 
I found that the leaked file descriptor was created in subst.c 
 
/* Pipe the output of executing STRING into the current shell. */ 
if (pipe(fildes) < 0) 
{ 
sys_error("%s", _("cannot make pipe for command substitution")); 
goto error_exit; 
} 
 
add it leaked in  
 
if (--bufn <= 0) 
{ 
SET_CLOSE_ON_EXEC(fd); 
bufn = zread(fd, buf, sizeof(buf)); 
if (bufn <= 0) 
break; 
bufp = buf; 
} 
 
I try to add SET_CLOSE_ON_EXEC (fd) before zread, but it doesn't seem to work.

Re: Bad leaks file fd to child processes

2022-11-26 Thread Andreas Schwab
On Nov 26 2022, "凋叶棕" via Bug reports for the GNU Bourne Again SHell wrote:

> But when I execute pvs in the terminal opened through vscode(use Remote-SHH 
> to connect linux), the File descriptor was leaked 
>  
> File descriptor 19 (/dev/ptmx) leaked on pvs invocation. Parent PID 3789: 
> /usr/bin/bash 
> File descriptor 20 (/dev/ptmx) leaked on pvs invocation. Parent PID 3789: 
> /usr/bin/bash 
> File descriptor 21 (/dev/ptmx) leaked on pvs invocation. Parent PID 3789: 
> /usr/bin/bash 
> File descriptor 99 
> (/root/.vscode-server/bin/899d46d82c4c95423fb7e10e68eba52050e30ba3/vscode-remote-lock.root.899d46d82c4c95423fb7e10e68eba52050e30ba3)
>  leaked on pvs invocation. Parent PID 3789: /usr/bin/bash 

That looks more like the FD leak is in vscode (and bash just hands them
through).

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."



Re: [bash 4] 'test -v 1' is never true

2022-11-26 Thread Chet Ramey

On 11/25/22 4:02 PM, Alejandro Colomar wrote:

Hi!

I wrote a script, and am trying it on many systems.  On RHEL8, which has 
bash 4, it didn't work.  I could reduce the problem to the following 
command, which never returns true:


     test -v 1;


This is a bash feature. I cribbed it from ksh93, and it first appeared in
bash-4.2.

The initial implementation was restricted to shell variables -- positional
parameters like $1 are not shell variables.

After a bunch of requests, like

https://lists.gnu.org/archive/html/bug-bash/2018-12/msg00098.html
https://lists.gnu.org/archive/html/bug-bash/2018-12/msg00104.html
https://lists.gnu.org/archive/html/bug-bash/2020-01/msg00027.html

I added support for testing positional parameters in bash-5.1.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/




Re: [bash 4] 'test -v 1' is never true

2022-11-26 Thread Alejandro Colomar

Hi Chet!

On 11/26/22 18:44, Chet Ramey wrote:

On 11/25/22 4:02 PM, Alejandro Colomar wrote:

Hi!

I wrote a script, and am trying it on many systems.  On RHEL8, which has bash 
4, it didn't work.  I could reduce the problem to the following command, which 
never returns true:


 test -v 1;


This is a bash feature. I cribbed it from ksh93, and it first appeared in
bash-4.2.

The initial implementation was restricted to shell variables -- positional
parameters like $1 are not shell variables.

After a bunch of requests, like

https://lists.gnu.org/archive/html/bug-bash/2018-12/msg00098.html
https://lists.gnu.org/archive/html/bug-bash/2018-12/msg00104.html
https://lists.gnu.org/archive/html/bug-bash/2020-01/msg00027.html

I added support for testing positional parameters in bash-5.1.


That was my gut; thanks!  I'll workaround with $#.

Cheers,

Alex


--



OpenPGP_signature
Description: OpenPGP digital signature


Re: Bad leaks file fd to child processes

2022-11-26 Thread Chet Ramey
On 11/26/22 5:05 AM, 凋叶棕 via Bug reports for the GNU Bourne Again SHell 
wrote:

Hello,
  
I find that the file descriptor leaks when I execute the command pvs in bash 5.2, The abnormal scenario is similar to the bug which reported by http://lists.gnu.org/archive/html/bug-bash/2017-01/msg00026.html


Can you supply a reproducer that demonstrates this is a problem with bash?

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/