XEmacs 21.2-b1
[chise/xemacs-chise.git.1] / tests / reproduce-bugs.el
1 ;;; reproduce-bugs.el --- reproduce bugs in XEmacs;
2
3 ;; Copyright (C) 1997  Free Software Foundation, Inc.
4 ;; Copyright (C) 1997  Sun Microsystems, Inc.
5
6 ;; Keywords: bugs, crash, burn, die, croak, munge
7
8 ;; This file is part of XEmacs.
9
10 ;; This file is free software; you can redistribute it and/or modify it
11 ;; under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
14
15 ;; XEmacs is distributed in the hope that it will be useful, but
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 ;; General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with XEmacs; see the file COPYING.  If not, write to the Free
22 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23 ;; 02111-1307, USA.
24
25 ;;; Synched up with: Not in FSF.
26
27 ;;; Commentary:
28
29 ;; Reproduce XEmacs bugs, so that they can get fixed.
30 ;; Especially, make XEmacs crash.
31 ;; You may need to use a debug version of XEmacs to reproduce some of these.
32
33 ;; Several global keybindings are created, each of which exhibits a bug.
34
35 ;; For XEmacs maintainers and other masochists.
36
37 ;; It's a bad idea to rely on code in this file continuing to work in
38 ;; the same way. :-)
39
40 ;;; Code:
41
42 (defvar bug-hashtable (make-hashtable 10))
43
44 (defmacro defbug (bug-number &rest body)
45   `(puthash ,bug-number (lambda () ,@body) bug-hashtable))
46
47 (put 'defbug 'lisp-indent-function 'defun)
48
49 (defconst bug-buffer
50   (save-excursion
51     (set-buffer (get-buffer-create "*Bug*"))
52     (erase-buffer)
53     (current-buffer)))
54
55 ;;;####autoload
56 (defun reproduce-bug (number)
57   "Reproduce XEmacs bugs, so that they can get fixed.
58 Especially, make XEmacs crash.
59 See reproduce-bugs.el for bug descriptions and bug numbers.
60 A debug version of XEmacs may be needed to reproduce some bugs."
61   (interactive "nBug Number: ")
62   (funcall (gethash number bug-hashtable)))
63
64 ;;; Change this to your preferred key-binding
65
66 (global-set-key  [(control ?Z)] 'reproduce-bug)
67
68 ;;;; Bugs follow:
69
70 ;;; ------------------------------------------------------------------
71 ;;; Crash on trace-function
72 ;;; Fatal error: assertion failed, file src/eval.c, line 1405, abort()
73 (defbug 1
74   (trace-function 'record-buffer bug-buffer)
75   (pop-to-buffer bug-buffer))
76
77
78 ;;; ------------------------------------------------------------------
79 ;;; Crashes with stack overflow
80 ;;; Should give error via barf-if-buffer-read-only
81 ;;; Fatal error: assertion failed, file src/eval.c, line 1874, abort()
82 ;; This bug has been fixed. -sb
83 (defbug 2
84   (switch-to-buffer bug-buffer)
85   ;; The following line should contain a number of eight-bit characters
86   (insert "²èÌÌËè¤Î°ÜÆ°¤Ï¤Ç¤­¤ë¤è¤¦¤Ë¤Ê¤ê¤Þ¤·¤¿¡£º£Å٤ϡ¢²èÌ̤ÎÃæ¤Ç¡¢ÆÃÄê¤Î¾ì")
87   (setq buffer-read-only t)
88   (ignore-errors
89     (encode-coding-region (point-min) (point-max) 'euc-japan))
90   (garbage-collect))
91
92
93 ;;; ------------------------------------------------------------------
94 ;;; Crashes in debug version only
95 ;;; Fatal error: assertion failed, file src/objects.h, line 149,
96 ;;; RECORD_TYPEP (_obj, lrecord_font_instance) || MARKED_RECORD_P (_obj)
97 (defbug 3
98   (let (glyph ext)
99     (make-face 'adobe-symbol-face)
100     (set-face-font
101      'adobe-symbol-face
102      "-adobe-symbol-medium-r-normal--*-140-*-*-p-*-adobe-fontspecific")
103     (setq glyph (make-glyph (list (vector 'string
104                                           :data (char-to-string ?\xD3)))))
105     (set-glyph-face glyph 'adobe-symbol-face)
106     (setq ext (make-extent 14 18))
107     (set-extent-property ext 'begin-glyph glyph)))
108
109
110 ;;; ------------------------------------------------------------------
111 ;;; (maybe?) crash koi8
112 ;;; ACCL: Invalid command (c)
113 ;;; With debugging on, crashes as follows:
114 ;;; Fatal error: assertion failed, file src/lisp.h, line 1227, INTP (obj)
115 (defbug 5
116   ;;(load "cyrillic")
117   ;;(load "cyrillic-hooks")
118   (princ (decode-coding-string "\xe1" 'koi8)))
119
120
121 ;;; ------------------------------------------------------------------
122 ;;; Completely Uninterruptible hang in re-search-backward (Was: java-mode)
123 (defbug 6
124   (switch-to-buffer bug-buffer)
125   (insert "{
126 public static void main(String[] args) throws java.io.IOException
127     {
128     }
129 }
130 ")
131   (goto-char (point-min))
132   (search-forward "{" nil nil 2)
133   (backward-char)
134   (re-search-backward
135    "^\\s(\\|\\(^[ \t]*\\(\\(\\(public\\|protected\\|static\\)\\s-+\\)*\\(\\(\\([[a-zA-Z][][_$.a-zA-Z0-9]*[][_$.a-zA-Z0-9]+\\|[[a-zA-Z]\\)\\s-*\\)\\s-+\\)\\)?\\(\\([[a-zA-Z][][_$.a-zA-Z0-9]*\\s-+\\)\\s-*\\)?\\([_a-zA-Z][^][ \t:;.,{}()\7f=]*\\|\\([_$a-zA-Z][_$.a-zA-Z0-9]*\\)\\)\\s-*\\(([^);{}]*)\\)?\\([] \t]*\\)\\(\\s-*\\<throws\\>\\s-*\\(\\([_$a-zA-Z][_$.a-zA-Z0-9]*\\)[, \t\n\r\f]*\\)+\\)?\\s-*\\)\\s("))
136
137
138 ;;; ------------------------------------------------------------------
139 ;;; regexp crash
140 ;; This doesn't crash for me. -sb
141 (defbug 7
142   (string-match "\\(\\s-\\|$\\)" "å"))
143
144   
145 ;;;; -------------------------------------------------------------------
146 ;;;; Bugs below this line have been fixed.
147 ;;;; Keep these for regression testing
148 ;;;; -------------------------------------------------------------------
149
150
151 ;;; ------------------------------------------------------------------
152 ;;; Infinite recursion crash - Segmentation Fault
153 (defbug 4
154   (switch-to-buffer bug-buffer)
155   (insert "abcdefg")
156   (setq e (make-extent 1 4))
157   (set-extent-property e 'face 'bold)
158   (set-extent-property e 'duplicable t)
159   (set-extent-property e 'replicating t)
160   (insert (buffer-string))
161   (delete-region 8 9))
162
163 (defbug 5
164   (interactive)
165   (with-temp-buffer
166     (insert "abc")
167     (forward-char -1)
168     (subst-char-in-region 1 4 ?b ?\344)
169     (if (not (= (point) 3))
170         (message "Bug!  point should equal 3 but is %d" (point)))))
171
172 ;;; crash popup frames FIXED
173 ;;(global-set-key
174 ;; [(alt meta control f12)]
175 ;; (lambda ()
176 ;;   (interactive)
177 ;;   (let ((f (selected-frame)))
178 ;;     (make-frame `(popup ,(selected-frame)))
179 ;;     (make-frame)
180 ;;     (sit-for 0)
181 ;;     (delete-frame f)
182 ;;     (save-buffers-kill-emacs))))
183
184 ;;; crash on delete-frame-hook - FIXED!
185 ;;(global-set-key
186 ;; [(alt meta control f10)]
187 ;; (lambda ()
188 ;;   (interactive)
189 ;;   (setq delete-frame-hook
190 ;;         (lambda (frame)
191 ;;           (select-frame frame)
192 ;;         (kill-buffer (window-buffer (frame-selected-window frame)))))))
193
194 ;;; reproduce-bugs.el ends here