[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/emacs-24 r108012: Fix bug #11519 with reloc
From: |
Eli Zaretskii |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/emacs-24 r108012: Fix bug #11519 with relocation of buffer text during regex search. |
Date: |
Wed, 23 May 2012 20:32:28 +0300 |
User-agent: |
Bazaar (2.5.0) |
------------------------------------------------------------
revno: 108012
fixes bug: http://debbugs.gnu.org/11519
committer: Eli Zaretskii <address@hidden>
branch nick: emacs-24
timestamp: Wed 2012-05-23 20:32:28 +0300
message:
Fix bug #11519 with relocation of buffer text during regex search.
src/lisp.h [REL_ALLOC]: Add prototypes for external functions
defined on ralloc.c.
src/buffer.c [REL_ALLOC]: Remove prototypes of
r_alloc_reset_variable, r_alloc, r_re_alloc, and r_alloc_free,
they are now on lisp.h.
src/ralloc.c (r_alloc_inhibit_buffer_relocation): New function.
src/search.c (search_buffer): Use it to inhibit relocation of buffer
text while re_search_2 is doing its job, because re_search_2 is
passed C pointers to buffer text.
modified:
src/ChangeLog
src/buffer.c
src/lisp.h
src/ralloc.c
src/search.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog 2012-05-21 19:56:36 +0000
+++ b/src/ChangeLog 2012-05-23 17:32:28 +0000
@@ -1,3 +1,18 @@
+2012-05-23 Eli Zaretskii <address@hidden>
+
+ * lisp.h [REL_ALLOC]: Add prototypes for external functions
+ defined on ralloc.c.
+
+ * buffer.c [REL_ALLOC]: Remove prototypes of
+ r_alloc_reset_variable, r_alloc, r_re_alloc, and r_alloc_free,
+ they are now on lisp.h.
+
+ * ralloc.c (r_alloc_inhibit_buffer_relocation): New function.
+
+ * search.c (search_buffer): Use it to inhibit relocation of buffer
+ text while re_search_2 is doing its job, because re_search_2 is
+ passed C pointers to buffer text. (Bug#11519)
+
2012-05-21 Eli Zaretskii <address@hidden>
* msdos.c (internal_terminal_init) <Vwindow_system_version>:
=== modified file 'src/buffer.c'
--- a/src/buffer.c 2012-03-12 08:27:25 +0000
+++ b/src/buffer.c 2012-05-23 17:32:28 +0000
@@ -2014,10 +2014,6 @@
return byte_pos;
}
-#ifdef REL_ALLOC
-extern void r_alloc_reset_variable (POINTER_TYPE *, POINTER_TYPE *);
-#endif /* REL_ALLOC */
-
DEFUN ("buffer-swap-text", Fbuffer_swap_text, Sbuffer_swap_text,
1, 1, 0,
doc: /* Swap the text between current buffer and BUFFER. */)
@@ -4779,13 +4775,6 @@
Buffer-text Allocation
***********************************************************************/
-#ifdef REL_ALLOC
-extern POINTER_TYPE *r_alloc (POINTER_TYPE **, size_t);
-extern POINTER_TYPE *r_re_alloc (POINTER_TYPE **, size_t);
-extern void r_alloc_free (POINTER_TYPE **ptr);
-#endif /* REL_ALLOC */
-
-
/* Allocate NBYTES bytes for buffer B's text buffer. */
static void
=== modified file 'src/lisp.h'
--- a/src/lisp.h 2012-03-12 06:34:32 +0000
+++ b/src/lisp.h 2012-05-23 17:32:28 +0000
@@ -3565,6 +3565,15 @@
/* Defined in msdos.c, w32.c */
extern char *emacs_root_dir (void);
#endif /* DOS_NT */
+
+#ifdef REL_ALLOC
+/* Defined in ralloc.c */
+extern void r_alloc_reset_variable (POINTER_TYPE **, POINTER_TYPE **);
+extern POINTER_TYPE *r_alloc (POINTER_TYPE **, size_t);
+extern POINTER_TYPE *r_re_alloc (POINTER_TYPE **, size_t);
+extern void r_alloc_free (POINTER_TYPE **ptr);
+extern void r_alloc_inhibit_buffer_relocation (int);
+#endif /* REL_ALLOC */
/* Nonzero means Emacs has already been initialized.
Used during startup to detect startup of dumped Emacs. */
=== modified file 'src/ralloc.c'
--- a/src/ralloc.c 2012-02-01 16:51:20 +0000
+++ b/src/ralloc.c 2012-05-23 17:32:28 +0000
@@ -1201,6 +1201,12 @@
bloc->variable = new;
}
+void
+r_alloc_inhibit_buffer_relocation (int inhibit)
+{
+ use_relocatable_buffers = !inhibit;
+}
+
/***********************************************************************
Initialization
=== modified file 'src/search.c'
--- a/src/search.c 2012-03-27 06:46:42 +0000
+++ b/src/search.c 2012-05-23 17:32:28 +0000
@@ -1158,12 +1158,25 @@
while (n < 0)
{
EMACS_INT val;
+
+#ifdef REL_ALLOC
+ /* re_search_2 below is passed C pointers to buffer text.
+ If some code called by it causes memory (re)allocation,
+ buffer text could be relocated on platforms that use
+ REL_ALLOC, which invalidates those C pointers. So we
+ inhibit relocation of buffer text for as long as
+ re_search_2 runs. */
+ r_alloc_inhibit_buffer_relocation (1);
+#endif
val = re_search_2 (bufp, (char *) p1, s1, (char *) p2, s2,
pos_byte - BEGV_BYTE, lim_byte - pos_byte,
(NILP (Vinhibit_changing_match_data)
? &search_regs : &search_regs_1),
/* Don't allow match past current point */
pos_byte - BEGV_BYTE);
+#ifdef REL_ALLOC
+ r_alloc_inhibit_buffer_relocation (0);
+#endif
if (val == -2)
{
matcher_overflow ();
@@ -1202,11 +1215,20 @@
while (n > 0)
{
EMACS_INT val;
+
+#ifdef REL_ALLOC
+ /* See commentary above for the reasons for inhibiting
+ buffer text relocation here. */
+ r_alloc_inhibit_buffer_relocation (1);
+#endif
val = re_search_2 (bufp, (char *) p1, s1, (char *) p2, s2,
pos_byte - BEGV_BYTE, lim_byte - pos_byte,
(NILP (Vinhibit_changing_match_data)
? &search_regs : &search_regs_1),
lim_byte - BEGV_BYTE);
+#ifdef REL_ALLOC
+ r_alloc_inhibit_buffer_relocation (0);
+#endif
if (val == -2)
{
matcher_overflow ();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/emacs-24 r108012: Fix bug #11519 with relocation of buffer text during regex search.,
Eli Zaretskii <=