| Message ID | CAPmKWpH7x5QVTnehjOTx9SnZD0HqQ5zA=t8BuCmeQK2JPfft=Q@mail.gmail.com |
|---|---|
| State | Accepted |
| Headers | show |
Hi Eugene, Eugene Yudin wrote, > Hi, > > Current uClibc-ng have issue with several different valloc declarations. > > malloc.h: > #ifdef __UCLIBC_SUSV2_LEGACY__ > /* Allocate SIZE bytes on a page boundary. */ > extern __malloc_ptr_t valloc __MALLOC_P ((size_t __size)) __attribute_malloc__; > #endif > > stdlib.h: > #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED > /* Allocate SIZE bytes on a page boundary. The storage cannot be freed. */ > extern void *valloc (size_t __size) __THROW __attribute_malloc__ __wur; > #endif > > The second declaration doesn't use the define __UCLIBC_SUSV2_LEGACY__. > That leads to compile time problems. Can you explain in which situations this leads to compile time problems? best regards Waldemar
Sorry. I made a typo. Of course It's a runtime error.
Requirements:
* uClibc-ng with disabled option "Enable SuSv2 LEGACY functions"
(UCLIBC_SUSV2_LEGACY symbol).
Test progam:
$ cat test_valloc.c
#include <stdlib.h>
int main(int argc, char *argv[])
{
void *p;
p = valloc(1);
if (p == NULL)
return EXIT_FAILURE;
free(p);
return EXIT_SUCCESS;
}
The program above compiles without problems because of declaration in
"stdio.h", but it segfaults in runtime:
$ ./test_valloc
Segmentation fault
Definition of valloc also depends from UCLIBC_SUSV2_LEGACY
(libc/stdlib/Makefile.in):
CSRC-$(UCLIBC_SUSV2_LEGACY) += valloc.c
The patch transforms the issue to compile time error.
On Mon, Jul 24, 2017 at 11:29 PM, Waldemar Brodkorb <wbx@uclibc-ng.org>
wrote:
> Hi Eugene,
> Eugene Yudin wrote,
>
> > Hi,
> >
> > Current uClibc-ng have issue with several different valloc declarations.
> >
> > malloc.h:
> > #ifdef __UCLIBC_SUSV2_LEGACY__
> > /* Allocate SIZE bytes on a page boundary. */
> > extern __malloc_ptr_t valloc __MALLOC_P ((size_t __size))
> __attribute_malloc__;
> > #endif
> >
> > stdlib.h:
> > #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
> > /* Allocate SIZE bytes on a page boundary. The storage cannot be
> freed. */
> > extern void *valloc (size_t __size) __THROW __attribute_malloc__ __wur;
> > #endif
> >
> > The second declaration doesn't use the define __UCLIBC_SUSV2_LEGACY__.
> > That leads to compile time problems.
>
> Can you explain in which situations this leads to compile time
> problems?
>
> best regards
> Waldemar
>
Hi, Eugene Yudin wrote, > Sorry. I made a typo. Of course It's a runtime error. > > Requirements: > * uClibc-ng with disabled option "Enable SuSv2 LEGACY functions" > (UCLIBC_SUSV2_LEGACY symbol). Applied and pushed, Thanks Waldemar
commit 3990f36e0ba7177cb36effe24ef72dca04c762c0
Author: Eugene Yudin <e.yudin@ndmsystems.com>
Date: Wed May 4 14:56:57 2016 +0300
stdlib.h: Fix valloc declaration.
diff --git a/include/stdlib.h b/include/stdlib.h
index cbc0473..8947796 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -518,9 +518,11 @@ extern void cfree (void *__ptr) __THROW;
# include <alloca.h>
#endif /* Use GNU, BSD, or misc. */
-#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
+#ifdef __UCLIBC_SUSV2_LEGACY__
+# if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
/* Allocate SIZE bytes on a page boundary. The storage cannot be freed. */
extern void *valloc (size_t __size) __THROW __attribute_malloc__ __wur;
+# endif
#endif
#if defined __USE_XOPEN2K && defined __UCLIBC_HAS_ADVANCED_REALTIME__