RTEMS5 _REENT

Ian Caddy ianc at goanna.iinet.net.au
Wed Nov 7 06:26:40 UTC 2018


Hi All,

We are migrating a product from RTEMS4.10 to RTEMS5, and I have come up 
with a problem that we have not experienced previously.

We have some code that works before RTEMS mulit-tasking has been started.

This code uses some string functions which are causing the system to 
crash (bus error out), and I have worked it out to a call to:

_REENT

One example function is:

snprintf

using the newlib 3.0.0 the first few lines of the function are:

int
snprintf (char *__restrict str,
        size_t size,
        const char *__restrict fmt, ...)
{
   int ret;
   va_list ap;
   FILE f;
   struct _reent *ptr = _REENT;

The _REENT macro ends up calling:

cpukit/include/rtems/confdefs.h:2273 __getreent

which ends up returning the thread executing structure:

  return _Thread_Get_executing()->libc_reent;

Since this is before multi-tasking, _Thread_Get_executing() returns 
NULL, and this is not valid memory.

So, if I want to support this, do I need to configure:

#define CONFIGURE_DISABLE_NEWLIB_REENTRANCY

If I do this will it effect things later?

Or should this be fixed to check whether multi-tasking is running before 
checking the currently running thread, we do this in some of our other code?

regards,

Ian Caddy

Goanna Technologies Pty Ltd



More information about the users mailing list