[continuation args 2/2] Make continuation args not leak

Pedro Alves pedro@codesourcery.com
Sat Jul 12 22:53:00 GMT 2008


A Saturday 12 July 2008 21:23:41, Ulrich Weigand wrote:
> Pedro Alves wrote:
> > 	Rewrite continuations internals on top of cleanups and plug
> > 	continuation arguments leaks.
>
> This breaks the build due to violation of the C aliasing rules:
>
> /home/uweigand/fsf/gdb-head/gdb/utils.c: In function 'add_continuation':
> /home/uweigand/fsf/gdb-head/gdb/utils.c:479: warning: dereferencing
> type-punned pointer will break strict-aliasing rules
...

>
> > +  struct cleanup **as_cleanup_p = (struct cleanup **) &cmd_continuation;
>
> This may cause a "struct cleanup *" to alias with a "struct continuation
> *", which is not allowed according to the C standard.
>

Sorry for that.  Missed building at > -O0 to catch these things.

I thought that since the type is not defined, this would not
be a problem, as you can't dereference through cmd_continuation.

> Why do we still have a "struct continuation" (as nowhere-defined type)?
> Shouldn't this just use "struct cleanup" throughout?

Being a cleanup is an implementation detail, I didn't want to make
that fact public.

This fixes the issue for me by making the inheritance explicit.

Tested on x86_64-unknown-linux-gnu async mode.

OK?

-- 
Pedro Alves
-------------- next part --------------
A non-text attachment was scrubbed...
Name: continuations_alias.diff
Type: text/x-diff
Size: 3897 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20080712/7be7a6a0/attachment.bin>


More information about the Gdb-patches mailing list