C++ iostream only working in Init, not in other RTEMS Tasks

Sebastian Huber sebastian.huber at embedded-brains.de
Wed May 3 05:46:30 UTC 2017


On 03/05/17 07:15, Sebastian Huber wrote:
> On 03/05/17 00:47, Chris Johns wrote:
>> On 2/5/17 6:03 pm, Sebastian Huber wrote:
>>> On 02/05/17 09:35, Chris Coppens wrote:
>>>> Hello,
>>>>
>>>> In our RTEMS application C++ iostream (e.g. "cout") is only working in
>>>> the “Init” function?
>>>> If I use “cout” in a RTEMS Task other than Init, no output is shown in
>>>> the console.
>>>> Any idea why this is happening?
>>> The C++ library uses thread-local standard IO streams (Newlib feature)
>>> for the global IO stream objects. I am not sure how to fix this
>>> properly, but I guess a RTEMS-specific change in the libstdc++ would be
>>> necessary.
>>>
>> Does a ticket exist for this? This should be fixed for 4.12.0 so please
>> set the milestone to 4.12.0 and blocker.
>
> I don't know if a ticket exists. This issue exits in all RTEMS 
> versions with C++ support. Since the initialization thread is 
> restarted after the C++ global constructor calls this issue is more 
> obvious now.
>
> Before you make this a release blocker, then please find someone who 
> can fix this.
>

Just for reference. The std::cout etc. is initialized here

https://gcc.gnu.org/viewcvs/gcc/trunk/libstdc%2B%2B-v3/src/c%2B%2B98/ios_init.cc?view=markup#l85

via a placement new. The "stdout" etc. is thread-local in Newlib. Using 
this for a global object like std::cout is quite broken.

-- 
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 at embedded-brains.de
PGP     : Public key available on request.

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




More information about the users mailing list