This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Asan constructor init order checking
- From: Dodji Seketeli <dodji at redhat dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Konstantin Serebryany <konstantin dot s dot serebryany at gmail dot com>, gcc-patches at gcc dot gnu dot org
- Date: Fri, 22 Nov 2013 17:15:06 +0100
- Subject: Re: [PATCH] Asan constructor init order checking
- Authentication-results: sourceware.org; auth=none
- References: <20131115135845 dot GE892 at tucnak dot redhat dot com> <87li0gh2el dot fsf at redhat dot com> <20131122155346 dot GE892 at tucnak dot redhat dot com>
Jakub Jelinek <jakub@redhat.com> writes:
> On Fri, Nov 22, 2013 at 04:38:58PM +0100, Dodji Seketeli wrote:
>> Jakub Jelinek <jakub@redhat.com> writes:
>>
>> > --- gcc/cgraph.h.jj 2013-11-13 18:32:52.000000000 +0100
>> > +++ gcc/cgraph.h 2013-11-15 12:05:25.950985500 +0100
>> > @@ -520,6 +520,11 @@ class GTY((tag ("SYMTAB_VARIABLE"))) var
>> > public:
>> > /* Set when variable is scheduled to be assembled. */
>> > unsigned output : 1;
>> > + /* Set if the variable is dynamically initialized. Not set for
>> > + function local statics or variables that can be initialized in
>> > + multiple compilation units (such as template static data members
>> > + that need construction). */
>> > + unsigned asan_dynamically_initialized : 1;
>> > };
>>
>> Maybe this could just be called dynamically_initialized? It's just used
>> by asan today, but it looks like an information that could be used more
>> generally, independently from asan.
>
> I used that name initially, but then changed it, because it actually is
> quite asan specific. E.g. template static data members are dynamically
> initialized, but we intentionally don't set asan_dynamically_initialized
> on those, because their initializer can be called from multiple CUs, there
> is no CU that owns the variable.
I see. OK, I don't feel strongly about this anyway. Thanks for the
clarification.
>
>> > /* If we're using __cxa_atexit, register a function that calls the
>> > destructor for the object. */
>> > @@ -3498,6 +3507,9 @@ do_static_initialization_or_destruction
>> > tf_warning_or_error);
>> > finish_if_stmt_cond (cond, init_if_stmt);
>> >
>> > + if (flag_sanitize & SANITIZE_ADDRESS)
>> > + finish_expr_stmt (asan_dynamic_init_call (/*after_p=*/false));
>> > +
>
> Will add the comments.
>
>> Also, do we have some tests for this? I am not sure how I'd write
>> multi-tu dejagnu tests for this myself though ;-)
>
> I've postponed tests for stage3, when I find spare time I'll try to
> port libsanitizer tests that are applicable to gcc over to dejagnu,
> plus perhaps add new tests as needed.
OK, thanks.
The patch is OK to commit, as far as I am concerned.
Thanks.
--
Dodji