public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dannysmith at users dot sourceforge dot net" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/15551] New: -mtune=pentium4  -O2 with sjlj EH breaks stack probe worker on windows32  targets
Date: Fri, 21 May 2004 11:45:00 -0000	[thread overview]
Message-ID: <20040520075803.15551.dannysmith@users.sourceforge.net> (raw)

When following testcase is compiled with

g++ -O2 -mtune=pentium4

for a cygwin or mingw target, the executable segfaults.

When tuning switch is set to pentium3 or lower,
the executable works correctly.

This is observed on 3.4.0 and on trunk, but not on gcc-3.3.3

/* pm.cpp */
/* Testcase submitted by Hans Horn to mingw bug tracker */

#include <cstring>
#include <fstream>
using namespace std;

ostream* logfile;

//char expList[20000];

int main () {

  logfile = new ofstream("bar", ios::out);

  char expList[20000];
  strcpy(expList, "foo");

  return 0;
}

/* end pm.cpp */



The problem appears to be in scheduling pass moving
sjlj exception handling insns across call to the allocate
stack probe worker (_alloca) in the function prologue.

Here is the assembler output for main() prologue from
g++ -S -O2 -mtune=pentium4 pm.cpp

_main:
	pushl	%ebp
	movl	$20092, %eax
	movl	%esp, %ebp
	pushl	%edi
	pushl	%esi
	movl	$___gxx_personality_sj0, -20052(%ebp) <<<<
	movl	$LLSDA1484, -20048(%ebp)              <<<< 
	pushl	%ebx                                     
	movl	$L4, -20040(%ebp)                     <<<< 
	call	__alloca
	movl	$16, %eax
	andl	$-16, %esp
	call	__alloca
	leal	-24(%ebp), %eax
	movl	%eax, -20044(%ebp)
	leal	-20076(%ebp), %eax
	movl	%esp, -20036(%ebp)
	movl	%eax, (%esp)
	call	__Unwind_SjLj_Register
	call	___main
<snip>

The following patch fixes by restoring the gen_blockage
barrier in i386.c:ix86_expand_prologue that was removed at revision 1.608

http://gcc.gnu.org/ml/gcc-cvs/2003-10/msg00685.html


The patch was tested on i386-pc-mingw32 on 3.4.1 and trunk.

	* config/i386/i386.c (ix86_expand_prologue):  Ensure that scheduling 
pass does
	not move insns across __alloca call


Index: i386.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.c,v
retrieving revision 1.668
diff -c -3 -p -r1.668 i386.c
*** i386.c	17 May 2004 15:23:12 -0000	1.668
--- i386.c	20 May 2004 07:30:16 -0000
*************** ix86_expand_prologue (void)
*** 5295,5300 ****
--- 5295,5304 ----
  	  rtx t = plus_constant (stack_pointer_rtx, allocate);
  	  emit_move_insn (eax, gen_rtx_MEM (SImode, t));
  	}
+ 
+       /* Ensure that scheduling pass does not move insns across __alloca
+          call.  */
+       emit_insn (gen_blockage (const0_rtx));
      }
  
    if (frame.save_regs_using_mov && !TARGET_RED_ZONE)

-- 
           Summary: -mtune=pentium4  -O2 with sjlj EH breaks stack probe
                    worker on windows32  targets
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dannysmith at users dot sourceforge dot net
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-mingw32
  GCC host triplet: i686-pc-mingw32
GCC target triplet: i686-pc-mingw32


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


             reply	other threads:[~2004-05-20  7:58 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-21 11:45 dannysmith at users dot sourceforge dot net [this message]
2004-05-21 12:36 ` [Bug target/15551] [3.4/3.5? Regression] " pinskia at gcc dot gnu dot org
2004-05-29 22:47 ` mmitchel at gcc dot gnu dot org
2004-06-01 20:44 ` kcook at gcc dot gnu dot org
2004-06-07 20:01 ` kcook at gcc dot gnu dot org
2004-06-10 12:47 ` kcook at gcc dot gnu dot org
2004-06-10 13:43 ` mmitchel at gcc dot gnu dot org
2004-06-15 17:42 ` me at cgf dot cx
2004-06-19 17:47 ` mmitchel at gcc dot gnu dot org
2004-06-19 19:18 ` rth at gcc dot gnu dot org
2004-06-21 18:38 ` rth at gcc dot gnu dot org
2004-06-21 21:26 ` mmitchel at gcc dot gnu dot org
2004-06-21 22:52 ` cvs-commit at gcc dot gnu dot org
2004-06-22 21:47 ` cvs-commit at gcc dot gnu dot org
2004-06-22 22:16 ` 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=20040520075803.15551.dannysmith@users.sourceforge.net \
    --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).