public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "matz at suse dot de" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/27681] FAIL: gdb.base/help.exp: apropos \(print[^[ bsiedf\".-]\) (timeout)
Date: Tue, 06 Apr 2021 15:51:13 +0000	[thread overview]
Message-ID: <bug-27681-4717-a96zDi5URg@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-27681-4717@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=27681

--- Comment #18 from Michael Matz <matz at suse dot de> ---
The types are simply incompatible:

extern int regcomp (regex_t *_Restrict_ __preg,
                    const char *_Restrict_ __pattern,
                    int __cflags);
...
extern regoff_t re_search (struct re_pattern_buffer *__buffer,
                           const char *__String, regoff_t __length,
                           regoff_t __start, regoff_t __range,
                           struct re_registers *__regs);

regex_t != struct re_pattern_buffer.  In the GNU implementation they are a
typedef
of each other (which is why there are no warnings :-/ ).  But conceptually it's
two opaque (and different) types (or rather, in POSIX a struct
re_pattern_buffer
doesn't exist).

With the pcre2 library they are _in fact_ different types, not just
conceptually. 
So regcomp (from pcre2) uses a different layout than re_search (from glibc) and
hence initializing a regex_t with regcomp (in gdb's
compiled_regex::compiled_regex() in m_pattern) but using it as a
struct re_pattern_buffer for re_search via compiled_regex::search is not going
to work.  Your work-around of putting -lc somewhere in between makes it so that
regcomp again comes from glibc (with the one in the later libpcre2 being
ignored), and hence stuff works again.  (Of course uses within libncurses that
assume pcre2 layout will be broken with the glibc regcomp).

There are multiple problems here:
1) that libpcre2 is used implicitely at all
2) If we accept (1) then it's a problem that the <regex.h> header of glibc
   is used to compile stuff, because that enables getting into the problematic
   situation to start with (with the pcre2 headers re_search would have been 
   simply undeclared, and lead to compile errors making the problem more
   obvious, or alternatively libiberty's regex.c would have been included,
   instead of relying on the mixture of glibc and pcre2)
3) Mixing re_search and regcomp on the same data would still be incorrect
   as a matter of principle, even though it happens to work when staying within
   glibc: if the design of the GNU extension would have been so that
   interoperability was intended there would have been no need for the extra
   type and initializer re_compile_pattern: regex_t and regcomp would suffice.
4) But, as something like re_free is missing the design of the GNU extension
   also isn't completely orthogonal to POSIX regex_t, leading to necessary
   mixture which is actually incorrect as per (3).

(3) and (4) together make it so that the GNU extension involving
struct re_pattern_buffer can only be used in very controlled circumstances,
and (1) breaks those circumstances :-/

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2021-04-06 15:51 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-01  9:46 [Bug gdb/27681] New: " vries at gcc dot gnu.org
2021-04-01  9:50 ` [Bug gdb/27681] " vries at gcc dot gnu.org
2021-04-01 10:06 ` vries at gcc dot gnu.org
2021-04-01 10:08 ` vries at gcc dot gnu.org
2021-04-01 11:38 ` vries at gcc dot gnu.org
2021-04-01 12:53 ` tromey at sourceware dot org
2021-04-01 13:16 ` vries at gcc dot gnu.org
2021-04-01 14:53 ` vries at gcc dot gnu.org
2021-04-02 11:17 ` vries at gcc dot gnu.org
2021-04-02 11:32 ` vries at gcc dot gnu.org
2021-04-03 13:08 ` vries at gcc dot gnu.org
2021-04-04  2:21 ` vries at gcc dot gnu.org
2021-04-06  8:53 ` schwab@linux-m68k.org
2021-04-06  9:00 ` vries at gcc dot gnu.org
2021-04-06  9:23 ` schwab@linux-m68k.org
2021-04-06 13:17 ` vries at gcc dot gnu.org
2021-04-06 14:03 ` matz at suse dot de
2021-04-06 14:12 ` vries at gcc dot gnu.org
2021-04-06 14:29 ` vries at gcc dot gnu.org
2021-04-06 15:51 ` matz at suse dot de [this message]
2021-04-07  2:51 ` tromey at sourceware dot org
2021-04-08  8:57 ` vries at gcc dot gnu.org
2021-04-08  9:44 ` vries at gcc dot gnu.org
2021-04-08 12:48 ` vries at gcc dot gnu.org
2021-04-08 12:56 ` matz at suse dot de
2021-04-08 13:10 ` tromey at sourceware dot org
2021-04-12 13:38 ` vries at gcc dot gnu.org
2021-04-13 15:35 ` vries at gcc dot gnu.org
2021-04-21 19:54 ` cvs-commit at gcc dot gnu.org
2021-04-21 19:55 ` vries at gcc dot gnu.org

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=bug-27681-4717-a96zDi5URg@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).