Menu

#58 '-stty: 'standard input': Inappropriate ioctl for device' makes 6 tests fail

v1.0_(example)
open
nobody
None
9
2020-03-28
2018-11-18
No

Debian buster
bashdb release-4.4-1.0.1
bash 4.4.18-3.1

Buiding bashdb sources from https://git.code.sf.net/p/bashdb/code at release-4.4-1.0.1 checkout with:
export NOCONFIGURE=yes
/autogen.sh
/configure --with-bash-src=/home/actionmystique/src/Bash/bash-build/bash-4.4.18-3.1\ --build=x86_64-pc-linux-gnu \ --prefix=/usr --sysconfdir=/etc --localstatedir=/var \ --infodir=/usr/share/info --mandir=/usr/share/man
remake --trace
make check

leads to:

...
make[4]: Entering directory '/media/actionmystique/SAMSUNG5-Shared/home/actionmystique/src/Bash/git-bashdb/test/integration'
PASS: test-bug-step-subshell
PASS: test-bug-set-e
PASS: test-complete
PASS: test-debug
PASS: test-delete
PASS: test-export
PASS: test-file-with-spaces
PASS: test-info-args
FAIL: test-interrupt
PASS: test-misc
PASS: test-setshow
SKIP: test-sig
PASS: test-action
PASS: test-brkpt
PASS: test-bug-args
PASS: test-bugI
PASS: test-bugIFS
PASS: test-bug-loc
PASS: test-bug-source
PASS: test-command
PASS: test-display
PASS: test-enable
PASS: test-finish
PASS: test-frame
PASS: test-list
FAIL: test-lopts
PASS: test-multi
PASS: test-parm
PASS: test-restart
PASS: test-search
FAIL: test-settrace
PASS: test-skip
FAIL: test-sopts
PASS: test-bug-break
PASS: test-bug-clear
PASS: test-bug-step
PASS: test-subshell
PASS: test-tbreak
FAIL: test-trace
PASS: test-watch1
PASS: test-watch2
============================================================================
Testsuite summary for bashdb 4.4-1.0.2git
============================================================================
# TOTAL: 44
# PASS:  37
# SKIP:  1
# XFAIL: 0
# FAIL:  6
# XPASS: 0
# ERROR: 0
============================================================================
See test/integration/test-suite.log
Please report to https://sourceforge.net/p/bashdb/bugs/new/
============================================================================

test/integration/test-suite.log is attached.

1 Attachments

Discussion

  • Jean-christophe Manciot

    There is a type in previous bug report: release-4.4-1.0.1 checkout must be replaced by 2d1a608 checkout

     
  • Rocky Bernstein

    Rocky Bernstein - 2018-11-18

    I can't reproduce this on my setup. See if the below fixes this.

    If not, suggest something if you are able.

    diff --git a/init/term-background.sh b/init/term-background.sh
    index 413b63d..b661807 100644
    --- a/init/term-background.sh
    +++ b/init/term-background.sh
    @@ -73,21 +73,24 @@ exit_if_not_sourced() {
     # User should set up RGB_fg and RGB_bg arrays
     xterm_compatible_fg_bg() {
         typeset fg bg junk
    -    stty -echo
    -    # Issue command to get both foreground and
    -    # background color
    -    #            fg       bg
    -    echo -ne '\e]10;?\a\e]11;?\a'
    -    IFS=: read -t 0.1 -d $'\a' x fg
    -    IFS=: read -t 0.1 -d $'\a' x bg
    -    stty echo
    -    [[ -z $bg ]] && return 1
    -    typeset -p fg
    -    typeset -p bg
    -    IFS='/' read -ra RGB_fg <<< $fg
    -    IFS='/' read -ra RGB_bg <<< $bg
    -    typeset -p RGB_fg
    -    typeset -p RGB_bg
    +    if stty -echo 2>/dev/null; then
    +   # Issue command to get both foreground and
    +   # background color
    +   #            fg       bg
    +   echo -ne '\e]10;?\a\e]11;?\a'
    +   IFS=: read -t 0.1 -d $'\a' x fg
    +   IFS=: read -t 0.1 -d $'\a' x bg
    +   stty echo
    +   [[ -z $bg ]] && return 1
    +   typeset -p fg
    +   typeset -p bg
    +   IFS='/' read -ra RGB_fg <<< $fg
    +   IFS='/' read -ra RGB_bg <<< $bg
    +   typeset -p RGB_fg
    +   typeset -p RGB_bg
    +    else
    +   stty echo 2>/dev/null
    +    fi
         return 0
     }
    
     
    👍
    1
  • Jean-christophe Manciot

    This patch does not change anything, except that 1 test is skipped.

    I have found this link online which may be helpful, although the context is different.

     

    Last edit: Jean-christophe Manciot 2018-11-18
  • Rocky Bernstein

    Rocky Bernstein - 2018-11-18

    Ok. If you would like to work up a solution, I would appreciate it. Otherwise this bug can hang out for a while until someone else has the problem and wants to address it.

     
  • Jean-christophe Manciot

    Actually, I did not check the status of the patch apply the first time: it turns out it seems corrupted:

    git apply ../bug-report#58.patch
    error: corrupt patch at line 44
    

    Strange error message because there is no.... line 44.
    The patch I applied is attached.

     
  • Rocky Bernstein

    Rocky Bernstein - 2018-11-18
    • Priority: 5 --> 9
     
  • Jean-christophe Manciot

    git: 1:2.19.1-1

     
  • Jaime Hablutzel

    Jaime Hablutzel - 2020-03-28

    Note that this bug report is related to the following erratic behavior.

    Say you want to debug a script that receives piped data:

    echo "piped data" | bashdb --tty /dev/pts/0 --tty_in /dev/pts/0 script_that_reads_stdin.sh
    

    Currently, the first call to "read" around the function "xterm_cormpatible_fg_bg" in "init/term-background.sh":

    ...
    IFS=: read -t 0.1 -d $'\a' x fg
    ...
    

    Will unintendedly consume the piped data, so when the script being debugged tries to read the data it might not be available anymore.

    Now, I've just tested that the patch in https://sourceforge.net/p/bashdb/bugs/58/#e212 fixes this behavior when input is received through a pipe but I'm not really sure if these calls to "read" are totally safe when receiving input from a terminal and if they could unintentionally consume input intended to be read by the script being debugged.

     

    Last edit: Jaime Hablutzel 2020-03-28
  • Rocky Bernstein

    Rocky Bernstein - 2020-03-28

    First let me summarize what's going on before suggesting what might be done.

    bashdb is trying to be "smart" about what kind of background you got so that its terminal highlightiing will look nice. From the value of TERM environment variable, it thinks you are running something xterm-compatible. xterm has this thing that when you issue a funny command it will echo data, and the data piped in competes with this.

    One possible solution is unset TERM beforehand or set it to something that doesn't start "xterm" | "gnome" | "rxvt". If you care about getting the background right, that can be done by setting COLORFGBG, passing the --highlightoption to bashdb, setting this in a .bashdbrc profile or running some commands inside bashdb.

    The above feel to me a little more direct than trying to make bashdb "smarter", which I think is a lost cause since I am sure people will find even more clever ways to invoke the debugger.

    But what do you think?

     
    • Jaime Hablutzel

      Jaime Hablutzel - 2020-03-28

      One possible solution is unset TERM beforehand or set it to something that doesn't start "xterm" | "gnome" | "rxvt".

      I've tested this and it works, but asking a regular user to do this would be confusing to say the least.

      The above feel to me a little more direct than trying to make bashdb "smarter",

      To me (as a noob in terminals, bash, etc), the patch in https://sourceforge.net/p/bashdb/bugs/58/#e212 doesn't seem to be adding more "smart" logic as it seems to be just asking where the input is coming from and executing the "smart" terminal highlighting related logic only when input comes from a terminal and not from a pipe which is the expected behavior if I'm not wrong.

       
  • Rocky Bernstein

    Rocky Bernstein - 2020-03-28

    Ok. In commit a409bf6 I have applied the logic in the patch. The attached patch above was rejected by patch so I did it by hand, and I make mistakes. So please double check.

     

    Last edit: Rocky Bernstein 2020-03-28

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.