aboutsummaryrefslogtreecommitdiff
path: root/gcc/toplev.c
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2016-01-19 14:35:16 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2016-01-19 14:35:16 +0000
commitd6874f56624074a067b5f42bbacae030201e4520 (patch)
treed79b1923ebfa78c9386a4fa276282c145ef07993 /gcc/toplev.c
parent962801c550a859cc05fd761fac09ade6beb5e34a (diff)
downloadgcc-d6874f56624074a067b5f42bbacae030201e4520.zip
gcc-d6874f56624074a067b5f42bbacae030201e4520.tar.gz
gcc-d6874f56624074a067b5f42bbacae030201e4520.tar.bz2
Fix memory chunk corruption for opts_obstack (PR jit/68446)
gcc/ChangeLog: PR jit/68446 * gcc.c (driver::decode_argv): Add call to init_opts_obstack before init_options_struct. * opts.c (init_opts_obstack): Remove idempotency. (init_options_struct): Replace call to init_opts_obstack with a gcc_assert to verify that it has already been called. * toplev.c (toplev::main): Add call to init_opts_obstack before calls to init_options_struct. (toplev::finalize): Move cleanup of opts_obstack next to cleanup of save_decoded_options, clearing the latter, and save_decoded_options_count. From-SVN: r232567
Diffstat (limited to 'gcc/toplev.c')
-rw-r--r--gcc/toplev.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/gcc/toplev.c b/gcc/toplev.c
index b754e5b..28c115d 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -2053,6 +2053,7 @@ toplev::main (int argc, char **argv)
/* One-off initialization of options that does not need to be
repeated when options are added for particular functions. */
init_options_once ();
+ init_opts_obstack ();
/* Initialize global options structures; this must be repeated for
each structure used for parsing options. */
@@ -2134,11 +2135,15 @@ toplev::finalize (void)
finalize_options_struct (&global_options);
finalize_options_struct (&global_options_set);
+ /* save_decoded_options uses opts_obstack, so these must
+ be cleaned up together. */
+ obstack_free (&opts_obstack, NULL);
XDELETEVEC (save_decoded_options);
+ save_decoded_options = NULL;
+ save_decoded_options_count = 0;
/* Clean up the context (and pass_manager etc). */
delete g;
g = NULL;
- obstack_free (&opts_obstack, NULL);
}