help-bash
[Top][All Lists]
Advanced

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

Bug that only happens in ubuntu 22.04 even with older bash version


From: Robert E. Griffith
Subject: Bug that only happens in ubuntu 22.04 even with older bash version
Date: Mon, 8 Aug 2022 12:11:40 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0

Does anyone know how bash 5.0 and 5.1 on ubuntu 22.04(jammy) could behave differently from bash 5.0 and 5.1 onĀ  20.04(focal)?

The two symptoms I see are...

   1. rarely but repeatedly a DEBUG trap starts reentering itself in a
   infinite loop. set -x shows that it runs a handfull of benign
   looking, false conditions and the last command printed is just
   declaring a local variable with no assignment and then it goes back
   to the first command of the trap string.

   2. rarely but repeatedly a DEBUG trap stops updating BASH_COMMAND so
   that it gets stuck on that command and no longer updates even though
   its actually executing other script commands. its typically not
   first command -- its updates for a while and then stops.

On 22.04(jammy), I have tested the static and dynamically linked bash binaries from ubuntu packages and compiled several 5.0 and 5.1 github branchesĀ  and always get the same incorrect behavior.

On 20.04(focal) I have compiled the jammy bash5.1 source package and 5.1 release from git hub and always get the correct behavior. (focal uses bash 5.0 by default which behaves correctly)

I have only tested jammy in a VM. I tested focal on my native host and in a focal VM created the same way as the jammy VM.

Here is the test script that I use to reproduce behavior 2 (BASH_COMMAND stops update in the DEBUG trap). I have not yet been able to reproduce the behavior 1 (reentering infinite loop) in a small test script.

   bobg@focal$ cat ./debugUsr2Trap5.1.sh
   #!/usr/bin/env bash
   shopt -s extdebug
   count=8
   dbgScript='
        echo "# ENTER DEBUG  ($BASH_COMMAND) (${#FUNCNAME[@]})";
        ((count--<=0)) && exit
        if (( ${#FUNCNAME[@]} <3 )); then
                trap - DEBUG
                local code=0
        else
                local code=2
        fi
        (exit $code)
   '
   function f1() {
        trap "$dbgScript" DEBUG
        echo "SHOULD NOT PRINT"
   }
   function f2() {
        f1
        echo "this should print"
   }
   f2

   #### This is the correct result I get on ubunut 20.04(focal) no matter which 
bash 5.0 and 5.1 I try
   bobg@focal$ ./debugUsr2Trap5.1.sh
   # ENTER DEBUG  (echo "SHOULD NOT PRINT") (3)
   # ENTER DEBUG  (echo "this should print") (2)
   this should print

   #### This is the incorrect result I get on ubunut 22.04(jammy) no matter 
which bash 5.0 and 5.1 I try
   ubuntu@bgcore-jammy$ ./debugUsr2Trap5.1.sh
   # ENTER DEBUG  (echo "SHOULD NOT PRINT") (3)
   # ENTER DEBUG  (exit $code) (3)
   # ENTER DEBUG  (exit $code) (3)
   # ENTER DEBUG  (exit $code) (3)
   # ENTER DEBUG  (exit $code) (3)
   # ENTER DEBUG  (exit $code) (3)
   # ENTER DEBUG  (exit $code) (3)
   # ENTER DEBUG  (exit $code) (3)
   # ENTER DEBUG  (exit $code) (3)
   # ENTER DEBUG  (echo "this should print") (2)
   this should print

Any ideas?

--BobG





reply via email to

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