public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* target/5469: ia64 arc profiling can use the wrong global pointer
@ 2002-01-23 10:36 janis187
  0 siblings, 0 replies; 2+ messages in thread
From: janis187 @ 2002-01-23 10:36 UTC (permalink / raw)
  To: gcc-gnats


>Number:         5469
>Category:       target
>Synopsis:       ia64 arc profiling can use the wrong global pointer
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Wed Jan 23 10:36:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Janis Johnson
>Release:        gcc version 3.1 20020122 (experimental)
>Organization:
>Environment:
ia64-unknown-linux-gnu
>Description:
Arc profiling on ia64 inserts profiling code between a call
and the restore of the global pointer, but the profiling
code uses the global pointer to address the arc count.  If
the call was to a function in a shared library then it uses
the wrong global pointer.  If the user is lucky this will
cause the profiled program to abort; otherwise it might
increment data used by the shared library.

This bug causes the failure of gcc.misc-tests/gcov-7.c for
ia64.  That test uses setjump and longjmp, but the test case
provided here uses C library functions rand and srand and is
much simpler.
>How-To-Repeat:
Compile the test case on ia64-linux with -fprofile-arcs
and execute it.  Examine generated assembly code to see
that the restore of the GP after calls to libc functions
is done after the GP is used to reference the profile
counts.
>Fix:
Unknown.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="bug.c"
Content-Disposition: inline; filename="bug.c"

/* Check that arc profiling restores the global pointer before using it
   to get the address of a count.  The test calls srand and rand, C library
   functions, assuming that they will be in a shared C library.  The bug
   only affected targets that address all global data using the GP and
   require the caller to save and restore the GP value, including IA-64.  */

/* { dg-options "-fprofile-arcs" } */
/* { dg-do run { target native } } */

int rand (void);
void srand (unsigned int seed);

int globvar;

void
leave (int i)
{
  if (i != 0)
    abort ();
  exit (0);
}

void
doit ()
{
  srand (12);
  globvar = rand ();
  if (rand () > 0)
    globvar = 0;
  leave (globvar);
}

int
main ()
{
  doit ();
}


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

* Re: target/5469: ia64 arc profiling can use the wrong global pointer
@ 2002-02-01 11:16 Janis Johnson
  0 siblings, 0 replies; 2+ messages in thread
From: Janis Johnson @ 2002-02-01 11:16 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR target/5469; it has been noted by GNATS.

From: Janis Johnson <janis187@us.ibm.com>
To: janis187@us.ibm.com
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: target/5469: ia64 arc profiling can use the wrong global pointer
Date: Fri, 1 Feb 2002 11:12:02 -0800

 This problem is fixed by the following patch:
 http://gcc.gnu.org/ml/gcc-patches/2002-02/msg00022.html


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

end of thread, other threads:[~2002-02-01 19:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-23 10:36 target/5469: ia64 arc profiling can use the wrong global pointer janis187
2002-02-01 11:16 Janis Johnson

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).