test-fast-slot-ref.in 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/bin/sh
  2. # Copyright (C) 2006 Free Software Foundation, Inc.
  3. #
  4. # This library is free software; you can redistribute it and/or modify it
  5. # under the terms of the GNU Lesser General Public License as published by
  6. # the Free Software Foundation; either version 2.1 of the License, or (at
  7. # your option) any later version.
  8. #
  9. # This library is distributed in the hope that it will be useful, but
  10. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  11. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
  12. # License for more details.
  13. #
  14. # You should have received a copy of the GNU Lesser General Public License
  15. # along with this library; if not, write to the Free Software Foundation,
  16. # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. # Test for %fast-slot-ref, which was previously implemented such that
  18. # an out-of-range slot index could escape being properly detected, and
  19. # could then cause a segmentation fault.
  20. #
  21. # Prior to the change in this commit to goops.c, the following
  22. # sequence reliably causes a segmentation fault on my GNU/Linux when
  23. # executing the (%fast-slot-ref i 3) line. For reasons as yet
  24. # unknown, it does not cause a segmentation fault if the same code is
  25. # loaded as a script; that is why we run it here using "guile -q <<EOF".
  26. exec guile -q -l @top_builddir_absolute@/libguile/stack-limit-calibration.scm >/dev/null 2>&1 <<EOF
  27. (use-modules (oop goops))
  28. (define-module (oop goops))
  29. (define-class <c> () (a #:init-value 1) (b #:init-value 2) (c #:init-value 3))
  30. (define i (make <c>))
  31. (%fast-slot-ref i 1)
  32. (%fast-slot-ref i 0)
  33. (%fast-slot-ref i 3)
  34. (%fast-slot-ref i -1)
  35. (%fast-slot-ref i 2)
  36. (exit 0)
  37. EOF