https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68446
--- Comment #5 from Martin Liška <marxin at gcc dot gnu.org> --- Hi David. Removal of lazy initialization: diff --git a/gcc/opts.c b/gcc/opts.c index 2add158..cc96150 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -273,7 +273,7 @@ init_opts_obstack (void) { static bool opts_obstack_initialized = false; - if (!opts_obstack_initialized) +// if (!opts_obstack_initialized) { opts_obstack_initialized = true; gcc_obstack_init (&opts_obstack); Introduces back the memory leak that was removed in r230264: $ valgrind --leak-check=yes --trace-children=yes ./xgcc -B. -c /home/marxin/Programming/gcc3/gcc/testsuite/g++.dg/ext/mv1.C -O2 -fPIC ==24974== 1,245,184 bytes in 19 blocks are definitely lost in loss record 922 of 924 ==24974== at 0x4C2A00F: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==24974== by 0x1B32A77: xmalloc (xmalloc.c:148) ==24974== by 0xAE53CA: memory_block_pool::allocate() (memory-block.h:56) ==24974== by 0x1AE7465: mempool_obstack_chunk_alloc(unsigned long) (memory-block.cc:49) ==24974== by 0x1B31B37: _obstack_begin_worker (obstack.c:141) ==24974== by 0x1AC7341: init_opts_obstack() (opts.c:279) ==24974== by 0x1AC7362: init_options_struct(gcc_options*, gcc_options*) (opts.c:290) ==24974== by 0x145F196: ix86_valid_target_attribute_p(tree_node*, tree_node*, tree_node*, int) (i386.c:6253) ==24974== by 0xACAD03: handle_target_attribute(tree_node**, tree_node*, tree_node*, int, bool*) (c-common.c:9421) ==24974== by 0xA8D645: decl_attributes(tree_node**, tree_node*, int) (attribs.c:548) ==24974== by 0x8D6CDE: cplus_decl_attributes(tree_node**, tree_node*, int) (decl2.c:1490) ==24974== by 0x7EB0CB: grokfndecl(tree_node*, tree_node*, tree_node*, tree_node*, tree_node*, tree_node*, int, overload_flags, int, cp_ref_qualifier, tree_node*, int, int, int, int, bool, special_function_kind, bool, int, tree_node*, tree_node**, unsigned int) (decl.c:8152) Using trunk with the patch you suggest, I see invalid write operation by valgrind (same command line): ==27543== Invalid write of size 8 ==27543== at 0x4C2C7DF: memset (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==27543== by 0xAE54D6: memory_block_pool::release(void*) (memory-block.h:70) ==27543== by 0xAE5696: base_pool_allocator<memory_block_pool>::release() (alloc-pool.h:302) ==27543== by 0xC97CAE: base_pool_allocator<memory_block_pool>::release_if_empty() (alloc-pool.h:325) ==27543== by 0xC97C61: object_allocator<et_occ>::release_if_empty() (alloc-pool.h:477) ==27543== by 0xC97404: et_free_pools (et-forest.c:509) ==27543== by 0xC191D1: free_dominance_info(function*, cdi_direction) (dominance.c:686) ==27543== by 0xC19223: free_dominance_info(cdi_direction) (dominance.c:696) ==27543== by 0xF935CB: execute_pass_list(function*, opt_pass*) (passes.c:2424) ==27543== by 0xBC7FAB: cgraph_node::analyze() (cgraphunit.c:636) ==27543== by 0xBC9716: analyze_functions(bool) (cgraphunit.c:1080) ==27543== by 0xBCDCD8: symbol_table::finalize_compilation_unit() (cgraphunit.c:2531) ==27543== Address 0x72f15d0 is 16 bytes inside a block of size 65,536 alloc'd ==27543== at 0x4C2A00F: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==27543== by 0x1B32AA7: xmalloc (xmalloc.c:148) ==27543== by 0xAE53CA: memory_block_pool::allocate() (memory-block.h:56) ==27543== by 0xAE576A: base_pool_allocator<memory_block_pool>::allocate() (alloc-pool.h:365) ==27543== by 0xC97BC5: object_allocator<et_occ>::allocate() (alloc-pool.h:486) ==27543== by 0xC97259: et_new_occ(et_node*) (et-forest.c:445) ==27543== by 0xC97315: et_new_tree (et-forest.c:472) ==27543== by 0xC18FEF: calculate_dominance_info(cdi_direction) (dominance.c:647) ==27543== by 0x1109047: cleanup_tree_cfg_noloop() (tree-cfgcleanup.c:753) ==27543== by 0x110915B: cleanup_tree_cfg() (tree-cfgcleanup.c:812) ==27543== by 0x10EB907: execute_build_cfg() (tree-cfg.c:360) ==27543== by 0x10EB966: (anonymous namespace)::pass_build_cfg::execute(function*) (tree-cfg.c:389) Martin