Dear list,

I get a segfault when selecting view->ps after loading my LyX 1.1.x
document.

After a little editing the same document won't export, generating tons
of LaTeX errors.

Attached is the trace generated with lyxdbg-0.3d which I've also
attached since I'm not active enough to be responsible for maintaining
it. I'd love to see it in the CVS, especially if we plan on segfaulting
often ;) But I'm not active enough to keep it on my machine where it
can't be used.

Darren

#!/bin/sh
#
# This file is copyright 2002 Darren Freeman and Rob Lahaye.
# It is covered by the GNU General Public License which was supplied with LyX.
# 0.1  - 2002/11/28 Initial version by Darren Freeman
# 0.2  - 2002/11/29 Greatly improved by Rob Lahaye
# 0.2b - 2002/11/30 Revisited by Darren Freeman
# 0.3  - 2002/12/01 More commands to gdbcmd, made LyX async for faster loading, added trace gzipping. By Darren Freeman
# 0.3b - 2002/12/01 Prettifying by Rob Lahaye.
# 0.3c - 2002/12/07 Minor fixes and more messages by Darren Freeman.
# 0.3d - 2002/12/08 Repair work and extra checking by Darren Freeman.

version="LyX automatic testing assistant v0.3d"
echo "$version"

# Define file names for output.
gdbcmd="lyx-gdb-cmd"
trace="lyx-trace"
lyxout="lyx-stdout"
lyxerr="lyx-stderr"

# Number of stack frames to investigate further.
listframes=16

# Verify the existence of GDB. Without that, we're toast.
if ( test -z `which gdb 2>/dev/null` )
then
	echo
	echo "Sorry, GDB (the GNU Debugger) was not found in your path."
	echo "You will need to install or fix it before this script can run."
	exit
fi

# Start the trace file with the version string.
echo "$version" >$trace

# Find the LyX executable - it is either the first argument if it's an executable file,
# or we search in order through some possibilities, finishing up with asking which
# to find LyX in the executable path.
if ( test -x "$1" -a ! -d "$1" )
then
	lyx=$1
	shift
else
	for i in `dirname $0`/src/lyx `dirname $0`/lyx ./src/lyx ./lyx `which lyx 2>/dev/null`
	do
		if ( test -x "$i" -a ! -d "$i" )
		then
			lyx=$i
			break
		fi
	done
fi

if ( test -z "$lyx" )
then
	echo "Cannot find the LyX executable."
	echo "Either supply the full path of the LyX executable as the"
	echo "first argument, copy this script into the LyX build"
	echo "directory, 'cd' into there, or add LyX to your path."
	exit
fi

# Dump compiled-in LyX version information to the trace.
echo "----------*-version--*----------" >>$trace
$lyx --version >> $trace 2>&1

# Check next argument for coredump file.
[ -n "`file -i $1 2> /dev/null | grep coredump`" ] && { coredump=$1; shift; }

# Create stdin for GDB. It starts as an empty file.
echo -n > $gdbcmd

# GDB needs to wait for LyX as we will spawn it below.
[ -z "$coredump" ] && echo "finish" >> $gdbcmd

# First grab a backtrace if LyX had problems. Include local variables.
echo "bt"          >> $gdbcmd
echo "info locals" >> $gdbcmd

# Rise through the stack dumping local variables.
while (( --listframes > 0 ))
do
	echo "up"          >> $gdbcmd
	echo "info locals" >> $gdbcmd
done

# Allow LyX to continue with an emergency save in case of crash.
[ -z "$coredump" ] && echo "continue" >> $gdbcmd

# Append the GDB commands to the trace.
echo "----------*-commands-*----------" >> $trace
cat "$gdbcmd" >> $trace

echo "----------*---gdb----*----------" >> $trace

if ( test -z "$coredump" )
then
	# Spawn LyX in the background and save its PID.
        echo "Starting $lyx ..."
	$lyx $@ > $lyxout 2> $lyxerr &
	lyxpid=$!
	echo "Attaching the debugger..."
else
	echo "Executing the debugger on core file $coredump ..."
fi

# Start GDB; either attach to running LyX PID or read the core dump. 
gdb < $gdbcmd >> $trace 2>&1 $lyx $lyxpid$coredump
echo >> $trace

# If we started LyX ourselves we can append the output of LyX.
if ( test -z "$coredump" )
then
	# Append the stdout and stderr from LyX.
	echo "----------*--stdout--*----------" >> $trace
	cat $lyxout >> $trace
	echo "----------*--stderr--*----------" >> $trace
	cat $lyxerr >> $trace
fi
	
# Compress without removing original.
gzip -c $trace > ${trace}.gz

echo
echo "The file $trace contains everything GDB and LyX have said"
echo "plus other useful information intended for the developers."
echo "${trace}.gz is the compressed version for emailing."

# Extra messages when interesting things are in the trace files.
# Add more interesting things below!
#	echo "desired line length of messages below---------------------60"

email=""

if ( grep "SIGSEGV" $trace &>/dev/null )
then
	echo
	echo "Whoa! It appears that a segmentation fault occurred. This is"
	echo "probably a very serious fault in LyX that may be hard for"
	echo "the developers to find without your help."
	email=true
fi

if ( grep "Phew." $lyxerr &>/dev/null )
then
	echo
	echo "It appears that LyX performed a successful autosave. LyX"
	echo "should remind you about this recovery file the next time"
	echo "you open the document(s). Most of the time you will not"
	echo "lose your work even if you haven't saved it for a while."
fi

if ( ! test -z "$email" )
then
	echo
	echo "Please email the compressed trace file to the LyX team at"
	echo "[EMAIL PROTECTED] (LyX Developers List)"
	echo "Don't forget to mention what you were doing before the"
	echo "error, and remember that:"
	echo
	echo "--- THIS SCRIPT REPLACES OLD TRACE FILES AUTOMATICALLY ---"
fi

# Clean up files.
rm -f $gdbcmd $lyxout $lyxerr

Attachment: lyx-trace.gz
Description: GNU Zip compressed data

Reply via email to