public inbox for glibc-bugs-regex@sourceware.org
help / color / mirror / Atom feed
From: "octo.nebula at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs-regex@sourceware.org
Subject: [Bug regex/16749] New: segfault in regfree
Date: Tue, 25 Mar 2014 05:08:00 -0000	[thread overview]
Message-ID: <bug-16749-132@http.sourceware.org/bugzilla/> (raw)

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

            Bug ID: 16749
           Summary: segfault in regfree
           Product: glibc
           Version: 2.19
            Status: NEW
          Severity: critical
          Priority: P2
         Component: regex
          Assignee: unassigned at sourceware dot org
          Reporter: octo.nebula at gmail dot com
                CC: drepper.fsp at gmail dot com

When I run this sample program:

#include <regex.h>
#include <stdio.h>

int main()
{
  regex_t regex;
  regmatch_t matches[3];
  int status;

  status = regcomp(&regex, "(ello)", REG_EXTENDED);
  if (status != 0) {
    fprintf(stderr, "invalid regex\n");
    return 1;
  }

  status = regexec(&regex, "Hello, world!", sizeof matches, matches, 0);
  if (status != 0)
    fprintf(stderr, "Match failed\n");
  else
    printf("Matched range is %d,%d\n", matches[1].rm_so, matches[1].rm_eo);

  regfree(&regex);
  return 0;
}

And compile with:
gcc -g3 -Wall -Wextra -ore re.c

With gdb I get the SIGSEGV on regfree():

(gdb) run
Starting program: /home/sun/source/re 
Matched range is 1,5

Program received signal SIGSEGV, Segmentation fault.
0xb7ecd0a9 in free_dfa_content () from /usr/lib/libc.so.6
(gdb) bt
#0  0xb7ecd0a9 in free_dfa_content () from /usr/lib/libc.so.6
#1  0xb7ed8b2f in regfree () from /usr/lib/libc.so.6
#2  0x0804864f in main () at re.c:23


There is nothing wrong with the regex match, as you can see it succeeds without
any problems.

What is the problem with regfree?

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


             reply	other threads:[~2014-03-25  5:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-25  5:08 octo.nebula at gmail dot com [this message]
2014-03-25  5:09 ` [Bug regex/16749] " octo.nebula at gmail dot com
2014-03-25 17:56 ` schwab@linux-m68k.org
2014-06-12 19:54 ` fweimer at redhat dot com

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-16749-132@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs-regex@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).