bug-bash
[Top][All Lists]
Advanced

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

Re: bash 3.2.39 -- race condition


From: Douglas Moyes
Subject: Re: bash 3.2.39 -- race condition
Date: Sun, 29 Nov 2009 11:10:06 -0800
User-agent: Thunderbird 2.0.0.23 (X11/20090817)

Chet Ramey wrote:
Douglas Moyes wrote:
I nearly brought down a server today.

# alias d="perl-script "
....

# d() {
# perl-script $1 |grep something|cut -d ' ' -f 3
# }
# d something
..... ..... .... CRASH

turns out bash went into a loop calling d over and over again, which
resulted in thousands of grep, bash, and -d processes being executed. It
wasn't pretty.

You defined `perl-script' as a recursive function (alias expansion is
performed when a function is defined) and called it.  I'm not surprised
at the result.

Chet


So... what you're saying is that this:

# alias d="dh-machine "
# d() {
# dh-machine $1 |grep something|cut -d ' ' -f 3
# }

became this:

# alias d="dh-machine "
# dh-machine() {
# dh-machine $1 |grep something|cut -d ' ' -f 3
# }

And bash didn't treat d() as a a unique identifier because it tokenized d and (), then expanded 'd' as an alias. Okay, I see how that makes the interpreter simpler, but it's not that intuitive and most likely would always be an undesired effect. It would be more intuitive if "xxxx() {" ignored any previous definition of xxxx.




reply via email to

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