Bug 104189 - Problem with -fstack-limit-symbol
Problem with -fstack-limit-symbol
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
8.0
All Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2003-09-10 20:52 EDT by Sanjay Gupta
Modified: 2007-04-18 12:57 EDT (History)
0 users

See Also:
Fixed In Version: 3.2.3-20
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-09-17 18:24:28 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Sanjay Gupta 2003-09-10 20:52:13 EDT
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 12:37:41 EDT
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@redhat.com>

        * 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 ();

Note You need to log in before you can comment on or make changes to this bug.