Skip to Content.
Sympa Menu

sm-sorcery-bugs - [SM-Sorcery-Bugs] [Bug 6957] Loop in depends on a cast.

sm-sorcery-bugs AT lists.ibiblio.org

Subject: Bugs for Sorcery are reported here

List archive

Chronological Thread  
  • From: bugzilla-daemon AT metalab.unc.edu
  • To: sm-sorcery-bugs AT lists.ibiblio.org
  • Subject: [SM-Sorcery-Bugs] [Bug 6957] Loop in depends on a cast.
  • Date: Mon, 7 Jun 2004 11:17:17 -0400

http://bugs.sourcemage.org/show_bug.cgi?id=6957

acedit AT armory.com changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |video AT sourcemage.org
Component|Cast |subroutines



------- Additional Comments From acedit AT armory.com 2004-06-07 11:17 -------
Ouch, this was painful to figure out. The short answer is, the depends
resolution function uses a loop variable of 'i', however so does the
MPlayer-codecs PREPARE file.

In libdepends we have this:
local i
<stuff>
for (( i=0 ; i<${#SPELLS[*]} ; i++ )) ; do
<stuff>
done

and in MPlayer-codecs/PREPARE we have this:
<start>
use_codec() {
if query "Install $1 codecs?" y
then
echo SOURCE${i/1/}=$2.tar.bz2 >> $SPELL_CONFIG
echo
SOURCE${i/1/}_URL[0]=http://www.mplayerhq.hu/MPlayer/releases/codecs/\$SOURCE${i/1/}
>> $SPELL_CONFIG
echo MD5[$[$i-1]]=$3 >> $SPELL_CONFIG
let i++
fi
}

SPELL=MPlayer-codecs
. $SCRIPT_DIRECTORY/codecs

if ! grep -q "SOURCE=" $SPELL_CONFIG; then
i=1
for (( c=0; c < $num_codecs; c++ )); do
use_codec ${codecs[$c]}
done
fi

. $SPELL_CONFIG
<end>

My knowledge of variable declarations in bash is limited, but 'local'
variables are still accessable down the stack, and if they're modified
in the same shell (not a subshell) their values are passed back up to
where they were declared.

So the 'i' in libdepends ended up being availible to PREPARE, which didn't
localize it, and stomped on sorcery's value of i.

I dont think bash has the concept of a 'my' variable like in perl,
which exists only in the function it was declared in, not further
down the stack like local variables, so doing that is right out.

We also can't very easily run PREPARE/CONFIGURE/DEPENDS in a subshell
because they end up calling back to sorcery code (depends/optional_depends)
which sets certain variables that libdepends needs to look at later. So
we can be more defensive in sorcery and a declare all our variables with
obscure names, or have spell writers localize their variables.

Im surprised this hasn't happened before.



------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.




Archive powered by MHonArc 2.6.24.

Top of Page