"Issue" in termiosinitialize.c
Joel Sherrill <joel@OARcorp.com>
joel.sherrill at OARcorp.com
Sat Oct 16 12:49:14 UTC 2004
Till Straumann wrote:
> AFAIK, there is a lot of code that assumes
> uninitialized data (not malloc()ed) is zero
> at startup.
>
> It is definitely a bug not to zero bss, of course.
I believe the C language standard calls for the
invoking environment to clear the BSS.
Even before it was a requirement, many programs written for a UNIX
environment assumed that the BSS was zero. Moving them to a
target where the BSS is not zeroed would break them.
Eventually I would like to see RTEMS not have to assume the
workspace is initialized to zero initially but for now, it
also is assumed to be zero.
> -- Till
>
> Smith, Gene wrote:
>
>> This may or may not arise to the level of a bug. The problem was that
>> I had forgotten to zero out bss section at startup. The function
>>
>> cpukit/libcsupport/src/termiosinitialze.c
>>
>> defines a global variable that, in the same file, is assumed to be
>> zero at startup. Since uninitialized data was not zero'd the termios
>> init failed for me.
>>
>> If the variable rtems_termios_ttyMutex had been explicitly set to zero
>> when defined it would not have mattered if bss was zero'd.
>>
>> Bug or not a bug?
>>
>> Diff attached.
>>
>> -gene
>>
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>> --- termiosinitialize.c 2003-09-04 14:46:58.000000000 -0400
>> +++ termiosinitialize-fixed.c 2004-10-15 16:49:56.000000000 -0400
>> @@ -31,7 +31,7 @@
>>
>> struct rtems_termios_tty *rtems_termios_ttyHead;
>> struct rtems_termios_tty *rtems_termios_ttyTail;
>> -rtems_id rtems_termios_ttyMutex;
>> +rtems_id rtems_termios_ttyMutex = 0; /* assumed to be zero at startup */
>>
>> void
>> rtems_termios_initialize (void)
>>
>
>
--
Joel Sherrill, Ph.D. Director of Research & Development
joel at OARcorp.com On-Line Applications Research
Ask me about RTEMS: a free RTOS Huntsville AL 35805
Support Available (256) 722-9985
More information about the users
mailing list