all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Mat Smiglarski <penthief@SDF.ORG>
To: Dmitry Antipov <dmantipov@yandex.ru>
Cc: 18180@debbugs.gnu.org
Subject: bug#18180: 24.3.92; Segfault in mark_object
Date: Mon, 04 Aug 2014 07:46:32 +0100	[thread overview]
Message-ID: <cb9b883e58451ac6754e83dc88cbde02@SDF.ORG> (raw)
In-Reply-To: <53DF0A95.7040707@yandex.ru>

On 2014-08-04 05:22, Dmitry Antipov wrote:
> On 08/03/2014 07:03 PM, Mat Smiglarski wrote:
> 
>> 2. Call some code which kills and creates a frame between 2 and 25 
>> times.
> 
> This doesn't look specific and useful. Do you create frame(s) with
> some non-default parameters?  After making changes in frame-related
> code, I usually do something like this:
> 
> (defun frame-test ()
>   (interactive)
>   (dotimes (i 10)
>     (let ((frame-list nil))
>       (dotimes (j 10)
> (setq frame-list (cons (make-frame) frame-list)))
>       (mapcar #'delete-frame frame-list))))
> 
> Can you reproduce your crash with this?

No that works fine.

On 2014-08-04 05:39, Dmitry Antipov wrote:
> On 08/03/2014 07:03 PM, Mat Smiglarski wrote:
> 
>> $ emacs -Q
> 
> [...skip...]
> 
>> "stupider-speed-read" (0xffffd6c8)
> 
> What's this?  This doesn't look like a feature comes from
> standard Lisp code.  I'm just curious how you get into
> this by running with -Q...

That is the code being used as a stress test; the code that I call 
between 2 and 25 times.

Perhaps you need to see the code, which has been slightly renamed. It 
can be made shorter by removing the comments and some key mappings but 
that doesn't seem very helpful.

1. Create stress-test.el with the following

(require 'cl)

(defvar stress-buffer-name "stress" "The name of the buffer created by 
`stress'.")
(defvar pause-time 0.1)

(defvar stress-map
   (let ((km (make-sparse-keymap)))
     (define-key km (kbd "q") 'stress-quit)
     (define-key km (kbd "SPC") 'stress-toggle-pause)
     (define-key km (kbd "n") 'stress-tick)
     km)
   "Keymap for `stress-speed-read'.")

(defun stress-speed-read (source-buffer)
   "Create and run a speed reading frame for `SOURCE-BUFFER'.
Words from BUFFER are displayed individually and progressed by an 
adjustable timer."
   (interactive "bCreate stress-speed-reader for source buffer: ")
   (stress-quit) ; Ensure that it is starting from a clean state.
   (setq min-pause-time 0.1)
   (setq tokeniser "[^ \n]+")
   (setq *source-buffer* (make-indirect-buffer source-buffer "source 
buffer"))
   (setq stress-frame
         (let* ((width 200)
                (left (- (/ (- (x-display-pixel-width) ; center frame
                               width) 2)
                         8)))
           (make-frame `((height . 1)
                         (left . ,left)
                         (top . 100)
                         (mode-line-format . nil)
                         (cursor-type . nil)
                         (minibuffer . nil)
                         (left-margin . 0)
                         (left-fringe . 0)
                         (right-fringe . 0)
                         (tool-bar-lines . 0)
                         (menu-bar-lines . 0)
                         (line-spacing . 0)
                         (unsplittable . t)
                         (fill-column . 30)))))
   (setq stress-buffer (get-buffer-create stress-buffer-name))
   (with-current-buffer *source-buffer*
     (goto-char (point-min))
     (with-selected-frame stress-frame
       (display-buffer stress-buffer '((display-buffer-same-window)))
     (stress--do
      (fundamental-mode)
      (setq buffer-read-only t)
      (use-local-map stress-map)
      (set-frame-font (font-spec :size 50))))
   (stress--start)))

(defmacro stress--do (&rest body)
   "Do something in the speed reading frame."
   `(with-selected-frame stress-frame
      (with-current-buffer stress-buffer
        ,@body)))

(defun stress-running-p ()
   "Is the speed reader running."
   (and (get-buffer stress-buffer-name) t))

(defun stress-toggle-pause ()
   "Pause or unpause."
   (interactive)
   (if (timerp resume-timer)
       (stress--stop)
     (stress--start)))

(defun stress--start ()
   "Start, and then continue on a timer."
   (stress-tick)
   (stress--resume pause-time))

(defun stress--resume (delay)
   "Iterate after a delay of `DELAY' seconds."
   (if (> delay 0)
       (setq resume-timer
             (run-at-time
              (format "%2f seconds" delay)
              nil #'stress-tick))
     (stress-quit)))

(defun stress--stop ()
   "Stop. Well more of a pause than a stop, really."
   (when (and (boundp 'resume-timer) (timerp resume-timer))
     (cancel-timer resume-timer)
     (setq resume-timer nil)))

(defun stress-quit ()
   "Quit the speed reader."
   (interactive)
   (stress--stop)
   (when (and (boundp 'stress-buffer)
              (buffer-live-p stress-buffer))
     (kill-buffer stress-buffer)
     (setq stress-buffer nil))
   (when (buffer-live-p (get-buffer "source buffer"))
     (kill-buffer "source buffer")
     (setq *source-buffer* nil))
   (when (and (boundp 'stress-frame)
              (frame-live-p stress-frame))
     (delete-frame stress-frame)
     (setq stress-frame nil)))

(defun stress-tick ()
   "Progress the reading.
This function handles being called either during manual or automatic 
iteration,
whether paused or not."
   (interactive)
   (let ((was-running-p (and (boundp 'resume-timer) (timerp 
resume-timer)))
         (s (with-current-buffer *source-buffer*
              (and (search-forward-regexp tokeniser nil t)
                   (match-string-no-properties 0)))))
     (stress--stop) ; ensure stopped
     (if s
         (let ((center (max (/ (length s) 2) 1)))
           (stress--do
            (setq buffer-read-only nil)
            (put-text-property 0 (length s) 'face '(foreground-color . 
"DeepSkyBlue") s)
            (put-text-property (- center 1) center 'face 
'(foreground-color . "tomato") s)
            (goto-char (point-min))
            (loop repeat
                  (max (- (/ 30 2) center) 0)
                  do (insert " "))
            (insert s)
            (delete-region (point) (point-max))
            (setq buffer-read-only t)
            (when was-running-p
              (stress--resume (* (stress--punctuation-weighting s)
                                   pause-time)))))
       (stress-quit))))

(defun stress--punctuation-weighting (str)
   "Returns the punctuation delay modifier for `STR', where 0 is a 
request to stop."
   (if str
       (case (last (car (last (string-to-list str))))
         (?, 1.4)
         (?\; 1.6)
         (?. 2)
         (?\: 2.2)
         (t 1))
     0))

(defun stress--log ()
   "User feedback."
   (message (format "Pause-time: %.2f" pause-time)))

2. Start emacs

$ emacs -Q -l stress-test.el

3. Setup a macro

C-x ( M-x stress-speed-read RET C-x )

4. Delete and restart the frame and time 20 times, although 4 or 5 times 
is usually enough on this laptop.
Note that q is bound in the code above.

q C-x e q C-x e q C-x e q C-x e q C-x e q C-x e q C-x e q C-x e q C-x e 
q C-x e
q C-x e q C-x e q C-x e q C-x e q C-x e q C-x e q C-x e q C-x e q C-x e 
q C-x e

5. See it crash.

Program received signal SIGSEGV, Segmentation fault.
0x00000000005b9d1a in mark_object (arg=140737253503599) at alloc.c:6318
6318	      FLOAT_MARK (XFLOAT (obj));

I have not been able to reproduce this by automating the calls to 
stress-speed-read.
Increasing stress-pause-time makes the crash more difficult to 
reproduce.
Isolating the make-frame call, and running that 20 times does not cause 
the crash.

Regards,
Mat





  reply	other threads:[~2014-08-04  6:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-03 15:03 bug#18180: 24.3.92; Segfault in mark_object Mat Smiglarski
     [not found] ` <handler.18180.B.140707825027898.ack@debbugs.gnu.org>
2014-08-03 21:08   ` bug#18180: Acknowledgement (24.3.92; Segfault in mark_object) Mat Smiglarski
2014-08-04  4:22 ` bug#18180: 24.3.92; Segfault in mark_object Dmitry Antipov
2014-08-04  6:46   ` Mat Smiglarski [this message]
2014-08-04  9:15     ` Dmitry Antipov
2014-08-06 17:29       ` Stefan Monnier
2014-08-04  4:39 ` Dmitry Antipov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cb9b883e58451ac6754e83dc88cbde02@SDF.ORG \
    --to=penthief@sdf.org \
    --cc=18180@debbugs.gnu.org \
    --cc=dmantipov@yandex.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.