public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug sanitizer/64330] New: [ASAN] Bogus "AddressSanitizer: odr-violation"
@ 2014-12-16 12:34 burnus at gcc dot gnu.org
  2014-12-16 12:45 ` [Bug sanitizer/64330] " trippels at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: burnus at gcc dot gnu.org @ 2014-12-16 12:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64330

            Bug ID: 64330
           Summary: [ASAN] Bogus "AddressSanitizer: odr-violation"
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: sanitizer
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
                CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
                    jakub at gcc dot gnu.org, kcc at gcc dot gnu.org,
                    mpolacek at gcc dot gnu.org

I have in a C++ header file ("foo.h"):

class Foo {
 public:
  static const unsigned short   AlignRight;
  static const unsigned short   AlignBottom;
  ...
};

And in its C++ file (foo.cc):

const unsigned short    Foo::AlignRight = 2;
const unsigned short    Foo::AlignTop  = 1;
const unsigned short    Foo::AlignBottom = 2;


I fail to see a reason why that's a violation of the One Definition Rule (ORD),
but ASAN fails with:

==9056==ERROR: AddressSanitizer: odr-violation (0x000004b4dbc0):
  [1] size=2 'AlignRight' foo.cc:23:22
  [2] size=2 'AlignBottom' foo.cc:25:22
These globals were registered at these points:
  [1]:
    #0 0x4daa56 in __asan_register_globals
../../../../libsanitizer/asan/asan_globals.cc:217
    #1 0x4b0c6ac in __libc_csu_init (foo+0x4b0c6ac)
    #2 0x3761c1ecef in __libc_start_main (/lib64/libc.so.6+0x3761c1ecef)


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug sanitizer/64330] [ASAN] Bogus "AddressSanitizer: odr-violation"
  2014-12-16 12:34 [Bug sanitizer/64330] New: [ASAN] Bogus "AddressSanitizer: odr-violation" burnus at gcc dot gnu.org
@ 2014-12-16 12:45 ` trippels at gcc dot gnu.org
  2014-12-16 13:43 ` jakub at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: trippels at gcc dot gnu.org @ 2014-12-16 12:45 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64330

Markus Trippelsdorf <trippels at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |trippels at gcc dot gnu.org

--- Comment #1 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
Looks like a dup of PR63888.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug sanitizer/64330] [ASAN] Bogus "AddressSanitizer: odr-violation"
  2014-12-16 12:34 [Bug sanitizer/64330] New: [ASAN] Bogus "AddressSanitizer: odr-violation" burnus at gcc dot gnu.org
  2014-12-16 12:45 ` [Bug sanitizer/64330] " trippels at gcc dot gnu.org
@ 2014-12-16 13:43 ` jakub at gcc dot gnu.org
  2014-12-16 14:02 ` [Bug tree-optimization/64330] [5 Regression] IPA-ICF merges const exported vars that could be addressable in other TUs jakub at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-12-16 13:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64330

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org,
                   |                            |marxin at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
It is related, but in this case it looks like IPA-ICF bug to me, unless the C++
standard allows what G++ does since r216305.

struct S
{
  static const unsigned short a;
  static const unsigned short b;
  static const unsigned short c;
};

#ifdef A
const unsigned short S::a = 2;
const unsigned short S::b = 1;
const unsigned short S::c = 2;
#endif

#ifdef B
int
main ()
{
  if (&S::a == &S::c)
    __builtin_abort ();
}
#endif

With g++ -O2 -o test test.C -DA -DB it succeeds, but with
g++ -O2 -c test.C -o testa.o -DA; g++ -O2 -o test -DB test.C testa.o
it fails.  Works with -fno-ipa-icf.  Without looking at the IPA-ICF patch, just
looking at what it generates, it sounds like it is checking TREE_ADDRESSABLE on
the variables and if they aren't addressable and are const, merges them.  That
is fine if you are in LTO and can see all TUs that could ever access those
vars, but if you can't inspect all the TUs that could take the address of it,
as in the second case, but it could very well be even LTO compiled binary that
links against a shared library that references those symbols, I think you can't
merge the variables (unless -fmerge-all-constants).


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug tree-optimization/64330] [5 Regression] IPA-ICF merges const exported vars that could be addressable in other TUs
  2014-12-16 12:34 [Bug sanitizer/64330] New: [ASAN] Bogus "AddressSanitizer: odr-violation" burnus at gcc dot gnu.org
  2014-12-16 12:45 ` [Bug sanitizer/64330] " trippels at gcc dot gnu.org
  2014-12-16 13:43 ` jakub at gcc dot gnu.org
@ 2014-12-16 14:02 ` jakub at gcc dot gnu.org
  2014-12-16 18:01 ` kcc at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-12-16 14:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64330

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-12-16
          Component|sanitizer                   |tree-optimization
   Target Milestone|---                         |5.0
            Summary|[ASAN] Bogus                |[5 Regression] IPA-ICF
                   |"AddressSanitizer:          |merges const exported vars
                   |odr-violation"              |that could be addressable
                   |                            |in other TUs
     Ever confirmed|0                           |1

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
sem_variable *
sem_variable::parse (varpool_node *node, bitmap_obstack *stack)
{
  tree decl = node->decl;

  bool readonly = TYPE_P (decl) ? TYPE_READONLY (decl) : TREE_READONLY (decl);
  bool can_handle = readonly && (DECL_VIRTUAL_P (decl)
                                 || !TREE_ADDRESSABLE (decl));

So it indeed doesn't consider the case when the variable is accessible by other
TUs where the variable could be addressable in them.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug tree-optimization/64330] [5 Regression] IPA-ICF merges const exported vars that could be addressable in other TUs
  2014-12-16 12:34 [Bug sanitizer/64330] New: [ASAN] Bogus "AddressSanitizer: odr-violation" burnus at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2014-12-16 14:02 ` [Bug tree-optimization/64330] [5 Regression] IPA-ICF merges const exported vars that could be addressable in other TUs jakub at gcc dot gnu.org
@ 2014-12-16 18:01 ` kcc at gcc dot gnu.org
  2014-12-16 18:09 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: kcc at gcc dot gnu.org @ 2014-12-16 18:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64330

--- Comment #4 from Kostya Serebryany <kcc at gcc dot gnu.org> ---
So, maybe the ODR checker in the current form is not that useless.
Sorry, couldn't resist :)


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug tree-optimization/64330] [5 Regression] IPA-ICF merges const exported vars that could be addressable in other TUs
  2014-12-16 12:34 [Bug sanitizer/64330] New: [ASAN] Bogus "AddressSanitizer: odr-violation" burnus at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2014-12-16 18:01 ` kcc at gcc dot gnu.org
@ 2014-12-16 18:09 ` jakub at gcc dot gnu.org
  2014-12-17 14:30 ` y.gribov at samsung dot com
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-12-16 18:09 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64330

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Kostya Serebryany from comment #4)
> So, maybe the ODR checker in the current form is not that useless.
> Sorry, couldn't resist :)

But it isn't really an ODR checker.  Here it complains if two different symbols
share the same storage.  Which is fine if they aren't address taken and can't
be address taken elsewhere.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug tree-optimization/64330] [5 Regression] IPA-ICF merges const exported vars that could be addressable in other TUs
  2014-12-16 12:34 [Bug sanitizer/64330] New: [ASAN] Bogus "AddressSanitizer: odr-violation" burnus at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2014-12-16 18:09 ` jakub at gcc dot gnu.org
@ 2014-12-17 14:30 ` y.gribov at samsung dot com
  2014-12-17 16:49 ` hubicka at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: y.gribov at samsung dot com @ 2014-12-17 14:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64330

Yury Gribov <y.gribov at samsung dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |y.gribov at samsung dot com

--- Comment #6 from Yury Gribov <y.gribov at samsung dot com> ---
(In reply to Jakub Jelinek from comment #5)
> (In reply to Kostya Serebryany from comment #4)
> > So, maybe the ODR checker in the current form is not that useless.
> > Sorry, couldn't resist :)
> 
> But it isn't really an ODR checker.

Basically a symbol aliasing checker.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug tree-optimization/64330] [5 Regression] IPA-ICF merges const exported vars that could be addressable in other TUs
  2014-12-16 12:34 [Bug sanitizer/64330] New: [ASAN] Bogus "AddressSanitizer: odr-violation" burnus at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2014-12-17 14:30 ` y.gribov at samsung dot com
@ 2014-12-17 16:49 ` hubicka at gcc dot gnu.org
  2014-12-17 19:08 ` hubicka at ucw dot cz
  2014-12-18 13:32 ` marxin at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: hubicka at gcc dot gnu.org @ 2014-12-17 16:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64330

Jan Hubicka <hubicka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hubicka at gcc dot gnu.org

--- Comment #7 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
I think the test should be something like
 VIRTUAL || -fmerge-all-constants || (!TREE_ADDRESSABLE && !
externally_visible)

te current code seems to miss the externally_visible flag.  Indeed you can not
merge symbols that may have address taken.

How does asan behave with aliases?

Honza


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug tree-optimization/64330] [5 Regression] IPA-ICF merges const exported vars that could be addressable in other TUs
  2014-12-16 12:34 [Bug sanitizer/64330] New: [ASAN] Bogus "AddressSanitizer: odr-violation" burnus at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2014-12-17 16:49 ` hubicka at gcc dot gnu.org
@ 2014-12-17 19:08 ` hubicka at ucw dot cz
  2014-12-18 13:32 ` marxin at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: hubicka at ucw dot cz @ 2014-12-17 19:08 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64330

--- Comment #9 from Jan Hubicka <hubicka at ucw dot cz> ---
> Thank you for the missing externally visible attribute.
> 
> I've been testing following patch:
> 
> diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
> index b193200..0685019 100644
> --- a/gcc/ipa-icf.c
> +++ b/gcc/ipa-icf.c
> @@ -1131,8 +1131,12 @@ sem_variable::parse (varpool_node *node, bitmap_obstack
> *stack)
>    tree decl = node->decl;
> 
>    bool readonly = TYPE_P (decl) ? TYPE_READONLY (decl) : TREE_READONLY (decl);
> -  bool can_handle = readonly && (DECL_VIRTUAL_P (decl)
> -                                || !TREE_ADDRESSABLE (decl));
> +  if (!readonly)
> +    return NULL;
> +
> +  bool can_handle = DECL_VIRTUAL_P (decl)
> +                   || flag_merge_constants >= 2
> +                   || (!TREE_ADDRESSABLE (decl) && !node->externally_visible);
> 
>    if (!can_handle)
>      return NULL;
> 
> As soon as tests finish, I will send it to ML.

Thanks, the patch is OK if it passes.
Also please be sure that we won't merge DECL_EXTERNAL at all.  Producing an
extenral
alias is not going to save any code.

Honza
> 
> Martin
> 
> -- 
> You are receiving this mail because:
> You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug tree-optimization/64330] [5 Regression] IPA-ICF merges const exported vars that could be addressable in other TUs
  2014-12-16 12:34 [Bug sanitizer/64330] New: [ASAN] Bogus "AddressSanitizer: odr-violation" burnus at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2014-12-17 19:08 ` hubicka at ucw dot cz
@ 2014-12-18 13:32 ` marxin at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: marxin at gcc dot gnu.org @ 2014-12-18 13:32 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64330

--- Comment #10 from Martin Liška <marxin at gcc dot gnu.org> ---
Author: marxin
Date: Thu Dec 18 13:32:18 2014
New Revision: 218864

URL: https://gcc.gnu.org/viewcvs?rev=218864&root=gcc&view=rev
Log:
Fix for PR64330.

    PR tree-optimization/64330
    * ipa-icf.c (sem_variable::parse): Add checking
    for externally visible symbols and do not introduce
    an alias for an external declaration.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/ipa-icf.c
>From gcc-bugs-return-471076-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Dec 18 13:33:17 2014
Return-Path: <gcc-bugs-return-471076-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 12238 invoked by alias); 18 Dec 2014 13:33:17 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 12077 invoked by uid 48); 18 Dec 2014 13:33:11 -0000
From: "marxin at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/64330] [5 Regression] IPA-ICF merges const exported vars that could be addressable in other TUs
Date: Thu, 18 Dec 2014 13:33:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: tree-optimization
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords: diagnostic
X-Bugzilla-Severity: normal
X-Bugzilla-Who: marxin at gcc dot gnu.org
X-Bugzilla-Status: RESOLVED
X-Bugzilla-Priority: P1
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 5.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status resolution
Message-ID: <bug-64330-4-5LS1d55MMU@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-64330-4@http.gcc.gnu.org/bugzilla/>
References: <bug-64330-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-12/txt/msg02083.txt.bz2
Content-length: 443

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64330

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #11 from Martin Liška <marxin at gcc dot gnu.org> ---
Fixed in 5.0.0.
>From gcc-bugs-return-471077-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Dec 18 14:11:48 2014
Return-Path: <gcc-bugs-return-471077-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 5903 invoked by alias); 18 Dec 2014 14:11:47 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 5863 invoked by uid 48); 18 Dec 2014 14:11:41 -0000
From: "ville.voutilainen at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/58972] Lambda can't access private members
Date: Thu, 18 Dec 2014 14:11:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: ville.voutilainen at gmail dot com
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: ville.voutilainen at gmail dot com
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-58972-4-qipI5yxoSk@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-58972-4@http.gcc.gnu.org/bugzilla/>
References: <bug-58972-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-12/txt/msg02084.txt.bz2
Content-length: 378

https://gcc.gnu.org/bugzilla/show_bug.cgi?idX972

--- Comment #11 from Ville Voutilainen <ville.voutilainen at gmail dot com> ---
Reduced further:

class base
{
protected:
  typedef int type;
};


template <typename T>
class derive: public base
{
public:
  void foo()
  {
    struct f_t {
      f_t(base::type a) {}
    };
  }
};

int main()
{
  derive<char> d;
  d.foo();
}


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-12-18 13:32 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-16 12:34 [Bug sanitizer/64330] New: [ASAN] Bogus "AddressSanitizer: odr-violation" burnus at gcc dot gnu.org
2014-12-16 12:45 ` [Bug sanitizer/64330] " trippels at gcc dot gnu.org
2014-12-16 13:43 ` jakub at gcc dot gnu.org
2014-12-16 14:02 ` [Bug tree-optimization/64330] [5 Regression] IPA-ICF merges const exported vars that could be addressable in other TUs jakub at gcc dot gnu.org
2014-12-16 18:01 ` kcc at gcc dot gnu.org
2014-12-16 18:09 ` jakub at gcc dot gnu.org
2014-12-17 14:30 ` y.gribov at samsung dot com
2014-12-17 16:49 ` hubicka at gcc dot gnu.org
2014-12-17 19:08 ` hubicka at ucw dot cz
2014-12-18 13:32 ` marxin at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).