Fwd: Problem report: Struct aliasing problem causes Thread_Ready_Chain corruption in

Thomas Doerfler Thomas.Doerfler at embedded-brains.de
Tue Nov 21 16:16:15 UTC 2006


Ralf Corsepius schrieb:
> On Tue, 2006-11-21 at 16:38 +0100, Thomas Doerfler wrote:
>> Therefore your patch in malloc.c is IMHO identical to the previous
>> explicit cast.
> Please prove Joel's patch to be broken.

maybe it is my limited horizon, but I don't see the difference applied
by the following patch:

   if (_System_state_Is_up(_System_state_Get())) {
     if ((_Thread_Dispatch_disable_level > 0) || (_ISR_Nest_level > 0)) {
-      Chain_Append(&RTEMS_Malloc_GC_list, (Chain_Node *)ptr);
+      Chain_Node *node = (Chain_Node *)ptr;
+      Chain_Append(&RTEMS_Malloc_GC_list, node);

The intermediate local variable "node" can easily be optimized by the
compiler. For the compiler, it should be obvious, that "node" is a
direct alias for "(Chain_Node *)ptr". So I don't see ANY reason, what
this additional variable would change in the compiler's behavior.

It MAY BE, that this change produces different code, but I don't see,
why the code should be more correct.


> Ralf

embedded brains GmbH
Thomas Doerfler           Obere Lagerstr. 30
D-82178 Puchheim          Germany
Tel. : +49-89-18 90 80 79-2
Fax  : +49-89-18 90 80 79-9
email: Thomas.Doerfler at embedded-brains.de
PGP public key available on request

More information about the users mailing list