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

Ralf Corsepius ralf.corsepius at rtems.org
Tue Nov 21 16:31:44 UTC 2006


On Tue, 2006-11-21 at 17:16 +0100, Thomas Doerfler wrote:
> Ralf,
> 
> 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);
>        return;
> 
> 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.
Right, ... that's why I have been asking Peer and you to prove an
example really exposing issue.

I am having difficulties in seeing what should be broken with this code.
But I see suspicious spots in chain.inl.

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

Ralf





More information about the users mailing list