Bug 104189

Summary: Problem with -fstack-limit-symbol
Product: [Retired] Red Hat Linux Reporter: Sanjay Gupta <sgupta>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED RAWHIDE QA Contact: Brian Brock <bbrock>
Severity: medium Docs Contact:
Priority: medium    
Version: 8.0   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: 3.2.3-20 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2003-09-17 22:24:28 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Sanjay Gupta 2003-09-11 00:52:13 UTC
Description of problem:
cc1plus: internal error: Segmentation fault

Version-Release number of selected component (if applicable):
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --
infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-
checking --host=i386-redhat-linux --with-system-zlib --enable-__cxa_atexit
Thread model: posix
gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7)

How reproducible:
Every time

Steps to Reproduce:
1.Just gmake -f makefile.unix
2.
3.
    
Actual results:
[sgupta@colorado SignalTest3]$ ./gm
g++ -g -Wall -fstack-limit-symbol=0x7ffe0000 -
I /home/sgupta/gs12/devroot/myneton/../buildroot/dist/include -
I /home/sgupta/gs12/devroot/myneton/../buildroot/dist/idl -
I /home/sgupta/gs12/devroot/myneton/../buildroot/dist/include_part2 -
I /home/sgupta/gs12/devroot/myneton/srcroot/modules/HA/Tools/PltLib  -
DSSRC_BASED_SWITCH_ON_CLIENT  -DMNDEBUG -DMN_LOG_SRTP -DDEBUG -DOS=Linux -
DSTAT_MGR_SUPPORT_WRTP  -c SignalTest3.cpp -
o /home/sgupta/MyExamples/signals/SignalTest3/SignalTest3.o
cc1plus: internal error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://bugzilla.redhat.com/bugzilla/> for instructions.
gmake: *** [/home/sgupta/MyExamples/signals/SignalTest3/SignalTest3.o] Error 1


Expected results:
Should compile

Additional info:

Comment 1 Jakub Jelinek 2003-09-11 16:37:41 UTC
The problem is that for -fstack-limit-{register,symbol} ggc_strdup is used
before GGC is initialized (and stringpool as well).
In GCC 3.3 and later, GGC/stringpool are initialized much earlier, so this is not a problem.
But note that you're using the option incorrectly, see info gcc. You need to
give it a symbol name, not an integer constant. It may work by luck on some arches,
but certainly will not work on other arches.

2003-09-11  Jakub Jelinek  <jakub>

        * toplev.c (stack_limit_reg, stack_limit_symbol): New.
        (decode_f_option): Don't set stack_limit_rtx here, set
        stack_limit_{reg,symbol} instead.
        (lang_independent_init): Set stack_limit_rtx here.

--- gcc/toplev.c.jj     2003-07-29 10:27:56.000000000 -0400
+++ gcc/toplev.c        2003-09-11 12:14:09.000000000 -0400
@@ -831,6 +831,9 @@ int flag_stack_check;
    the support provided depends on the backend.  */
 rtx stack_limit_rtx;

+int stack_limit_reg = -1;
+const char *stack_limit_symbol;
+
 /* 0 if pointer arguments may alias each other.  True in C.
    1 if pointer arguments may not alias each other but may alias
    global variables.
@@ -3977,14 +3980,13 @@ decode_f_option (arg)
       if (reg < 0)
        error ("unrecognized register name `%s'", option_value);
       else
-       stack_limit_rtx = gen_rtx_REG (Pmode, reg);
+       stack_limit_reg = reg;
     }
   else if ((option_value
            = skip_leading_substring (arg, "stack-limit-symbol=")))
     {
-      const char *nm;
-      nm = ggc_strdup (option_value);
-      stack_limit_rtx = gen_rtx_SYMBOL_REF (Pmode, nm);
+      stack_limit_symbol = xstrdup (option_value);
+      stack_limit_reg = -2;
     }
   else if ((option_value
             = skip_leading_substring (arg, "message-length=")))
@@ -4003,7 +4005,7 @@ decode_f_option (arg)
        error ("unrecognized option `%s'", arg - 2);
     }
   else if (!strcmp (arg, "no-stack-limit"))
-    stack_limit_rtx = NULL_RTX;
+    stack_limit_reg = -1;
   else if (!strcmp (arg, "preprocessed"))
     /* Recognise this switch but do nothing.  This prevents warnings
        about an unrecognized switch if cpplib has not been linked in.  */
@@ -5118,6 +5120,14 @@ lang_independent_init ()
   init_stringpool ();
   init_obstacks ();

+  if (stack_limit_reg == -2)
+    {
+      const char *nm = ggc_strdup (stack_limit_symbol);
+      stack_limit_rtx = gen_rtx_SYMBOL_REF (Pmode, nm);
+    }
+  else if (stack_limit_reg >= 0)
+    stack_limit_rtx = gen_rtx_REG (Pmode, stack_limit_reg);
+
   /* init_emit_once uses reg_raw_mode and therefore must be called
      after init_regs which initialized reg_raw_mode.  */
   init_regs ();