public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/24830]  New: Duplicate constructors with -fmudflap
@ 2005-11-13  4:05 dgraham at nortel dot com
  2005-11-13 16:20 ` [Bug c/24830] " pinskia at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: dgraham at nortel dot com @ 2005-11-13  4:05 UTC (permalink / raw)
  To: gcc-bugs

The only way I know how to reproduce this is with -fmudflap, but
that's only because *C* code doesn't normally generate constructors.

With -fmudflap, each of the mudflap constructors are run twice.  An objdump
run on the object files shows two ctor sections, one named ".ctor" and
one named ".ctor.65436".  default_named_section_asm_out_constructor() is
being called twice from cgraph_build_static_cdtor(), once directly, and
once indirectly.  The first (indirect) call is here:

#0  default_named_section_asm_out_constructor (symbol=0xb7a5a660,
priority=65535)
    at ../../gcc-4.0.2.bounds/gcc/varasm.c:1133
#1  0x0805b237 in c_expand_body (fndecl=0xb7a45dec)
    at ../../gcc-4.0.2.bounds/gcc/c-decl.c:6634
#2  0x0832f012 in cgraph_expand_function (node=0xb7a45f30)
    at ../../gcc-4.0.2.bounds/gcc/cgraphunit.c:835
#3  0x0832f0f5 in cgraph_assemble_pending_functions ()
    at ../../gcc-4.0.2.bounds/gcc/cgraphunit.c:307
#4  0x0832f78a in cgraph_finalize_function (decl=0xb7a45dec, nested=0 '\0')
    at ../../gcc-4.0.2.bounds/gcc/cgraphunit.c:399
#5  0x083309ae in cgraph_build_static_cdtor (which=73 'I', body=0xb7a5a660,
priority=99)
    at ../../gcc-4.0.2.bounds/gcc/cgraphunit.c:1901
#6  0x080941a2 in mudflap_finish_file () at
../../gcc-4.0.2.bounds/gcc/tree-mudflap.c:1374
#7  0x082eea55 in toplev_main (argc=3081086560, argv=0xbfb75a84)
    at ../../gcc-4.0.2.bounds/gcc/toplev.c:1050

The second (direct) call is here:

#0  default_named_section_asm_out_constructor (symbol=0xb7a5a660, priority=99)
    at ../../gcc-4.0.2.bounds/gcc/varasm.c:1133
#1  0x08330997 in cgraph_build_static_cdtor (which=73 'I', body=0xb7a5a660,
priority=99)
    at ../../gcc-4.0.2.bounds/gcc/cgraphunit.c:1911
#2  0x080941a2 in mudflap_finish_file () at
../../gcc-4.0.2.bounds/gcc/tree-mudflap.c:1374
#3  0x082eea55 in toplev_main (argc=3081086560, argv=0xbfb75a84)
    at ../../gcc-4.0.2.bounds/gcc/toplev.c:1050

The first call looks wrong, as it is not being passed the correct
priority.

--Doug.


-- 
           Summary: Duplicate constructors with -fmudflap
           Product: gcc
           Version: 4.0.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dgraham at nortel dot com
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24830


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

* [Bug c/24830] Duplicate constructors with -fmudflap
  2005-11-13  4:05 [Bug c/24830] New: Duplicate constructors with -fmudflap dgraham at nortel dot com
@ 2005-11-13 16:20 ` pinskia at gcc dot gnu dot org
  2005-11-13 20:17 ` dgraham at nortel dot com
  2005-12-05  3:03 ` [Bug libmudflap/24830] " pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-13 16:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2005-11-13 16:20 -------
Do you have an example source?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24830


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

* [Bug c/24830] Duplicate constructors with -fmudflap
  2005-11-13  4:05 [Bug c/24830] New: Duplicate constructors with -fmudflap dgraham at nortel dot com
  2005-11-13 16:20 ` [Bug c/24830] " pinskia at gcc dot gnu dot org
@ 2005-11-13 20:17 ` dgraham at nortel dot com
  2005-12-05  3:03 ` [Bug libmudflap/24830] " pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: dgraham at nortel dot com @ 2005-11-13 20:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from dgraham at nortel dot com  2005-11-13 20:17 -------
Subject: Re:  Duplicate constructors with -fmudflap

On Sun, Nov 13, 2005 at 04:20:06PM -0000, pinskia at gcc dot gnu dot org wrote:
> 
> ------- Comment #1 from pinskia at gcc dot gnu dot org  2005-11-13 16:20 -------
> Do you have an example source?

Sure:

-------- begin foo.c ---------
static int foo;

int main(int argc, char **argv)
{
        printf("%d\n", foo);
}
-------- end foo.c ---------

Compile with "gcc -g -fmudflap foo.c -lmudflap".

Put a breakpoint on _GLOBAL__I_0_main.  It will be hit twice.

I forgot to mention that I'm talking about static constructors only.

I don't think this is a serious problem for mudflap, except maybe for
its performance implications (all static data gets registered twice),
but there may be other uses of constructors in C where having those
constructors called twice would be a serious problem.

--Doug.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24830


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

* [Bug libmudflap/24830] Duplicate constructors with -fmudflap
  2005-11-13  4:05 [Bug c/24830] New: Duplicate constructors with -fmudflap dgraham at nortel dot com
  2005-11-13 16:20 ` [Bug c/24830] " pinskia at gcc dot gnu dot org
  2005-11-13 20:17 ` dgraham at nortel dot com
@ 2005-12-05  3:03 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-12-05  3:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2005-12-05 03:03 -------
Confirmed:
        .size   _GLOBAL__I_0_main, .-_GLOBAL__I_0_main
        .section        .ctors,"aw",@progbits
        .align 4
        .long   _GLOBAL__I_0_main
        .section        .ctors.65436,"aw",@progbits
        .align 4


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
          Component|c                           |libmudflap
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2005-12-05 03:03:51
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24830


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

end of thread, other threads:[~2005-12-05  3:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-13  4:05 [Bug c/24830] New: Duplicate constructors with -fmudflap dgraham at nortel dot com
2005-11-13 16:20 ` [Bug c/24830] " pinskia at gcc dot gnu dot org
2005-11-13 20:17 ` dgraham at nortel dot com
2005-12-05  3:03 ` [Bug libmudflap/24830] " pinskia at gcc dot gnu dot 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).