all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: "Michał Kondraciuk" <k.michal@zoho.com>
Cc: 31888@debbugs.gnu.org
Subject: bug#31888: 27.0.50; Segmentation fault in replace-buffer-contents
Date: Fri, 22 Jun 2018 16:03:02 +0300	[thread overview]
Message-ID: <83602bq8hl.fsf@gnu.org> (raw)
In-Reply-To: <39638875-4e85-85dc-1cfa-3bfb7321e6b0@zoho.com> (message from Michał Kondraciuk on Sun, 17 Jun 2018 15:12:10 +0200)

> From: Michał Kondraciuk <k.michal@zoho.com>
> Date: Sun, 17 Jun 2018 15:12:10 +0200
> 
> Run this shell command in Emacs source tree (the file contents.c was
> generated with clang-format):
> 
> emacs -Q src/dispnew.c contents.c --eval '(with-current-buffer
> "dispnew.c" (replace-buffer-contents "contents.c"))'
> 
> Backtrace (full backtrace in attachment):
> Thread 1 "emacs" received signal SIGSEGV, Segmentation fault.
> 0x00000000005b34cb in find_interval (tree=0x0, 
> position=position@entry=-12) at ../../src/intervals.c:616
> 616	      if (relative_position < LEFT_TOTAL_LENGTH (tree))
> #0  0x00000000005b34cb in find_interval (tree=0x0, 
> position=position@entry=-12) at ../../src/intervals.c:616
>          relative_position = -13
> #1  0x00000000005b4dfd in set_point_both (charpos=-12, bytepos=-12) at 
> ../../src/intervals.c:1864
>          to = <optimized out>
>          from = <optimized out>
>          toprev = <optimized out>
>          fromprev = <optimized out>
>          buffer_point = <optimized out>
>          old_position = 160
>          backwards = true
>          original_position = <optimized out>
> #2  0x00000000005b5586 in set_point (charpos=<optimized out>) at 
> ../../src/intervals.c:1754
> No locals.
> #3  0x000000000055c40d in Freplace_buffer_contents (source=0x184d9a4) at 
> ../../src/editfns.c:3267

We were accessing memory we freed, which of course segfaults.
This blunder is now fixed on the emacs-26 branch.

The command is still too slow (takes about 2.5 min for the above use
case in my unoptimized build, about 30 sec of which is spent in
compareseq).  I will try to look into speeding it up.

Thanks.





  parent reply	other threads:[~2018-06-22 13:03 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-17 13:12 bug#31888: 27.0.50; Segmentation fault in replace-buffer-contents Michał Kondraciuk
2018-06-18 21:50 ` bug#31888: Milan Stanojević
2018-06-22 13:03 ` Eli Zaretskii [this message]
2018-06-23 11:15   ` bug#31888: 27.0.50; Segmentation fault in replace-buffer-contents Eli Zaretskii
2018-06-25 10:49     ` João Távora
2018-06-25 14:54       ` Eli Zaretskii
2018-06-25 15:55         ` João Távora
2018-06-29 14:07         ` Eli Zaretskii
2018-06-29 14:51           ` Stefan Monnier
2018-06-29 15:23             ` Eli Zaretskii
2018-06-29 16:57               ` Stefan Monnier
2018-06-29 17:34                 ` Eli Zaretskii
2018-06-29 17:39                   ` Eli Zaretskii
2018-06-29 19:04                     ` João Távora
2018-06-29 19:09                       ` Eli Zaretskii
2018-06-30  8:33                         ` João Távora
2018-06-30 11:03                           ` Eli Zaretskii
2018-06-30 13:28                             ` João Távora
2018-06-29 20:40                   ` Stefan Monnier
2018-06-30  7:44                     ` Eli Zaretskii
2018-06-30 12:54                       ` Stefan Monnier
2018-06-30 13:51                         ` Eli Zaretskii

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=83602bq8hl.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=31888@debbugs.gnu.org \
    --cc=k.michal@zoho.com \
    /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.