Fix crash running two consecutive examine commands.
authorJohn Darrington <john@darrington.wattle.id.au>
Sun, 29 Mar 2009 04:05:09 +0000 (12:05 +0800)
committerJohn Darrington <john@darrington.wattle.id.au>
Sun, 29 Mar 2009 04:05:09 +0000 (12:05 +0800)
Re-initialise list in the dynamically instead of
relying on the static initialiser.  Fixes bug #25903

src/language/stats/examine.q
tests/automake.mk
tests/bugs/examine-crash2.sh [new file with mode: 0755]

index 78ea0e63c0b1989f3f35a0a1e1105e5bb269f76d..2649968b31485b105f6a80f3119ab39bdc851eea 100644 (file)
@@ -198,7 +198,7 @@ factor_destroy (struct xfactor *fctr)
 }
 
 static struct xfactor level0_factor;
-static struct ll_list factor_list = LL_INITIALIZER (factor_list);
+static struct ll_list factor_list;
 
 /* Parse the clause specifying the factors */
 static int examine_parse_independent_vars (struct lexer *lexer,
@@ -268,6 +268,8 @@ cmd_examine (struct lexer *lexer, struct dataset *ds)
   subc_list_double_create (&percentile_list);
   percentile_algorithm = PC_HAVERAGE;
 
+  ll_init (&factor_list);
+
   if ( !parse_examine (lexer, ds, &cmd, NULL) )
     {
       subc_list_double_destroy (&percentile_list);
index f1bb6306b3092bc5bce05b7198a3bccebad74da4..5c84354f1b4dbc5185f27fba40c8a455f06a2adf 100644 (file)
@@ -116,6 +116,7 @@ dist_TESTS = \
        tests/bugs/empty-do-repeat.sh \
        tests/bugs/get.sh \
        tests/bugs/examine-crash.sh \
+       tests/bugs/examine-crash2.sh \
        tests/bugs/examine-1sample.sh \
        tests/bugs/examine-missing.sh \
        tests/bugs/examine-missing2.sh \
diff --git a/tests/bugs/examine-crash2.sh b/tests/bugs/examine-crash2.sh
new file mode 100755 (executable)
index 0000000..01fe8f9
--- /dev/null
@@ -0,0 +1,81 @@
+#!/bin/sh
+
+# This program tests for a bug which crashed pspp
+# when two consecutive EXAMINE commands are run.
+
+TEMPDIR=/tmp/pspp-tst-$$
+TESTFILE=$TEMPDIR/`basename $0`.sps
+
+# ensure that top_srcdir and top_builddir  are absolute
+if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
+if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
+top_srcdir=`cd $top_srcdir; pwd`
+top_builddir=`cd $top_builddir; pwd`
+
+PSPP=$top_builddir/src/ui/terminal/pspp
+
+STAT_CONFIG_PATH=$top_srcdir/config
+export STAT_CONFIG_PATH
+
+LANG=C
+export LANG
+
+
+cleanup()
+{
+     if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
+       echo "NOT cleaning $TEMPDIR"
+       return ; 
+     fi
+     rm -rf $TEMPDIR
+}
+
+
+fail()
+{
+    echo $activity
+    echo FAILED
+    cleanup;
+    exit 1;
+}
+
+
+no_result()
+{
+    echo $activity
+    echo NO RESULT;
+    cleanup;
+    exit 2;
+}
+
+pass()
+{
+    cleanup;
+    exit 0;
+}
+
+mkdir -p $TEMPDIR
+
+cd $TEMPDIR
+
+cat <<EOF > $TESTFILE
+data list list /y * z *.
+begin data.
+6 4
+5 3
+7 6
+end data.
+
+EXAMINE /VARIABLES= z BY y.
+
+EXAMINE /VARIABLES= z. 
+EOF
+if [ $? -ne 0 ] ; then no_result ; fi
+
+
+activity="run program"
+$SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE
+if [ $? -ne 0 ] ; then fail ; fi
+
+
+pass;