test-fast-slot-ref.in 1.6 KB

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