public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dave at hiauly1 dot hia dot nrc dot ca" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/17044] [3.5 Regression] libgcc2.c:169: internal compiler error: Segmentation fault
Date: Tue, 17 Aug 2004 20:49:00 -0000	[thread overview]
Message-ID: <20040817204938.17313.qmail@sourceware.org> (raw)
In-Reply-To: <20040816015952.17044.danglin@gcc.gnu.org>


------- Additional Comments From dave at hiauly1 dot hia dot nrc dot ca  2004-08-17 20:49 -------
Subject: Re:  [3.5 Regression] libgcc2.c:169: internal c

> The exception occurs in the following call to free:
> 
> Breakpoint 13, 0x400000000031e350 in thread_block (bb=0x800003fffeacd8c0)
>     at ../../gcc/gcc/tree-ssa-threadupdate.c:381
> 381           free (rd);

Here is a possible fix.  VARRAY_GENERIC_PTR_INIT allocates with
garbage collection enabled.  The code as written was trying to
free the i=0 block allocated using ggc_alloc (i.e., mmap allocated).
This patch leaves collection to the garbage collector.

I will post to gcc-patches when testing completes.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)

2004-08-17  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>

	PR middle-end/17044
	* tree-ssa-threadupdate.c (redirection_data): Make static.
	(thread_block): Use ggc_alloc_cleared to allocate struct
	redirection_data.  Don't free elements in redirection_data.

Index: tree-ssa-threadupdate.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-threadupdate.c,v
retrieving revision 2.1
diff -u -3 -p -r2.1 tree-ssa-threadupdate.c
--- tree-ssa-threadupdate.c	9 Aug 2004 19:13:07 -0000	2.1
+++ tree-ssa-threadupdate.c	17 Aug 2004 20:15:35 -0000
@@ -92,6 +92,9 @@ struct redirection_data
   edge outgoing_edge;
 };
 
+/* Main data structure to hold information for duplicates of BB.  */
+static varray_type redirection_data;
+
 /* For each PHI node in BB, find or create a PHI node in NEW_BB for the
    same PHI_RESULT.  Add an argument to the PHI node in NEW_BB which
    corresponds to the same PHI argument associated with edge E in BB.  */
@@ -239,8 +242,6 @@ thread_block (basic_block bb)
      be threaded to a duplicate of BB.  */
   bool all = true;
 
-  /* Main data structure to hold information for duplicates of BB.  */
-  varray_type redirection_data;
   unsigned int i;
 
   VARRAY_GENERIC_PTR_INIT (redirection_data, 2, "redirection data");
@@ -278,7 +279,7 @@ thread_block (basic_block bb)
 	    {
 	      struct redirection_data *rd;
 
-	      rd = xcalloc (1, sizeof (redirection_data));
+	      rd = ggc_alloc_cleared (sizeof (struct redirection_data));
 	      rd->outgoing_edge = e->aux;
 	      VARRAY_PUSH_GENERIC_PTR (redirection_data, rd);
 	    }
@@ -372,14 +373,7 @@ thread_block (basic_block bb)
       remove_last_stmt_and_useless_edges (bb, rd->outgoing_edge->dest);
     }
 
-  /* Done with this block.  Free any memory we have allocated, clear
-     REDIRECTION_DATA and unmark this block as needing incoming
-     edge redirections.  */
-  for (i = 0; i < VARRAY_ACTIVE_SIZE (redirection_data); i++)
-    {
-      struct redirection_data *rd = VARRAY_GENERIC_PTR (redirection_data, i);
-      free (rd);
-    }
+  /* Done with this block.  Clear REDIRECTION_DATA.  */
   VARRAY_CLEAR (redirection_data);
 }
 


-- 


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


  parent reply	other threads:[~2004-08-17 20:49 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-16  1:59 [Bug middle-end/17044] New: " danglin at gcc dot gnu dot org
2004-08-16  2:03 ` [Bug middle-end/17044] [3.5 Regression] " pinskia at gcc dot gnu dot org
2004-08-16  2:11 ` dave at hiauly1 dot hia dot nrc dot ca
2004-08-16  4:18 ` danglin at gcc dot gnu dot org
2004-08-16  6:07 ` law at redhat dot com
2004-08-16 14:40 ` danglin at gcc dot gnu dot org
2004-08-17  5:26 ` pinskia at gcc dot gnu dot org
2004-08-17  5:44 ` law at redhat dot com
2004-08-17 16:27 ` dave at hiauly1 dot hia dot nrc dot ca
2004-08-17 17:38 ` dave at hiauly1 dot hia dot nrc dot ca
2004-08-17 20:49 ` dave at hiauly1 dot hia dot nrc dot ca [this message]
2004-08-18 15:36 ` pinskia at gcc dot gnu dot org
2004-08-24 19:48 ` law at redhat dot com
2004-08-24 20:00 ` dave at hiauly1 dot hia dot nrc dot ca
2004-08-24 20:04 ` law at redhat dot com
2004-08-24 20:59 ` cvs-commit at gcc dot gnu dot org
2004-08-24 21:04 ` pinskia at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040817204938.17313.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).