Bug 1207253

Summary: Perl "bad file descriptor" error when using YaST commandline
Product: [openSUSE] openSUSE Distribution Reporter: Hans Heinrich Fiddelke <hh_fiddelke>
Component: YaST2Assignee: Michael Schröder <mls>
Status: RESOLVED DUPLICATE QA Contact: Jiri Srain <jsrain>
Severity: Normal    
Priority: P5 - None CC: fvogt, mls, mvidner, ncutler, yast-internal
Version: Leap 15.3   
Target Milestone: ---   
Hardware: Other   
OS: Other   
URL: https://trello.com/c/MtlIIzjR
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Hans Heinrich Fiddelke 2023-01-18 10:47:42 UTC
Hello,

using for example the command line "yast dns edit hostname=HOSTNAME" causes in Leap 15.4 (older and newer distros similar) the error
>>>>>
Warning: unable to close filehandle properly: Bad file descriptor, <STDIN> line
        3 during global destruction (#1)
    (S io) There were errors during the implicit close() done on a filehandle
    when its reference count reached zero while it was still open, e.g.:

        {
            open my $fh, '>', $file  or die "open: '$file': $!\n";
            print $fh $data or die "print: $!";
        } # implicit close here

    Because various errors may only be detected by close() (e.g. buffering could
    allow the print in this example to return true even when the disk is full),
    it is dangerous to ignore its result.  So when it happens implicitly, perl
    will signal errors by warning.

    Prior to version 5.22.0, perl ignored such errors, so the common idiom shown
    above was liable to cause silent data loss.
<<<<
which seems to be a known problem in the past.
Cause for this error seems to be the package "perl-TermReadLine-Gnu" (consider naming) V1.20, which is part of all 15.X Leap distributions.

Replacing this with the package perl-Term-ReadLine-Gnu V1.45 (also consider naming) from https://software.opensuse.org/package/perl-Term-ReadLine-Gnu

seems to fix the issue, but is missing in distributions
Comment 1 Stefan Hundhammer 2023-01-18 13:21:25 UTC
Thank you for your bug report. I can reproduce the problem.

After some initial confusion, we found some very old YaST modules that actually use Perl. AFAICS all of them are candidates for dropping for for a major refactoring. Dropping is much more likely.
Comment 2 Martin Vidner 2023-01-18 13:22:19 UTC
perl-TermReadLine-Gnu...
See also https://bugzilla.suse.com/show_bug.cgi?id=1203080
Comment 3 Stefan Hundhammer 2023-01-18 13:24:26 UTC
I just checked: yast2-users is also written in Perl, and that one is definitely not a drop candidate. It was refactored not so long ago, and it shows the same problem.

Reproducing it doesn't even need valid command line arguments:

% yast2 users foo

Unknown Command: foo
Use 'yast2 users help' for a complete list of available commands.
Warning: unable to close filehandle properly: Bad file descriptor, <STDIN> line
	5 during global destruction (#1)
    (S io) There were errors during the implicit close() done on a filehandle
    when its reference count reached zero while it was still open, e.g.:
    
        {
            open my $fh, '>', $file  or die "open: '$file': $!\n";
            print $fh $data or die "print: $!";
        } # implicit close here
    
    Because various errors may only be detected by close() (e.g. buffering could
    allow the print in this example to return true even when the disk is full),
    it is dangerous to ignore its result.  So when it happens implicitly, perl
    will signal errors by warning.
    
    Prior to version 5.22.0, perl ignored such errors, so the common idiom shown
    above was liable to cause silent data loss.
Comment 4 Stefan Hundhammer 2023-01-18 13:32:19 UTC
CC'ing our Perl maintainer.
Comment 5 Stefan Hundhammer 2023-01-18 13:33:06 UTC
Michael, please see the bug reporter's suggestion in comment #0.
Comment 8 Nathan Cutler 2023-03-10 09:42:19 UTC
The fix has reached Leap 15.3 as well:

https://build.opensuse.org/package/show/openSUSE:Leap:15.3:Update/perl-Term-ReadLine-Gnu