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