_cygtls::handle_exceptions and segmentation fault while running bash script

pw p.willis@telus.net
Wed Dec 19 19:40:00 GMT 2007


Hello,

I am running a bash script used for processing some text files.
The script works fine for a few files and then _cygtls will throw
and exception, there will be a segfault and a core gets dumped.

If I restart the  bash script on the file where it last left off
the script will continue for a few more files and then the same thing 
will happen.

The script itself is nothing more than a couple of nested 'for' loops
reading lines of text from delimited files and calculating some values
and then writing the same line, with additional columns, into an output
file.

There are 26 input files in total, each with 992 delimited lines.
The files are delimited using '|' (pipe) character and usually have
16 numeric columns. The first line of each file is a header line
with the names of the columns. These files would be easy to 'mock up'.

ie:
name_1|name_2|<....>name_n <newline>
1234|4567|<....>9876 <newline>
.
.
.
etc

An input file mock up script is as follows (tested/works):

#!/bin/bash
#mockup_input_files.sh

mkdir final
mkdir sunshine

for FNUM in `seq 1 26`;do
	OFILE=`echo $FNUM| awk '{print "./final/test_file_" $1 ".final.txt"}'`;
	echo "HEADER|HEADER|HEADER|HEADER|HEADER|HEADER|HEADER|HEADER|HEADER" > 
$OFILE

	for L in `seq 1 992`; do
		LINE=`echo 9|awk '{for(i=1;i<=$1;i++){printf("%d000", 
i);if(i<9){printf("|");}} printf("\n");}'`;
		echo "$LINE" >> $OFILE;
	done
done

  find -type f -iname '*.final.txt' | awk -F "/" '{print $NF 
"|73.056977|6986" }'>latitudes.txt

#END OF SCRIPT



The error I get when running the script looks like this:

       4 [main] sh 3164 _cygtls::handle_exceptions: Error while dumping 
state (probably corrupted stack)
Segmentation fault (core dumped)


The bash problematic script is as follows:

#!/bin/bash
#make_sunshine.sh
#my apologies about line wrapping
#email doesn't lend itself to long linear bash/awk scripts

IFS=$'\n'

for FILE in `find -type f -iname '*.final.txt'`; do
	OFILE=`echo $FILE | sed -e "s/final/sunshine/g"`;
	#get the short name of the file
	NAME=`echo $FILE|awk -F "/" '{print $NF}'`;

#latitudes.txt format is pipe delimited with 3 columns
#first column is the name of the file without path
#matching one of the '*.final.txt' file names read by the first for loop
#second column is a numeric value used for calculation
#third column is a numeric value used for calculation

	for LINE in `cat latitudes.txt`;do
		CNAME=`echo $LINE| awk -F "|" '{print $1}'`;
		LAT=`echo $LINE| awk -F "|" '{print $2}'`;
		WATER_PIXELS=`echo $LINE| awk -F "|" '{print $3}'`;
		if [ "$CNAME" == "$NAME" ]; then
			break;
		fi
	done

	LCOUNT=0;
	for LINE in `cat $FILE|sed -e "s/^M//g"`;do
		if [ "$LCOUNT" != "0" ]; then
			JDAY=`echo $LINE| awk -F "|" '{print $3}'`;
			VALID=`echo $LINE| awk -F "|" '{print $6}'`;
			COVERAGE_PCT=`echo "$VALID|$WATER_PIXELS" | awk -F "|" '{print $1/$2}'`;
			SUNSHINE=`echo "$COVERAGE_PCT|$JDAY|$LAT" | awk -F "|" 
'{PI=3.141592653589;JULIAN_ANGLE=((($2/365.25)-0.5)*360.0)+90.0;JULIAN_SIN=sin((JULIAN_ANGLE/360.0)*(2.0*PI));ATF=JULIAN_SIN*23.4;CAL=cos((($3-ATF)/360.0)*(2.0*PI));print 
CAL*$1}'`;
			echo "$LINE|$LAT|$SUNSHINE|$COVERAGE_PCT|$WATER_PIXELS" | sed -e 
"s/|-0|/|0|/g" >> $OFILE;
		else
			echo "$LINE|AVERAGE_LATITUDE|SUNSHINE|COVERAGE_PCT|WATER_PIXELS">$OFILE;
		fi
		LCOUNT=1;
	done
	unix2dos $OFILE;
done
#END OF SCRIPT

Thanks for any help regarding this issue.

Peter

PS. Attached is the cygcheck output file 'cygcheck.out'

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cygcheck.out
URL: <http://cygwin.com/pipermail/cygwin/attachments/20071219/fea1bfd7/attachment.ksh>
-------------- next part --------------
--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


More information about the Cygwin mailing list