bug-bash
[Top][All Lists]
Advanced

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

RE: builtin bash echo failing - errno EINTR on multi-CPU machine


From: Philippe Champagne
Subject: RE: builtin bash echo failing - errno EINTR on multi-CPU machine
Date: Thu, 24 Jun 2004 13:38:21 -0700

I was able to reproduce the problem with a smaller bash script.
Only require that file
I notice that if I remove either the "read tag val ... " line (and artificially set tag and val to some values)
or if I remove the if statement following it, then I don't get the echo error (ie: echo returning failure).
 
#!/bin/bash

let i=0;
 
while true; do
                let i=$i+1
                line="filename: aajjj"
 
                read tag val < <(echo "$line")
 
                if [ "$tag" = "filename" ]; then
                    fname="$val"
                elif [ "$tag" = "size" ]; then
                    nbytes="$val"
                fi
 
                # format the output
                if [ ! -z  "$tag" ] && [ ! -z "$val" ]; then
                        echo -n "| $tag: $val" || {
echo $?
echo "echo1 failed"
exit 1
}
                fi
                if [ "$i" -eq 10 ]; then
                    echo " Done " || {
echo " echo2 failed "
exit 1
}
                    exit 0;
                fi
done
exit 0
 
 
-----Original Message-----
Subject: builtin bash echo failing - errno EINTR on multi-CPU machine

Hi
 
I have a condition where I get about 5% failures of echo in bash.
The failure rate varies depending on the machine but easier to get on multiprocessor machine. Actually, so far I was not able to reproduce it on a single CPU machine... (SMP related?)
I'm running Linux 2.4.20 and GNU bash, version 2.05a.0(1)-release (i686-pc-linux-gnu)
glibc version is 2.2.5 but I tried on another machine that uses glibc 2.3.2 and all had the problem (all that have dual CPU or more)
 
With some debug code, I found out errno is set to EINTR when we get the error.
This errno is set after a call to printf in the bash builtin echo C source code.
 
I was hoping you could help me figure out what's going on here.
 
Following are the 3 files required
mytest.sh is the actual bash file with the failing echo
test.pkg is a file mytest.sh uses
trun.sh is a little helper to run it many times.
 
Note: the "echo1 failed" or "echo2 failed" are the 2 locations where we hit the problems.
(although as you can see, we haven't check the exit code from all echo)
 
Any help will be appreciated - thx
 
------------------mytest.sh
#!/bin/bash
 
ifs=$IFS
IFS=$(echo -ne '\t\r\n')
 
while read sh_line
do
        #echo "sh_line: [$sh_line]"
        if [ -z $sh_line ]
        then
                ## start reading files
                first_line=0
                while read line junk
                do
                        IFS=' :'
                        read tag val < <(echo "$line")
 
                if [ "$tag" = "filename" ]; then
                    fname="$val"
                elif [ "$tag" = "size" ]; then
                    nbytes="$val"
                elif [ -z $tag ] && [ -z $val ]; then
                        echo " "
                fi
 
                # format the output
                if [ ! -z  "$tag" ] && [ ! -z "$val" ]; then
                        if [ $first_line -eq 1 ]; then
                                echo -n "| $tag: $val" || {
echo $?
echo "echo1 failed"
exit 1
}
                        else
                                echo -n "$tag: $val" || {
echo $?
echo "echo2 failed"
exit 1
}
                        first_line=1
                        fi
                fi
 
                # go back to reading one line at a time.
                IFS=$(echo -ne '\t\r\n')
                done
        fi
done < test.pkg
exit 0
------------- end
 
-------test.pkg file needed by mytest.sh
name: something
description: A Simple Description
platform: PC
size: 14329
 
filename: flist.txt
filetype: txt
size: 143209
utc_date: 060220262004.17
char_count: 32672
 
-----------end
 
-------------  trun.sh
#!/bin/bash
#
#
 
echo "starting test"
 
let good=0;
let bad=0;
 
let i=0;
 
while true; do
        let i=$i+1
        if ./mytest.sh; then
                let good=$good+1
        else
                let bad=$bad+1
        fi
        if [ "$i" -eq 100 ]; then
                echo "SUCCESSFUL: $good" >> ./result.txt
                echo "FAIL CALLS: $bad"  >> ./result.txt
                let good=0;
                let bad=0;
                let i=0;
#               exit 0;
        fi
done
--------------- end
 
 

reply via email to

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