Bug 1416796

Summary: rlRun -s can end in an endless loop under specific conditions
Product: [Fedora] Fedora Reporter: Frantisek Sumsal <fsumsal>
Component: beakerlibAssignee: Dalibor Pospíšil <dapospis>
Status: CLOSED CURRENTRELEASE QA Contact: Jiri Jaburek <jjaburek>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 25CC: azelinka, dapospis, jprokes, mkyral, muller
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: beakerlib-1.17-13 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-03-16 12:25: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:
Bug Depends On: 1361246    
Bug Blocks:    

Description Frantisek Sumsal 2017-01-26 12:45:20 UTC
Description of problem:
Some change in the testing version causes rlRun -s being stuck in an endless loop under some circumstances. I guess the culprit is commit 688273145292c75fb3e5ea013621746bd713086d.

Version-Release number of selected component (if applicable):
beakerlib-1.13-1.el7eso.noarch

How reproducible:
always

Steps to Reproduce:
# cat loop.sh
#!/bin/bash

. /usr/share/beakerlib/beakerlib.sh || exit 1

function sleep() {
    rlLogInfo "Waiting $1 secs"
    /bin/sleep $1
}

rlJournalStart
    rlPhaseStart FAIL
        rlRun -s "systemd-run --scope ./test.sh" 
    rlPhaseEnd
rlJournalEnd

# cat test.sh
#!/bin/bash

echo "Forking sleep"
( echo "Forked"; while true; do sleep 1; done ) &
echo "Main end"

Actual results:
# bash loop.sh 

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: [   LOG    ] :: Phase of FAIL type
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [  BEGIN   ] :: Running 'systemd-run --scope ./test.sh'
Running scope as unit run-18865.scope.
Forking sleep
Main end
Forked
:: [ 07:39:06 ] :: [ INFO    ] :: Waiting 0.01 secs
:: [ 07:39:06 ] :: [ INFO    ] :: Waiting 0.01 secs
:: [ 07:39:06 ] :: [ INFO    ] :: Waiting 0.01 secs
:: [ 07:39:06 ] :: [ INFO    ] :: Waiting 0.01 secs
:: [ 07:39:06 ] :: [ INFO    ] :: Waiting 0.01 secs
:: [ 07:39:06 ] :: [ INFO    ] :: Waiting 0.01 secs
:: [ 07:39:06 ] :: [ INFO    ] :: Waiting 0.01 secs
:: [ 07:39:06 ] :: [ INFO    ] :: Waiting 0.01 secs
:: [ 07:39:06 ] :: [ INFO    ] :: Waiting 0.01 secs
:: [ 07:39:06 ] :: [ INFO    ] :: Waiting 0.01 secs
:: [ 07:39:06 ] :: [ INFO    ] :: Waiting 0.01 secs (# see testing.sh:799)
...

Expected results:
# rpm -q beakerlib
beakerlib-1.11-1.el7.noarch
# bash loop.sh 

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: [   LOG    ] :: Phase of FAIL type
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [  BEGIN   ] :: Running 'systemd-run --scope ./test.sh'
Running scope as unit run-19470.scope.
Forking sleep
Main end
Forked
:: [   PASS   ] :: Command 'systemd-run --scope ./test.sh' (Expected 0, got 0)
:: [ 07:40:34 ] :: JOURNAL XML: /var/tmp/beakerlib-h11RGSv/journal.xml
:: [ 07:40:34 ] :: JOURNAL TXT: /var/tmp/beakerlib-h11RGSv/journal.txt

Comment 1 Dalibor Pospíšil 2017-01-26 12:58:00 UTC
This is caused by fix of bz1361246, let's continue discussion there.