[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: regex_internal.h modification lead to GCC crash
From: |
Derek Price |
Subject: |
Re: regex_internal.h modification lead to GCC crash |
Date: |
Mon, 19 Sep 2005 20:53:56 -0400 |
User-agent: |
Mozilla Thunderbird 1.0.6 (Windows/20050716) |
Yoann Vandoorselaere wrote:
>Hi list,
>
>Recently introduced modification to regex_internal.h lead to a crash
>when compiling GnuLib regex module under FreeBSD-4.11 GCC-2.95.4.
>
>The same module is reported to compile successfully under FreeBSD-5.4,
>GCC-3.4.2.
>The GCC crash was traced down to the following addition:
>
>+#if !__GNUC_PREREQ (3, 1)
>+# define always_inline
>+#endif
>
>Commenting out the '# define always_inline' line fix the problem.
>
>
I can reproduce this on some half-dozen platforms. It has to do with
calling __attribute() without arguments with gcc 2.95.4 or so. They all
seg-fault but one, which manages to print an error.
I've attached a patch, which defines attribute_always_inline to
__attribute((always_inline)) when always_inline is available and empty
when not and similar for attribute_pure. I've tested it on two of the
offending platforms.
2005-09-19 Derek Price <address@hidden>
* regex_internal.h (attribute_always_inline, attribute_pure): Instead of
blanking pure and always_inline when not available, define new macros.
Use attribute_pure as needed for function decls.
* regcomp.c, regexec.c: Use new attribute_always_inline.
* regex_internal.c: Use new attribute_pure.
Regards,
Derek
--
Derek R. Price
CVS Solutions Architect
Ximbiot <http://ximbiot.com>
v: +1 717.579.6168
f: +1 717.234.3125
<mailto:address@hidden>
Index: lib/regcomp.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/regcomp.c,v
retrieving revision 1.19
diff -u -p -r1.19 regcomp.c
--- lib/regcomp.c 16 Sep 2005 00:23:36 -0000 1.19
+++ lib/regcomp.c 20 Sep 2005 00:51:35 -0000
@@ -282,7 +282,7 @@ weak_alias (__re_compile_fastmap, re_com
#endif
static inline void
-__attribute ((always_inline))
+attribute_always_inline
re_set_fastmap (char *fastmap, bool icase, int ch)
{
fastmap[ch] = 1;
@@ -2718,7 +2718,7 @@ parse_bracket_exp (re_string_t *regexp,
Return the index of the symbol in the SYMB_TABLE. */
auto inline int32_t
- __attribute ((always_inline))
+ attribute_always_inline
seek_collating_symbol_entry (const unsigned char *name, size_t name_len)
{
int32_t hash = elem_hash ((const char *) name, name_len);
@@ -2749,7 +2749,7 @@ parse_bracket_exp (re_string_t *regexp,
Return the value if succeeded, UINT_MAX otherwise. */
auto inline unsigned int
- __attribute ((always_inline))
+ attribute_always_inline
lookup_collation_sequence_value (bracket_elem_t *br_elem)
{
if (br_elem->type == SB_CHAR)
@@ -2816,7 +2816,7 @@ parse_bracket_exp (re_string_t *regexp,
update it. */
auto inline reg_errcode_t
- __attribute ((always_inline))
+ attribute_always_inline
build_range_exp (bitset sbcset, re_charset_t *mbcset,
Idx *range_alloc,
bracket_elem_t *start_elem, bracket_elem_t *end_elem)
@@ -2896,7 +2896,7 @@ parse_bracket_exp (re_string_t *regexp,
pointer argument sinse we may update it. */
auto inline reg_errcode_t
- __attribute ((always_inline))
+ attribute_always_inline
build_collating_symbol (bitset sbcset, re_charset_t *mbcset,
Idx *coll_sym_alloc, const unsigned char *name)
{
Index: lib/regexec.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/regexec.c,v
retrieving revision 1.20
diff -u -p -r1.20 regexec.c
--- lib/regexec.c 16 Sep 2005 00:23:36 -0000 1.20
+++ lib/regexec.c 20 Sep 2005 00:51:36 -0000
@@ -1017,7 +1017,7 @@ prune_impossible_nodes (re_match_context
since initial states may have constraints like "\<", "^", etc.. */
static inline re_dfastate_t *
-__attribute ((always_inline)) internal_function
+attribute_always_inline internal_function
acquire_init_state_context (reg_errcode_t *err, const re_match_context_t *mctx,
Idx idx)
{
Index: lib/regex_internal.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/regex_internal.c,v
retrieving revision 1.19
diff -u -p -r1.19 regex_internal.c
--- lib/regex_internal.c 16 Sep 2005 00:23:36 -0000 1.19
+++ lib/regex_internal.c 20 Sep 2005 00:51:36 -0000
@@ -734,7 +734,7 @@ re_string_reconstruct (re_string_t *pstr
}
static unsigned char
-internal_function __attribute ((pure))
+internal_function attribute_pure
re_string_peek_byte_case (const re_string_t *pstr, Idx idx)
{
int ch;
@@ -771,7 +771,7 @@ re_string_peek_byte_case (const re_strin
}
static unsigned char
-internal_function __attribute ((pure))
+internal_function attribute_pure
re_string_fetch_byte_case (re_string_t *pstr)
{
if (BE (!pstr->mbs_allocated, 1))
@@ -1266,7 +1266,7 @@ re_node_set_insert_last (re_node_set *se
Return true if SET1 and SET2 are equivalent. */
static bool
-internal_function __attribute ((pure))
+internal_function attribute_pure
re_node_set_compare (const re_node_set *set1, const re_node_set *set2)
{
Idx i;
@@ -1281,7 +1281,7 @@ re_node_set_compare (const re_node_set *
/* Return (idx + 1) if SET contains the element ELEM, return 0 otherwise. */
static Idx
-internal_function __attribute ((pure))
+internal_function attribute_pure
re_node_set_contains (const re_node_set *set, Idx elem)
{
__re_size_t idx, right, mid;
Index: lib/regex_internal.h
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/regex_internal.h,v
retrieving revision 1.16
diff -u -p -r1.16 regex_internal.h
--- lib/regex_internal.h 16 Sep 2005 00:23:36 -0000 1.16
+++ lib/regex_internal.h 20 Sep 2005 00:51:36 -0000
@@ -93,16 +93,19 @@
# endif
#endif
-#if !__GNUC_PREREQ (3, 1)
-# define always_inline
+#if __GNUC_PREREQ (3, 1)
+# define attribute_always_inline __attribute((always_inline))
+#else
+# define attribute_always_inline
#endif
#if __GNUC__ >= 3
# define BE(expr, val) __builtin_expect (expr, val)
+# define attribute_pure __attribute((pure))
#else
# define BE(expr, val) (expr)
# define inline
-# define pure
+# define attribute_pure
#endif
/* Number of single byte character. */
@@ -447,7 +450,7 @@ static void build_upper_buffer (re_strin
static void re_string_translate_buffer (re_string_t *pstr) internal_function;
static unsigned int re_string_context_at (const re_string_t *input,
Idx idx, int eflags)
- internal_function __attribute ((pure));
+ internal_function attribute_pure;
#define re_string_peek_byte(pstr, offset) \
((pstr)->mbs[(pstr)->cur_idx + offset])
@@ -870,7 +873,7 @@ bitset_mask (bitset dest, const bitset s
#if defined RE_ENABLE_I18N
/* Inline functions for re_string. */
static inline int
-internal_function __attribute ((pure))
+internal_function attribute_pure
re_string_char_size_at (const re_string_t *pstr, Idx idx)
{
int byte_idx;
@@ -883,7 +886,7 @@ re_string_char_size_at (const re_string_
}
static inline wint_t
-internal_function __attribute ((pure))
+internal_function attribute_pure
re_string_wchar_at (const re_string_t *pstr, Idx idx)
{
if (pstr->mb_cur_max == 1)
@@ -892,7 +895,7 @@ re_string_wchar_at (const re_string_t *p
}
static int
-internal_function __attribute ((pure))
+internal_function attribute_pure
re_string_elem_size_at (const re_string_t *pstr, Idx idx)
{
#ifdef _LIBC