emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: segmentation fault using organizer-mode.el


From: Antonio Carzaniga
Subject: Re: segmentation fault using organizer-mode.el
Date: Tue, 29 Jul 2003 13:38:11 -0600

 |       0. run emacs with --no-site-file --no-init-file
 | 
 |       1. M-x load-file RET organizer-mode.el
 | 
 |       2. M-x organizer-show RET ~/Organizer/cbn
 | 
 | Can you possibly send in a self-contained test case, using code from
 | whichever files you need?

okay.  The attached file (X.el) is my attempt at that.  I tried to
boil it down as much as possible.  This test does not require other
files, but it does create a file called "XXX" (which you can obviously
remove after running the test).  I execute this test with:

   emacs with --no-site-file --no-init-file -l X.el

 |     Program received signal SIGSEGV, Segmentation fault.
 |     0x081322fe in re_compile_pattern ()
 |     (gdb) where
 |     #0  0x081322fe in re_compile_pattern ()
 |     #1  0x08139fc9 in error ()
 | 
 | It seems to me that the function names in your backtrace are
 | not right.  Did you compile without -g?  If so, how about
 | recompiling with -g so you can get a meaningful backtrace?

I was using a binary distribution from RedHat, and I thought I could
get a meaningful stack trace from that.  This is what I get from a
version that I just compiled (with -g):

Program received signal SIGSEGV, Segmentation fault.
save_restriction_restore (data=1480501668)
    at /local/home/carzanig/core/emacs-21.3/src/editfns.c:2872
2872          if (beg->charpos != BUF_BEGV(buf) || end->charpos != BUF_ZV(buf))
(gdb) where
#0  save_restriction_restore (data=1480501668)
    at /local/home/carzanig/core/emacs-21.3/src/editfns.c:2872
#1  0x081233f8 in unbind_to (count=2, value=405199556)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:3014
#2  0x08120abf in unwind_to_catch (catch=0xbffff420, value=138324388)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:1072
#3  0x08121241 in Fsignal (error_symbol=405295924, data=405199556)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:1463
#4  0x081229ea in Ffuncall (nargs=3, args=0xbfffdff4)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:2659
#5  0x08149bb4 in Fbyte_code (bytestr=941496636, vector=2, 
    maxdepth=-1073750032)
    at /local/home/carzanig/core/emacs-21.3/src/bytecode.c:716
#6  0x08122d09 in funcall_lambda (fun=1209932060, nargs=0, 
    arg_vector=0xbfffe0a0)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:2851
#7  0x08122baa in apply_lambda (fun=1209932060, args=405199556, eval_flag=1)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:2770
#8  0x08121e98 in Feval (form=1209932060)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:2071
#9  0x0811fee1 in Fsetq (args=138324388)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:531
#10 0x08122140 in Feval (form=1209525052)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:1960
#11 0x0811fc70 in Fif (args=1480490540)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:364
#12 0x08122140 in Feval (form=1209524932)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:1960
#13 0x0811fdad in Fprogn (args=405199604)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:431
#14 0x08122d48 in funcall_lambda (fun=138314516, nargs=0, 
    arg_vector=0xbfffe420)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:2844
#15 0x08122baa in apply_lambda (fun=1480491796, args=405199556, eval_flag=1)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:2770
#16 0x08121e98 in Feval (form=1480491796)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:2071
#17 0x0811fdad in Fprogn (args=1480488772)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:431
#18 0x0812073f in Flet (args=1480488796)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:875
#19 0x08122140 in Feval (form=1209525292)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:1960
#20 0x0811fdad in Fprogn (args=405199556)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:431
#21 0x08122d48 in funcall_lambda (fun=138312108, nargs=0, 
    arg_vector=0xbfffe730)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:2844
#22 0x08122baa in apply_lambda (fun=1480489388, args=405199556, eval_flag=1)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:2770
#23 0x08121e98 in Feval (form=1480489388)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:2071
#24 0x0811fdad in Fprogn (args=1480501756)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:431
#25 0x0811c2b6 in Fsave_restriction (body=1480501756)
    at /local/home/carzanig/core/emacs-21.3/src/editfns.c:2931
#26 0x08122140 in Feval (form=1209524576)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:1960
#27 0x0811fdad in Fprogn (args=1480501740)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:431
#28 0x08119086 in Fsave_excursion (args=1480501740)
    at /local/home/carzanig/core/emacs-21.3/src/editfns.c:902
#29 0x08122140 in Feval (form=1209523376)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:1960
#30 0x0811fdad in Fprogn (args=1480501732)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:431
#31 0x0807b94c in Fsave_window_excursion (args=1480501732)
    at /local/home/carzanig/core/emacs-21.3/src/window.c:5373
#32 0x08122140 in Feval (form=1209504192)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:1960
#33 0x081346cf in readevalloop (readcharfun=1213280184, stream=0x0, 
    sourcename=943957908, evalfun=0x8121c68 <Feval>, printflag=0, 
    unibyte=138324388, readfun=405199556)
    at /local/home/carzanig/core/emacs-21.3/src/lread.c:1259
#34 0x08134936 in Feval_buffer (buffer=138324388, printflag=405199556, 
    filename=943957908, unibyte=405199556, do_allow_print=405199604)
    at /local/home/carzanig/core/emacs-21.3/src/lread.c:1317
#35 0x08122a2e in Ffuncall (nargs=6, args=0xbfffec94)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:2675
#36 0x08149bb4 in Fbyte_code (bytestr=405315732, vector=5, 
    maxdepth=-1073746800)
    at /local/home/carzanig/core/emacs-21.3/src/bytecode.c:716
#37 0x08122d09 in funcall_lambda (fun=1209832604, nargs=4, 
    arg_vector=0xbfffedd4)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:2851
#38 0x0812290a in Ffuncall (nargs=5, args=0xbfffedd0)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:2716
#39 0x08122724 in call4 (fn=405598820, arg1=944843796, arg2=943957908, 
    arg3=405199556, arg4=405199604)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:2525
#40 0x08133c92 in Fload (file=943957908, noerror=405199556, 
    nomessage=405199604, nosuffix=405199556, must_suffix=405199556)
    at /local/home/carzanig/core/emacs-21.3/src/lread.c:785
#41 0x08122a2e in Ffuncall (nargs=4, args=0xbfffef30)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:2675
#42 0x08149bb4 in Fbyte_code (bytestr=137076444, vector=3, 
    maxdepth=-1073746000)
    at /local/home/carzanig/core/emacs-21.3/src/bytecode.c:716
#43 0x08122d09 in funcall_lambda (fun=1210359644, nargs=1, 
    arg_vector=0xbffff0e4)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:2851
#44 0x0812290a in Ffuncall (nargs=2, args=0xbffff0e0)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:2716
#45 0x08149bb4 in Fbyte_code (bytestr=2, vector=1, maxdepth=-1073745696)
    at /local/home/carzanig/core/emacs-21.3/src/bytecode.c:716
#46 0x08122d09 in funcall_lambda (fun=1210350280, nargs=0, 
    arg_vector=0xbffff204)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:2851
#47 0x0812290a in Ffuncall (nargs=1, args=0xbffff200)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:2716
#48 0x08149bb4 in Fbyte_code (bytestr=136902532, vector=0, 
    maxdepth=-1073745408)
    at /local/home/carzanig/core/emacs-21.3/src/bytecode.c:716
#49 0x08122d09 in funcall_lambda (fun=1210346344, nargs=0, 
    arg_vector=0xbffff2c0)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:2851
#50 0x08122baa in apply_lambda (fun=1210346344, args=405199556, eval_flag=1)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:2770
#51 0x08121e98 in Feval (form=1210346344)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:2071
#52 0x080cdb15 in top_level_2 ()
    at /local/home/carzanig/core/emacs-21.3/src/keyboard.c:1254
#53 0x08120eb6 in internal_condition_case (bfun=0x80cdb04 <top_level_2>, 
    handlers=405295900, hfun=0x80cd844 <cmd_error>)
    at /local/home/carzanig/core/emacs-21.3/src/eval.c:1267
#54 0x080cdb41 in top_level_1 ()
    at /local/home/carzanig/core/emacs-21.3/src/keyboard.c:1262
#55 0x08120a71 in internal_catch (tag=138324388, func=0x80cdb18 <top_level_1>, 
    arg=405199556) at /local/home/carzanig/core/emacs-21.3/src/eval.c:1030
#56 0x080cda93 in command_loop ()
    at /local/home/carzanig/core/emacs-21.3/src/keyboard.c:1223
#57 0x080cd614 in recursive_edit_1 ()
    at /local/home/carzanig/core/emacs-21.3/src/keyboard.c:950
#58 0x080cd730 in Frecursive_edit ()
    at /local/home/carzanig/core/emacs-21.3/src/keyboard.c:1006
#59 0x080cc1ed in main (argc=5, argv=0xbffff924, envp=0xbffff93c)
    at /local/home/carzanig/core/emacs-21.3/src/emacs.c:1547
#60 0x40279a77 in __libc_start_main () from /lib/i686/libc.so.6

Hope this helps.

-Antonio

;;; THIS IS A TEST FILE
;;;

;; User-configurable variables:

(defcustom organizer-directory "~/Organizer/"
  "Directory where organizer pages can be found.  Must have the trailing 
forward slash."
  :type 'string
  :group 'organizer)

(defgroup organizer nil
  "Maintain a list of organizer items."
  :link '(emacs-commentary-link "organizer-mode")
  :version "21.2"
  :group 'calendar)

(defcustom organizer-prefix     "&%%(equal (calendar-current-date) date)"
  "*ORGANIZER mode prefix for entries.  This is useful in conjunction with
`calendar' and `diary' to include your organizer list file as part of
your organizer page.  With the value \"*/*\" the organizer page
displays each entry every day and it may also be marked on every day
of the calendar.  Using \"&%%(equal
(calendar-current-date) date)\" instead will only show and mark
organizer entries for today, but may slow down processing of the organizer
file somewhat."

  :type 'string
  :group 'organizer)

(defcustom organizer-file    "~/.organizer-do"
  "* Initial ORGANIZER mode list file."
  :type 'file
  :group 'organizer)

(defcustom organizer-show-priorities 1
  "*Default number of priorities to show by \\[organizer-top-priorities].
0 means show all entries."
  :type 'integer
  :group 'organizer)

(defcustom organizer-remove-separator t
  "*Non-nil to remove category separators in\
\\[organizer-top-priorities] and \\[organizer-print]."
  :type 'boolean
  :group 'organizer)

;; -----------------------------------------------------------------------------
;; Set up some helpful context ...

(defvar organizer-categories '("cbn")
  "ORGANIZER categories.")

(defvar organizer-cats nil
  "Old variable for holding the ORGANIZER categories.
Use `organizer-categories' instead.")

(defvar organizer-category-number 0 "ORGANIZER category number.")

(defvar organizer-tmp-buffer-name " *organizer tmp*")

(defvar organizer-category-sep (make-string 75 ?-)
  "Category separator.")

(defvar organizer-category-beg " --- "
  "Category start separator to be prepended onto category name.")

(defvar organizer-category-end "--- End"
  "Separator after a category.")

(defvar organizer-header "-*- mode: organizer; "
  "Header of organizer files.")

(defun organizer-category-select ()
  "Make ORGANIZER mode display the current category correctly."
  (let ((name (nth organizer-category-number organizer-categories)))
    (setq mode-line-buffer-identification
          ;;          (concat "Category: " name))
          (concat "Category: " (format "%18s" name)))
    (widen)
    (goto-char (point-min))
    (if (not (search-forward-regexp
              (concat "^"
                      (regexp-quote (concat organizer-prefix 
organizer-category-beg name))
                      "$") nil t))
        (todo-forward-category))
    (let ((begin (1+ (line-end-position))))
      (search-forward-regexp (concat "^" organizer-category-end))
      (narrow-to-region begin (line-beginning-position))
      (goto-char (point-min)))))
(defalias 'organizer-cat-slct 'organizer-category-select)

(defun organizer-top-priorities (&optional nof-priorities category-pr-page)
  "List top priorities for each category.

Number of entries for each category is given by NOF-PRIORITIES which
defaults to \'organizer-show-priorities\'.

If CATEGORY-PR-PAGE is non-nil, a page separator \'^L\' is inserted
between each category."

  (interactive "P")
  (or nof-priorities (setq nof-priorities organizer-show-priorities))
  (if (listp nof-priorities)            ;universal argument
      (setq nof-priorities (car nof-priorities)))
  (let ((organizer-print-buffer-name organizer-tmp-buffer-name)
        ;;(organizer-print-category-number 0)
        (organizer-category-break (if category-pr-page "" ""))
        (cat-end
         (concat
          (if organizer-remove-separator
              (concat organizer-category-end "\n"
                      (regexp-quote organizer-prefix) " " 
organizer-category-sep "\n")
            (concat organizer-category-end "\n"))))
        beg end)
    (organizer-show)
    (save-excursion
      (save-restriction
        (widen)
        (copy-to-buffer organizer-print-buffer-name (point-min) (point-max))
        (set-buffer organizer-print-buffer-name)
        (goto-char (point-min))
        (when (re-search-forward (regexp-quote organizer-header) nil t)
          (beginning-of-line 1)
          (delete-region (point) (line-end-position)))
        (while (re-search-forward       ;Find category start
                (regexp-quote (concat organizer-prefix organizer-category-beg))
                nil t)
          (setq beg (+ (line-end-position) 1)) ;Start of first entry.
          (re-search-forward cat-end nil t)
          (setq end (match-beginning 0))
          (replace-match organizer-category-break)
          (narrow-to-region beg end) ;In case we have too few entries.
          (goto-char (point-min))
          (if (= 0 nof-priorities)      ;Traverse entries.
              (goto-char end)           ;All entries
            (organizer-forward-item nof-priorities))
          (setq beg (point))
          (delete-region beg end)
          (widen))
        (and (looking-at "") (replace-match "")) ;Remove trailing form-feed.
        (goto-char (point-min))         ;Due to display buffer
        ))
    ;; Could have used switch-to-buffer as it has a norecord argument,
    ;; which is nice when we are called from e.g. organizer-print.
    ;; Else we could have used pop-to-buffer.
    (display-buffer organizer-print-buffer-name)
    (message "Type C-x 1 to remove %s window.  M-C-v to scroll the help."
             organizer-print-buffer-name)))

;; As calendar reads .organizer-do before organizer-mode is loaded.
(defun organizer-mode ()
  "Major mode for editing ORGANIZER lists.

\\{organizer-mode-map}"
  (interactive)
  (setq major-mode 'organizer-mode)
  (setq mode-name "ORGANIZER")
  (run-hooks 'organizer-mode-hook))

(defun organizer-show (&optional organizer-file)
  "Show ORGANIZER list."
  (interactive)
  ;;  (setq organizer-categories nil)
  ;;  (setq organizer-cats nil)
  ;; kill other organizer mode buffers
  (list-buffers)
  (other-window 1)
  (setq junk_buffer (current-buffer))
  (delete-other-windows)
  (goto-char (point-min))
  (if (re-search-forward "ORGANIZER[^-]" nil t)
      (progn
        (Buffer-menu-save)
        (Buffer-menu-execute)))
  (goto-char (point-min))
  (if (re-search-forward "ORGANIZER[^-]" nil t)
      (progn
        (Buffer-menu-delete)
        (Buffer-menu-execute)))
  (kill-buffer junk_buffer)
  (if (not organizer-file)
      (setq organizer-file (keyboard-quit)))
  (if (find-buffer-visiting organizer-file)
      (switch-to-buffer (find-buffer-visiting organizer-file))
    (if (file-exists-p organizer-file)
            (find-file organizer-file)
            (organizer-initial-setup organizer-file)))
  (if (null organizer-categories)
      (if (null organizer-cats)
          (error "Error in %s: No categories in list `organizer-categories'"
                 organizer-file)
        (goto-char (point-min))
        (and (search-forward "organizer-cats:" nil t)
             (replace-match "organizer-categories:"))
        (make-local-variable 'organizer-categories)
        (setq organizer-categories organizer-cats)))
  (beginning-of-line)
  (organizer-category-select))

(defun organizer-add-category (cat &optional organizer)
  "Add new category CAT to the ORGANIZER list."
  (interactive "sCategory: ")
  (save-window-excursion
    (if (not (string-equal mode-name "ORGANIZER")) 
        (if (equal organizer nil)
            (organizer-show)
          (organizer-show organizer)))
    (setq organizer-categories (cons cat organizer-categories))
    (setq organizer buffer-file-name)
    (widen)
    (goto-char (point-min))
    ;; If this is a new file, there's no previous mode line to kill
    (if (not (equal (point-min) (point-max)))
        (progn
          (beginning-of-line)
          (let ((junk-point (point)))
            (end-of-line)
            (let ((junk-point-two (point)))
              (delete-region junk-point junk-point-two)))))
    (insert "-*- mode: organizer; ")
    (insert (format "organizer-categories: %S; -*-" organizer-categories))
    ;; If this is a new file, insert line otherwise advance to the next line
    (if (equal (point) (point-max))
        (newline)
      (forward-char 1))
    (insert (format "%s%s%s\n%s\n%s %s\n"
                    organizer-prefix organizer-category-beg cat
                    organizer-category-end
                    organizer-prefix organizer-category-sep)))
  (widen)
;;  (organizer-save)
  (message "")
  (bury-buffer)
  (organizer-show organizer)
  (organizer-jump-to-category cat organizer)
  (organizer-category-select)
  0)

(defun organizer-jump-to-category (&optional category organizer)
  "Jump to a category.  Default is previous category."
  (interactive)
  (let* ((categories organizer-categories)
         (history (cons 'categories (1+ organizer-category-number)))
         (default (nth organizer-category-number organizer-categories)))
    (if (not category)
        (setq category (completing-read
                        (concat "Category [" default "]: ")
                        (organizer-category-alist) nil nil nil history 
default)))
    (if (string= "" category)
        (setq category (nth organizer-category-number organizer-categories)))
    (setq organizer-category-number
          (if (member category organizer-categories)
              (- (length organizer-categories)
                 (length (member category organizer-categories)))
            (organizer-add-category category)))
    (organizer-show organizer)))

(defun organizer-initial-setup (organizer)
  "Set up things to work properly in ORGANIZER mode."
  ;;  (setq organizer (read-file-name "Organizer page: " organizer-directory))
  (find-file organizer)
  ;;  (switch-to-buffer (file-name-nondirectory organizer))
  (erase-buffer)
  (organizer-mode)
  ;;  (organizer-add-category-no-prompt (concat "End of " 
(file-name-nondirectory organizer)) organizer))
  (if (not (file-exists-p organizer))
      (progn
        (setq cat "cbn")  
        (organizer-add-category cat organizer))))

(organizer-show "XXX")
(save-window-excursion
  (save-excursion
    (save-restriction
      (organizer-top-priorities))))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]