public inbox for glibc-bugs-regex@sourceware.org
help / color / mirror / Atom feed
* [Bug regex/16851] New: re_node_set_alloc should not return REG_ESPACE when size == 0
@ 2014-04-17 22:19 nkennedy at grammatech dot com
  2014-04-18  1:15 ` [Bug regex/16851] " eggert at gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: nkennedy at grammatech dot com @ 2014-04-17 22:19 UTC (permalink / raw)
  To: glibc-bugs-regex

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

            Bug ID: 16851
           Summary: re_node_set_alloc should not return REG_ESPACE when
                    size == 0
           Product: glibc
           Version: unspecified
            Status: NEW
          Keywords: std-isoc
          Severity: normal
          Priority: P2
         Component: regex
          Assignee: unassigned at sourceware dot org
          Reporter: nkennedy at grammatech dot com
                CC: drepper.fsp at gmail dot com, eggert at gnu dot org

regcomp fails with REG_ESPACE from re_node_set_alloc if malloc(0) returns NULL.
 ptmalloc2 malloc(0) doesn't return NULL (unless it's really out of space), but
this is allowed by the standard and causes errors when such an allocator is
used.

This was fixed in gnulib at bbf0d723ed2335add96bcc0f842885d8a5d8b6da:
http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=bbf0d723ed2335add96bcc0f842885d8a5d8b6da

And previously in uClibc at 4af711dfe8caf18756c2cb28f72b102c5eba3930:
http://git.opencores.org/?a=commitdiff&p=uClibc&h=4af711dfe8caf18756c2cb28f72b102c5eba3930

(Despite the commit message, the uClibc patch had not ultimately been applied
to sed, rather until bbf0d72... gnulib's regex worked around the error using
the malloc-gnu wrapper module.)

In the vein of harmonizing glibc/gnulib regex, I'm don't think adding the
MALLOC_0_IS_NONNULL macro attempting to check for malloc(0) failure is needed.
It should be enough to add "&& size != 0" to

regex_internal.c:972 if (BE (set->elems == NULL, 0))

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug regex/16851] re_node_set_alloc should not return REG_ESPACE when size == 0
  2014-04-17 22:19 [Bug regex/16851] New: re_node_set_alloc should not return REG_ESPACE when size == 0 nkennedy at grammatech dot com
@ 2014-04-18  1:15 ` eggert at gnu dot org
  2014-04-18 14:37 ` nkennedy at grammatech dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: eggert at gnu dot org @ 2014-04-18  1:15 UTC (permalink / raw)
  To: glibc-bugs-regex

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

--- Comment #1 from Paul Eggert <eggert at gnu dot org> ---
Sorry, you've lost me on this one.  Which standard?  The C standard does not
let an application supply its own malloc function.  See C11 section 7.1.3. 
With glibc I suppose you can get away with it, but only if the application's
malloc is compatible with glibc's.

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug regex/16851] re_node_set_alloc should not return REG_ESPACE when size == 0
  2014-04-17 22:19 [Bug regex/16851] New: re_node_set_alloc should not return REG_ESPACE when size == 0 nkennedy at grammatech dot com
  2014-04-18  1:15 ` [Bug regex/16851] " eggert at gnu dot org
@ 2014-04-18 14:37 ` nkennedy at grammatech dot com
  2014-04-18 14:56 ` eggert at gnu dot org
  2014-06-12 19:40 ` fweimer at redhat dot com
  3 siblings, 0 replies; 5+ messages in thread
From: nkennedy at grammatech dot com @ 2014-04-18 14:37 UTC (permalink / raw)
  To: glibc-bugs-regex

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

--- Comment #2 from Nathan Kennedy <nkennedy at grammatech dot com> ---
re_node_set_alloc's use of malloc is not portable in that it needlessly relies
on current glibc malloc behavior not specified in any C standard for malloc;
the return value of malloc(0). Which works when it's using glibc malloc as is,
but makes the code nonportable, such as in the two downstream projects (gnulib
and uClibc).

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug regex/16851] re_node_set_alloc should not return REG_ESPACE when size == 0
  2014-04-17 22:19 [Bug regex/16851] New: re_node_set_alloc should not return REG_ESPACE when size == 0 nkennedy at grammatech dot com
  2014-04-18  1:15 ` [Bug regex/16851] " eggert at gnu dot org
  2014-04-18 14:37 ` nkennedy at grammatech dot com
@ 2014-04-18 14:56 ` eggert at gnu dot org
  2014-06-12 19:40 ` fweimer at redhat dot com
  3 siblings, 0 replies; 5+ messages in thread
From: eggert at gnu dot org @ 2014-04-18 14:56 UTC (permalink / raw)
  To: glibc-bugs-regex

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

--- Comment #3 from Paul Eggert <eggert at gnu dot org> ---
(In reply to Nathan Kennedy from comment #2)
> re_node_set_alloc's use of malloc is not portable in that it needlessly
> relies on current glibc malloc behavior not specified in any C standard

Sure, but this is glibc.  Glibc is allowed to rely on its own behavior, even if
that behavior is not specified in the C standard.

> such as in the two downstream projects (gnulib and uClibc).

It's not a bug in gnulib, because of its use of MALLOC_0_IS_NONNULL.  If
there's a uClibc bug, they can fix it there.  At some point, we may unify
gnulib regex and glibc regex, and and that point we'll deal with this, but in
the meantime there is no bug here.

The simplest fix for the uClibc issue may be to modify uClibc so that its
malloc is compatible with glibc.  Yes, the C standard alllows uClibc's
gratuitous incompability with glibc, but it's not good software engineering
practice.  But this is not the correct forum to discuss uClibc issues.

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug regex/16851] re_node_set_alloc should not return REG_ESPACE when size == 0
  2014-04-17 22:19 [Bug regex/16851] New: re_node_set_alloc should not return REG_ESPACE when size == 0 nkennedy at grammatech dot com
                   ` (2 preceding siblings ...)
  2014-04-18 14:56 ` eggert at gnu dot org
@ 2014-06-12 19:40 ` fweimer at redhat dot com
  3 siblings, 0 replies; 5+ messages in thread
From: fweimer at redhat dot com @ 2014-06-12 19:40 UTC (permalink / raw)
  To: glibc-bugs-regex

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

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fweimer at redhat dot com
              Flags|                            |security-

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-06-12 19:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-17 22:19 [Bug regex/16851] New: re_node_set_alloc should not return REG_ESPACE when size == 0 nkennedy at grammatech dot com
2014-04-18  1:15 ` [Bug regex/16851] " eggert at gnu dot org
2014-04-18 14:37 ` nkennedy at grammatech dot com
2014-04-18 14:56 ` eggert at gnu dot org
2014-06-12 19:40 ` fweimer at redhat dot com

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).