Unfortunately, I get crashes with this regexp now in the test suite.
Things like this happen:
Testing /project/xemacs/ws/bsd/tests/automated/lisp-tests.el...Fatal error: assertion
failed, file /project/xemacs/ws/bsd/src/insdel.c, line 1122, ( x) >= BI_BUF_BEG (buf)
&& x <= BI_BUF_Z (buf)
Fatal error (6).
[...]
Lisp backtrace follows:
string-match("\\(\\.\\=\\)" ".")
(not (string-match "\\(\\.\\=\\)" "."))
[...]
This happens for me on more than one platform, with and without mule,
but only if I build with error-checking.
Yoshiki, if you cannot reproduce this, you can get access to my own
workspaces.
Ben, you are the most knowledgable regexp maintainer here. Can you
take a look at this?
Yoshiki, also make sure that any fix does not involve "hiding" the bug
by changing asserts, etc...
>>>> "Y" == Yoshiki Hayashi
<yoshiki(a)xemacs.org> writes:
Y> Markus Linnala <maage(a)cs.tut.fi> writes:
> eval
> (string-match "\\(\\.\\=\\)" ".")
Y> The crash is caused by buffer bound checking code. When
Y> matching against string, pointer d in re_match_2_internal
Y> does not point to a string inside the buffer.
Y> BI_BUF_PTR_BYTE_POS returns right value only when d points
Y> inside the buffer.
Y> This patch checks if the value is reasonable so that assert
Y> won't be hit. I'm not so good at this regexp stuff, so I'd
Y> appreciate it very much if someone comes up with a better
Y> fix.
> I guess this can be tested by others with following patch.
>
> Index: tests/automated/lisp-tests.el
Y> Thanks. I've applied it to the sources.
Y> 2000-08-03 Yoshiki Hayashi <yoshiki(a)xemacs.org>
Y> * regex.c (re_match_2_internal): Check if pointer is inside
Y> a buffer so that assert won't be triggered when matching against
Y> strings.
Y> * buffer.h (VALID_BUF_PTR_P): New macro.
Y> Index: buffer.h
Y> ===================================================================
Y> RCS file: /usr/CVSroot/XEmacs/xemacs/src/buffer.h,v
Y> retrieving revision 1.13.2.21
Y> diff -u -r1.13.2.21 buffer.h
Y> --- buffer.h 2000/07/21 10:15:48 1.13.2.21
Y> +++ buffer.h 2000/08/03 08:23:44
Y> @@ -636,6 +636,9 @@
Y> #define BUF_PTR_BYTE_POS(buf, ptr) \
Y> bytind_to_bufpos (buf, BI_BUF_PTR_BYTE_POS (buf, ptr))
Y> +#define VALID_BUF_PTR_P(buf, ptr) \
Y> + valid_memind_p (buf, bytind_to_memind (buf, BI_BUF_PTR_BYTE_POS (buf, ptr)))
Y> +
Y> /* Address of byte at position POS in buffer. */
Y> INLINE_HEADER Bufbyte * BI_BUF_BYTE_ADDRESS (struct buffer *buf, Bytind pos);
Y> INLINE_HEADER Bufbyte *
Y> Index: regex.c
Y> ===================================================================
Y> RCS file: /usr/CVSroot/XEmacs/xemacs/src/regex.c,v
Y> retrieving revision 1.22.2.6
Y> diff -u -r1.22.2.6 regex.c
Y> --- regex.c 2000/03/13 07:28:04 1.22.2.6
Y> +++ regex.c 2000/08/03 08:23:45
Y> @@ -5500,21 +5500,24 @@
Y> #ifdef emacs
Y> case before_dot:
Y> DEBUG_PRINT1 ("EXECUTING before_dot.\n");
Y> - if (BUF_PTR_BYTE_POS (regex_emacs_buffer, (unsigned char *) d) >=
Y> - BUF_PT (regex_emacs_buffer))
Y> + if (!VALID_BUF_PTR_P (regex_emacs_buffer, (unsigned char *) d)
Y> + || BUF_PTR_BYTE_POS (regex_emacs_buffer, (unsigned char *) d)
Y> + >= BUF_PT (regex_emacs_buffer))
Y> goto fail;
Y> break;
Y> case at_dot:
Y> DEBUG_PRINT1 ("EXECUTING at_dot.\n");
Y> - if (BUF_PTR_BYTE_POS (regex_emacs_buffer, (unsigned char *) d)
Y> + if (!VALID_BUF_PTR_P (regex_emacs_buffer, (unsigned char *) d)
Y> + || BUF_PTR_BYTE_POS (regex_emacs_buffer, (unsigned char *) d)
Y> != BUF_PT (regex_emacs_buffer))
Y> goto fail;
Y> break;
Y> case after_dot:
Y> DEBUG_PRINT1 ("EXECUTING after_dot.\n");
Y> - if (BUF_PTR_BYTE_POS (regex_emacs_buffer, (unsigned char *) d)
Y> + if (!VALID_BUF_PTR_P (regex_emacs_buffer, (unsigned char *) d)
Y> + || BUF_PTR_BYTE_POS (regex_emacs_buffer, (unsigned char *) d)
Y> <= BUF_PT (regex_emacs_buffer))
Y> goto fail;
Y> break;
Y> --
Y> Yoshiki Hayashi