summaryrefslogtreecommitdiff
path: root/test-suite
diff options
context:
space:
mode:
authorNeil Jerram <neil@ossau.uklinux.net>2009-01-04 21:32:23 +0000
committerNeil Jerram <neil@ossau.uklinux.net>2009-01-04 22:46:47 +0000
commita9931e4e1ab80e6b47d6d836edf834f530bd9522 (patch)
tree071b6725354a340680267644936503743e2fa3c0 /test-suite
parent53e4bd36f3c8fc756fc091891b79e6aa16820256 (diff)
downloadguile-a9931e4e1ab80e6b47d6d836edf834f530bd9522.tar.gz
Fix implementation of %fast-slot-ref and %fast-slot-set!
* libguile/goops.c (scm_sys_fast_slot_ref, scm_sys_fast_slot_set_x): Correct incantation for getting the number of slots of the specified instance. * libguile/goops.h (SCM_NUMBER_OF_SLOTS): Removed (because wrong). * test-suite/standalone/test-fast-slot-ref.in: New standalone test. * configure.in: Generate test-suite/standalone/test-fast-slot-ref. * test-suite/standalone/Makefile.am (check_SCRIPTS): Add test-fast-slot-ref.
Diffstat (limited to 'test-suite')
-rw-r--r--test-suite/standalone/.gitignore1
-rw-r--r--test-suite/standalone/Makefile.am4
-rw-r--r--test-suite/standalone/test-fast-slot-ref.in39
3 files changed, 44 insertions, 0 deletions
diff --git a/test-suite/standalone/.gitignore b/test-suite/standalone/.gitignore
index b1f40882e..df1ad7028 100644
--- a/test-suite/standalone/.gitignore
+++ b/test-suite/standalone/.gitignore
@@ -8,3 +8,4 @@
/test-use-srfi
/test-scm-with-guile
/test-scm-c-read
+/test-fast-slot-ref
diff --git a/test-suite/standalone/Makefile.am b/test-suite/standalone/Makefile.am
index 3afd7e586..cc8b58871 100644
--- a/test-suite/standalone/Makefile.am
+++ b/test-suite/standalone/Makefile.am
@@ -103,6 +103,10 @@ test_conversion_LDADD = ${top_builddir}/libguile/libguile.la
check_PROGRAMS += test-conversion
TESTS += test-conversion
+# test-fast-slot-ref
+check_SCRIPTS += test-fast-slot-ref
+TESTS += test-fast-slot-ref
+
# test-use-srfi
check_SCRIPTS += test-use-srfi
TESTS += test-use-srfi
diff --git a/test-suite/standalone/test-fast-slot-ref.in b/test-suite/standalone/test-fast-slot-ref.in
new file mode 100644
index 000000000..5bd063876
--- /dev/null
+++ b/test-suite/standalone/test-fast-slot-ref.in
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+# Copyright (C) 2006 Free Software Foundation, Inc.
+#
+# This library is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 of the License, or (at
+# your option) any later version.
+#
+# This library is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+# License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+# Test for %fast-slot-ref, which was previously implemented such that
+# an out-of-range slot index could escape being properly detected, and
+# could then cause a segmentation fault.
+#
+# Prior to the change in this commit to goops.c, the following
+# sequence reliably causes a segmentation fault on my GNU/Linux when
+# executing the (%fast-slot-ref i 3) line. For reasons as yet
+# unknown, it does not cause a segmentation fault if the same code is
+# loaded as a script; that is why we run it here using "guile -q <<EOF".
+exec guile -q -l @top_builddir_absolute@/libguile/stack-limit-calibration.scm >/dev/null 2>&1 <<EOF
+(use-modules (oop goops))
+(define-module (oop goops))
+(define-class <c> () (a #:init-value 1) (b #:init-value 2) (c #:init-value 3))
+(define i (make <c>))
+(%fast-slot-ref i 1)
+(%fast-slot-ref i 0)
+(%fast-slot-ref i 3)
+(%fast-slot-ref i -1)
+(%fast-slot-ref i 2)
+(exit 0)
+EOF