This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: memory corruption problem




On 11/07/16 18:13, Wilkes, John wrote:
If _REENT_SMALL is defined, the __sinit(struct _reent *s) function sets s->stdout:

#ifndef _REENT_SMALL
   s->__sglue._niobs = 3;
   s->__sglue._iobs = &s->__sf[0];
#else
   s->__sglue._niobs = 0;
   s->__sglue._iobs = NULL;
   /* Avoid infinite recursion when calling __sfp  for _GLOBAL_REENT.  The
      problem is that __sfp checks for _GLOBAL_REENT->__sdidinit and calls
      __sinit if it's 0. */
   if (s == _GLOBAL_REENT)
     s->__sdidinit = 1;
   s->_stdin = __sfp(s);
   s->_stdout = __sfp(s);
   s->_stderr = __sfp(s);
#endif

   std (s->_stdin,  __SRD, 0, s);


If _REENT_SMALL is not defined, where is s->_stdout initialized before the call to __sinit()?

For RTEMS we use something like this:

https://git.rtems.org/rtems/tree/cpukit/libcsupport/src/newlibc_reent.c

--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber@embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]