hdiutil imageinfo problem with softlinks

Originator:kuehn.karl
Number:rdar://8111753 Date Originated:6/20/2010
Status:Open Resolved:
Product:MacOS X Product Version:10.6.4/10F569
Classification: Reproducible:Sometimes
 
20-Jun-2010 01:56 PM Karl Kuehn:
Summary:

	When using hdiutil with the "imageinfo" command 

Steps to Reproduce:

	Run the attached script. It creates a trivial compressed dmg, then tries "hdiutil imageinfo" on it both with an absolute path, and a symlinked path, each 1000 times, then reports how many failures it encountered with each.

Expected Results:

	I would expect this to succeed 100% of the time with either form of path.

Actual Results:

	The absolute path always succeeds on all machines, but the symlinked one fails. I am seeing different failure rates:

iMac5,1
	10.6.4/10F569 (clean, just installed): about .5% failure rate
	10.5.8/ (clean, just installed): never seems to display the problem

iMac8,1
	10.6.4/10F569 (dirty, development machine): between 15 and 25% failure rate.

Regression:
	Unknown

Notes:
	While there is a strait-forward work-around for this issue, it is a nasty trap for people to fall into since their machine might exhibit the problem less the 1% of the time. My guess is that this is a race condition, but that is a thin guess.


============== Test script ==============
#!/bin/bash

# create a temproary folder with three items in it
TEMP_FOLDER=`/usr/bin/mktemp -d /tmp/hdiutilBugTest.XXXX`
/usr/bin/touch "$TEMP_FOLDER/a"
/usr/bin/touch "$TEMP_FOLDER/b"
/usr/bin/touch "$TEMP_FOLDER/c"

# create a compressed image from the temp folder
/usr/bin/hdiutil create -srcfolder "$TEMP_FOLDER" "$TEMP_FOLDER/testImage.dmg" 1>/dev/null

# create the symlink to the image
/bin/ln -s "testImage.dmg" "$TEMP_FOLDER/symlink"

SYMLINK_PATH="$TEMP_FOLDER/symlink"
ABSOLUTE_PATH="$TEMP_FOLDER/testImage.dmg"

PATHS[0]="$SYMLINK_PATH"
PATHS[1]="$ABSOLUTE_PATH"

REPEAT_COUNT=1000
IFS=$'\n'
for THIS_PATH in ${PATHS[@]}; do
	echo "Working on: $THIS_PATH"
	FAILED_COUNT=0
	i=0
	while [ $i -lt $REPEAT_COUNT ]; do
		/usr/bin/hdiutil imageinfo "$THIS_PATH" 1>/dev/null 2>/dev/null
		if [ $? -ne 0 ]; then
			let FAILED_COUNT=FAILED_COUNT+1
		else
			let SUCEEDED_COUNT=SUCEEDED_COUNT+1
		fi
		let i=i+1
	done
	echo "	Failed $FAILED_COUNT out of $REPEAT_COUNT times"
done

# delete the temp folder
if [ ! -z "$TEMP_FOLDER" ] && [ -d "$TEMP_FOLDER" ]; then
	/bin/rm -rf "$TEMP_FOLDER"
fi

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!